Scanpy vs. 1.3.6
installed using pip3
OSX 10.10.5
Jupyter lab
code:
list_of_list_of_marker_genes = [mg1, mg2, mg3]
for mg in list_of_list_of_marker_genes:
sc.pl.stacked_violin(adata, mg, groupby = 'louvain’, rotation=90)
print(mg)
This works for some mg's but not for all; sc.pl.matrixplot works for all of them; the same for sc.pl.violin; it works also if I would combine all marker genes into one list and then run
sc.pl.stacked_violin. When I say it does not work: it typically generates one stacked plot and then
'hangs up' with an error message for subsequent plots:
Error message:
IndexError: list index out of range
When I run sc.pl.stacked_violin for the individual mg’s, some work others don’t. It is a reproducible results.
I explicitly tested whether the genes in the respective marker gene lists are present in ’n_cells’. If not, I update the lists.
What am I missing here?
@fidelram Could it be that stacked_violin doesn't fully account for .raw?
Hi, sorry for the late reply. Given that the function works for some mg
genes but not for other, this usually indicates that the gene may not be in
the matrix. Can you try to set use_raw=True just to check if this is the
issue (although use_raw should be True by default). Still, very suspicious
that it works with with other functions like matrixplot.
On Thu, Dec 27, 2018 at 9:07 PM Alex Wolf notifications@github.com wrote:
@fidelram https://github.com/fidelram Could it be that stacked_violin
doesn't fully account for .raw?—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/theislab/scanpy/issues/405#issuecomment-450221575,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEu_1ftSP-OSKeDQYWV8Eu0-oRt6aXBAks5u9Sh_gaJpZM4ZiTv5
.
That's why I meant the usual use_raw=None defaulting to True if .raw has been set might not be consistently implemented in stacked_violin?
Hi, no worries! I tried that but by explicitly stating ‘use_raw=True’ but it did not change the outcome.
From: Fidel Ramirez notifications@github.com
Reply-To: theislab/scanpy reply@reply.github.com
Date: Monday, January 7, 2019 at 11:16 AM
To: theislab/scanpy scanpy@noreply.github.com
Cc: "Heymann, Jurgen (NIH/NIDDK) [E]" heymannj@niddk.nih.gov, Author author@noreply.github.com
Subject: Re: [theislab/scanpy] sc.pl.stacked_violin: IndexError, list index out of range (#405)
Hi, sorry for the late reply. Given that the function works for some mg
genes but not for other, this usually indicates that the gene may not be in
the matrix. Can you try to set use_raw=True just to check if this is the
issue (although use_raw should be True by default). Still, very suspicious
that it works with with other functions like matrixplot.
On Thu, Dec 27, 2018 at 9:07 PM Alex Wolf notifications@github.com wrote:
@fidelram https://github.com/fidelram Could it be that stacked_violin
doesn't fully account for .raw?—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/theislab/scanpy/issues/405#issuecomment-450221575,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEu_1ftSP-OSKeDQYWV8Eu0-oRt6aXBAks5u9Sh_gaJpZM4ZiTv5
.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/theislab/scanpy/issues/405#issuecomment-451988385, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AioIiKYX4lsLgg91sMNygZWO1ALRDzsqks5vA3KmgaJpZM4ZiTv5.
Looking at the function code I don't see why your example does not work. @falexwolf, I checked and use_raw is consistently used in all plot functions.
@JuHey Can you check that mg is a python list?
Do you mind sharing privately your data to try to identify the problem? Or even better, can you reproduce the problem using the example data in Scanpy (e.g. https://scanpy-tutorials.readthedocs.io/en/latest/visualizing-marker-genes.html)?
@fidelram Thank you for your suggestions! The example data in Scanpy worked without flaw. I will go over my code again!
Hi, no worries! I tried that but by explicitly stating ‘use_raw=True’ but it did not change the outcome. From: Fidel Ramirez notifications@github.com Reply-To: theislab/scanpy reply@reply.github.com Date: Monday, January 7, 2019 at 11:16 AM To: theislab/scanpy scanpy@noreply.github.com Cc: "Heymann, Jurgen (NIH/NIDDK) [E]" heymannj@niddk.nih.gov, Author author@noreply.github.com Subject: Re: [theislab/scanpy] sc.pl.stacked_violin: IndexError, list index out of range (#405) Hi, sorry for the late reply. Given that the function works for some mg genes but not for other, this usually indicates that the gene may not be in the matrix. Can you try to set
use_raw=Truejust to check if this is the issue (although use_raw should be True by default). Still, very suspicious that it works with with other functions like matrixplot.
On Thu, Dec 27, 2018 at 9:07 PM Alex Wolf @.*> wrote: @fidelram https://github.com/fidelram Could it be that stacked_violin doesn't fully account for .raw? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#405 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AEu_1ftSP-OSKeDQYWV8Eu0-oRt6aXBAks5u9Sh_gaJpZM4ZiTv5 .
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#405 (comment)>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AioIiKYX4lsLgg91sMNygZWO1ALRDzsqks5vA3KmgaJpZM4ZiTv5.
Same error!
@fidelram Thank you for your suggestions! The example data in Scanpy worked without flaw. I will go over my code again!
Actually I solved this problem by adding more markers in the marker gene list.
Alternatively The error will be gone if I swap_axes=True
Interesting
I'm also getting this list error, but @brianpenghe 's suggestion of using swap_axes=True also seems to have fixed the problem. At least it shows a plot now, although not sure if its correct yet
@outlace Did you try adding more marker genes? The error is gone if you have a large number of marker genes to plot in my case.
@brianpenghe No I did not try that, but I will soon. Ideally we should be able to plot however many we want
Just made a pull request that fixes this issue. @brianpenghe
I did some debugging and the variable num_rows was incorrectly calculated only when swap_axes==False on line 880 of _anndata.py. Instead of num_rows = len(categories) it should be num_rows = len(var_names) . If you make that small change in your _anndata.py in ~/anaconda3/lib/site-packages/scanpy/plotting/_anndata.py then recompile the packages using python -m compileall . and restart python it should work.
Most helpful comment
Actually I solved this problem by adding more markers in the marker gene list.
Alternatively The error will be gone if I
swap_axes=TrueInteresting