scverse / scverse/scanpy

subsetting / subclustering, use raw

Open
#826 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

when I select a subset of cells using ad_sub=ad[ad.obs['louvain']=='subcluster_of_interest',:], and then re-apply preprocessing routines, this will use only the genes of ad.X (variable over the entire dataset), but not those that are variable only within the subcluster and might be informative for its substructure even if the variance doesn't pass the cutoff when evaluated over the entire dataset. basically, the set of variable genes can only shrink by subsetting..

I'd propose to either use

tmp=ad[ad.obs['louvain']=='subcluster_of_interest',:]
ad_sub=sc.AnnData(tmp.raw.X,obs=tmp.obs,var=tmp.raw.var)

to "reset" the .X matrix (maybe there's a better way?)
or to make sc.pp.highly_variable_genes work on ad.raw.X

scanpy==1.4.4 anndata==0.6.22.post1 umap==0.3.10 numpy==1.16.4 scipy==1.2.1 pandas==0.25.1 scikit-learn==0.20.3 statsmodels==0.10.1 python-igraph==0.7.1 louvain==0.6.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the sc.pp.highly_variable_genes entry point and inspect how a subsetted AnnData object and its .raw matrix are handled. Compare the proposed reset-of-.X approach with allowing highly variable gene selection from .raw.X; done means subcluster preprocessing can identify genes variable within the subset rather than only those selected for the full dataset.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.