Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subset based on terminal #462

Closed
wangmhan opened this issue Jan 14, 2021 · 10 comments
Closed

subset based on terminal #462

wangmhan opened this issue Jan 14, 2021 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@wangmhan
Copy link

...
Hi,

If I want to select cells for those who has the probability to one specific terminal state, i.e. in the tutorial Alpha. Is it possible to use parameters in adata.obs? I thought "clusters_gradients" is the most possible terminal states, please correct me if I understand wrong. But in my case, the proportion of "clusters_gradients" is always not even. For example, terminal type A, the cell number is 4000 cells, for terminal type B, it is 80 cells. I tried several datasets and it is always like that. One extremely high and the other is extremely low, which didn't make so much sense.
Please let me know if have any suggestions how to subset, it would be really helpful.

Thank you!

@wangmhan wangmhan added the question Further information is requested label Jan 14, 2021
@Marius1311
Copy link
Collaborator

Hi @wangmhan, thanks for your questions. I don't quite understand the problem you're facing, maybe you can help me by posting a code snippet that illustrates your question? Thanks!

@wangmhan
Copy link
Author

wangmhan commented Jan 15, 2021 via email

@Marius1311
Copy link
Collaborator

I think it would help me to understand your application. Why do you want to subset cells according to their lineage membership? What final plot would you like to generate?

@wangmhan
Copy link
Author

wangmhan commented Jan 19, 2021 via email

@Marius1311
Copy link
Collaborator

Marius1311 commented Jan 19, 2021

ok, got it! You don't need to subset cell for this - here's how I would do this: follow the steps of the pancreas advanced tutorial until line 23. At this point, you should have computed your set of terminal states and fate (absorption) probabilities towards them. Next, you illustrate the lineage you're interested in via it's associated fate probabilities like so:

g_fwd.plot_absorption_probabilities(same_plot=False, lineages=['YOUR_LINEAGE'], show_dp=False)

where the parameters are explained in the docstring. This will give you something like this:

image

Next, when you want to select genes which are specific to this lineage, you again use the corresponding fate probabilities by calling

g_fwd.compute_lineage_drivers(lineages=['YOUR_LINEAGE'], cluster_key='clusters', clusters=['RESTRICT_TO_RELEVANT_CLUSTERS'], use_raw=True)

This will compute correlations of genes with that respective lineage as well as their p and multiple-testing adjusted q-values. This will give you a set of genes which show interesting dynamics along your lineage. To plot these in a heatmap, use

model = cr.ul.models.GAM(adata_raw, n_knots=n_knots)
fig_kwargs = {'model': model, 
              'genes': GENES_THAT_CORRLEATE_WITH_THIS_LINEAGE 
              'lineages': ['YOUR_LINEAGE'], 
              'cluster_key': 'clusters', 
              'time_key': YOUR_PSEUDOTIME,  
              'weight_threshold': CELLS_WITH_FATE_PROB_BELOW_THIS_THRESHOLD_WILL_NOT_CONTRIBUTE}
cr.pl.heatmap(adata_raw, **fig_kwargs) 

Please check the precise meaning and function of these function arguments in the API, it's all there. If you have more questions, please check out our examples section, e.g. the example that shows how to plot a heatmap of gene expression trends.

@wangmhan
Copy link
Author

wangmhan commented Jan 20, 2021 via email

@Marius1311
Copy link
Collaborator

Great, let me know whether this worked, then we can close the issue.

@Marius1311
Copy link
Collaborator

Any updates on this?

@wangmhan
Copy link
Author

Hi, It works fine for me. Thank you!

@Marius1311
Copy link
Collaborator

Great, closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants