[go: nahoru, domu]

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

Split violin plot #1448

Closed
brianpenghe opened this issue Oct 7, 2020 · 7 comments
Closed

Split violin plot #1448

brianpenghe opened this issue Oct 7, 2020 · 7 comments

Comments

@brianpenghe
Copy link
brianpenghe commented Oct 7, 2020

Hello,
Currently only scanpy.pl.rank_genes_groups_violin can give us a split violin plot. But can we request a feature to allow us to do a split-violinplot of our own gene lists?

image

Thanks

@fidelram
Copy link
Collaborator
fidelram commented Oct 9, 2020

Can you elaborate? You can use sc.pl.violin independently.

@brianpenghe
Copy link
Author

Can you elaborate? You can use sc.pl.violin independently.

OK I just updated my question and attached a sample image. What I want to do is split-violinplot.

@fidelram
Copy link
Collaborator

Thanks for the update. Now is clear.

We do not offer that possibility as most of those functions are based on seaborn, thus, simply passing the relevant data to seaborn will get you the image that you want.

Nevertheless, I would like to take a look. How do you think this should work. Just add a variable to show the genes that you would like to see. Or you mean a more generic function just to make split plots between any two categories for the genes that you want to see?

@brianpenghe
Copy link
Author

Thanks for the update. Now is clear.

We do not offer that possibility as most of those functions are based on seaborn, thus, simply passing the relevant data to seaborn will get you the image that you want.

Nevertheless, I would like to take a look. How do you think this should work. Just add a variable to show the genes that you would like to see. Or you mean a more generic function just to make split plots between any two categories for the genes that you want to see?

Thanks for your attention. Yes it would be nice if I could compare two .obs categories with regard to expression distributions of a list of genes I supply.

Thanks!

@fidelram
Copy link
Collaborator

This is a way to do it btw:

adata = sc.datasets.pbmc68k_reduced()
adata = adata[adata.obs.louvain.isin(['0','1'])].copy()
df = sc.get.obs_df(adata, ['PTPN7', 'SMAP2', 'PPDPF', 'louvain'])
df = df.set_index('louvain').stack().reset_index()
df.columns = ['louvain', 'gene', 'value']
import seaborn as sns
sns.violinplot(data=df, x='gene', y='value', hue="louvain",
                split=True, inner="quart", linewidth=1)           

image

@brianpenghe
Copy link
Author

Thank you very much!

@howtofindme
Copy link

This is a way to do it btw:

adata = sc.datasets.pbmc68k_reduced()
adata = adata[adata.obs.louvain.isin(['0','1'])].copy()
df = sc.get.obs_df(adata, ['PTPN7', 'SMAP2', 'PPDPF', 'louvain'])
df = df.set_index('louvain').stack().reset_index()
df.columns = ['louvain', 'gene', 'value']
import seaborn as sns
sns.violinplot(data=df, x='gene', y='value', hue="louvain",
                split=True, inner="quart", linewidth=1)           

image

Thanks for the suggestion!
I am new to pthon.
In your samples, you have '0' and '1' conditions in 'louvain'.
But what if I have three conditions, How can I split the violin?

Best,
Young

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants