scverse / scverse/scanpy

Changing the use_raw behavior without breaking things

Open
#1,798 10 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

It is common to store raw counts (=unnormalized) of all measured genes under adata.raw, while having normalized and unnormalized expression of a subset of genes (might be only protein coding genes, or all genes except ribosomal and mitochondrial etc) at adata.X and adata.layers['counts'] respectively. This however gives rise to a lot of trouble in plotting since visualizing raw counts is not a great idea due to the dynamic range. It is super annoying to pass use_raw=False to a lot of functions. Furthermore, weird rank_genes_groups outputs as a result of raw counts might go unnoticed because of this. (happened to me many times)

I think there was a discussion somewhere about switching to use_raw=False by default in all functions, but this may potentially break things since it's a significant behavior change. This might be reasonable for Scanpy 2.0, but not in 1.x I assume.

My suggestion is to have a use_raw option under sc.settings (i.e. the global ScanpyConfig instance) which is None by default, and can be set to False (e.g. sc.settings.use_raw=False) which would then affect all the functions with use_raw argument. This way we don't break the behavior but still have a reasonable way to turn this thing off :)

Let me know what you think.

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

Review the global ScanpyConfig instance exposed as sc.settings and the functions that accept a use_raw argument. Determine how a None default should preserve existing behavior while sc.settings.use_raw=False affects those functions, then verify plotting and rank_genes_groups behavior. The issue names no specific files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.