You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of scanpy.
(optional) I have confirmed this bug exists on the main branch of scanpy.
What happened?
When doing HVG selection with batch_key = "something" and subset = True, I noticed unexpected genes to be selected in the subset anndata. Upon further investigation, it seems that somehow the inplace subsetting goes wrong. (Though I checked the source code and could not find any issue that may explain it there.)
Hey, thanks a lot for spotting & the nice reproducible example! Big help.
From my first look into it, it seems this is a bug indeed;
Bug appearing when
batch_key is not None and
flavor is “seurat” or “cell_ranger” and
then using subset=True.
Other cases are not suffering from this it seems (e.g. flavor="seurat_v3", or when batch_key=None).
Issue
It appears in the cases describe above, subset=True will cause the first n_top_genes many genes of adata.var to be used as selection: not the actual n_top_genes highly variable genes.
Fix is on the way: I'll follow up here.
Your Example
Reveals that sc.pp.highly_variable_genes(ad_sub, n_top_genes = 1000, batch_key = "Age", subset = True) suffers from this.
Circumvent bug
For now, I recommend not using subset=True if the cases above hold for you:
Rather, use
Please make sure these conditions are met
What happened?
When doing HVG selection with batch_key = "something" and subset = True, I noticed unexpected genes to be selected in the subset anndata. Upon further investigation, it seems that somehow the inplace subsetting goes wrong. (Though I checked the source code and could not find any issue that may explain it there.)
Minimal code sample
Error output
Versions
The text was updated successfully, but these errors were encountered: