scverse / scverse/scanpy

Issue with regress_out() and tagging rather than removing highly variable genes?

Open
#667 4 comments 0 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

One benefit of the newer scanpy versions is that calling highly_variable_genes() marks them as 'highly_variable' rather than removes them by default. Later steps (like PCA) use these tags and leave the rest of the data intact. This is great.

Following the pbmc3k workflow though still has a step which requires you to remove all non-highly-variable genes before continuing:

adata = adata[:, adata.var['highly_variable']]

If I do this, things work fine, but if I skip it then the next regress_out step fails with:

ValueError: The first guess on the deviance function returned a nan. This could be a boundary problem and should be reported.

I found discussions like this one where it is suggested a column of 0s might be the issue, but I followed this workflow directly which included these steps:

sc.pp.filter_cells(adata, min_genes=200)
sc.pp.filter_genes(adata, min_cells=3)

Is there a best practice (perhaps something along the line of @LuckyMD 's suggestion in issue #492 ?) to handle this?

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 by reproducing the pbmc3k workflow, comparing the path that filters to adata.var['highly_variable'] with the path that calls regress_out() without removing genes. Read the regress_out() entry point and the linked discussions in issues #230 and #492. Done means establishing the supported behavior or best practice for tagged, non-highly-variable genes and documenting or fixing the failing path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.