scverse / scverse/scanpy

"scanpy.pl.rank_genes_groups{,_violin}" are inconsistent with gene_names assignment

Open
#2,258 3 comments 0 reactions 1 assignee View on GitHub

@flying-sheep is already working on this.

Since Jul 27, 2023.

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

Description

https://github.com/scverse/scanpy/blob/2e98705347ea484c36caa9ba10de1987b09081bf/scanpy/plotting/_tools/__init__.py#L1151-L1156

For reference, sc.pl.rank_genes_groups assigns "_gene_names" as such https://github.com/scverse/scanpy/blob/2e98705347ea484c36caa9ba10de1987b09081bf/scanpy/plotting/_tools/__init__.py#L402-L406

This is causing a situation where I can pass identical parameters to both functions but rank_genes_groups_violin fails where rank_genes_groups succeeds. Basically in the violin plot one, the get_obs_df function is creating a dataframe using the <gene_symbol_key> as the columns but using adata.var_names (stored in adata.uns["rank_genes_groups"]["names"]) as the key to search for. If the <gene_symbol_key> is not the index of adata.var, then this fails with a KeyError.

I am using scanpy==1.8.2 and anndata==0.7.8 but can confirm that this code is still present in the master branch (as shown above)

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.