scvelocy 改变root_cell
企业开发
2023-04-17 04:18:18
阅读次数: 0
Hello, Thanks for this soft. There is a lot of work here. I would like to know if is finally possible to set the root clusters (or endpoint) for running scVelo ? I would like to reverse the latent time given by scvelo which is the opposite I expected. I tried to use root_key from latent.time (passing cells ID with adata.obs['root_cells'] #114) but without effect on the latent time graphic. Is this the good way to go ? Is there a use case somewhere ? I know it has been asked several times in the past but didn't find a clear answer and also the version has evolved so ... Thanks. |
Member
WeilerP commented
@ZheFrench, this has not yet been developed and I am also not sure I will do so as this can easily lead to false security/conclusions. Either way, specifying a root cell works. I just double checked and I got it to work by specifying the numerical ID of the root cell (it's a bit hacky), i.e., something along the lines of df = pd.DataFrame(index=adata.obs_names).reset_index()
adata.uns['root_key'] = df.index[df['index'].isin(adata.obs_names[adata.obs[COLUMN_NAME] == CLUSTER_LABEL])][0]
scv.tl.latent_time(adata, root_key='root_key') |
ZheFrench commented
Did not work for me. Ok could you give juste the content of adata.uns['root_key'] I mean the format. By numerical ID , you mean the index not the cellID ? It's just one cell ? I update a little bit,seems better but run for ages whith no end. sample_one_index = pd.DataFrame(sample_one.obs.index)
sample_one.uns['root_key'] = sample_one_index[sample_one_index.isin(sample_one.obs_names[sample_one.obs['my_cluster'] == 1])]
print(sample_one.uns['root_key'])
CellID 0 NaN 1 NaN 2 NaN 3 NaN 4 NaN ... ... 2991 NaN 2992 NaN 2993 TTTGTTGTCTCTGGTCx
Thanks |
Member
WeilerP commented
Did not work for me. I cannot help you without some information (logs, expected vs. actual behavior, etc.)
Ok could you give juste the content of adata.uns['root_key'] I mean the format. By numerical ID , you mean the index not the cellID ? It's just one cell ?
Yes, there is only one root cell, not an entire cluster. If in your AnnData object, the 10th cell is the root cell, you should do adata.uns['root_key'] = 9 This is what I meant by numerical ID (sorry, should have been more clear on this). My code snippet from above takes a given cluster annotation stored in .obs[COLUMN_NAME] and selects all cells which fall into the cluster CLUSTER_LABEL where your root cell lies (e.g. stem cells). I then simply selected the very first cell of all these candidate cells (as I said before, this is a bit hacky and very rudimentary). |
ZheFrench commented
Ok it worked. It reversed the color for the latent time plotting. Perfect. But then there is no way, to reverse the direction of the arrows from the velocity graph ? |
Member
WeilerP commented •
edited
But then there is no way, to reverse the direction of the arrows from the velocity graph ?
No, there is no way to reverse the arrow direction. #216 or #462 might be useful to understand why the inferred directionality is inconsistent with prior knowledge/what you expect. |
转载自blog.csdn.net/qq_52813185/article/details/130055842