scverse / scverse/scanpy

Order of pts and pts_rest in rank_genes_groups results doesn't match other fields in adata.uns["rank_genes_groups"]

Open
#3,930 0 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

Please make sure these conditions are met
  • 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?

After running sc.tl.rank_genes_groups, I noticed that in the adata.uns["rank_genes_groups"]dictionary, the ptsand pts_restfields are stored as pandas.DataFrameobjects, while other fields (like names, pvals, logfoldchanges, pvals_adj, scores) are stored as numpy.ndarray.

More importantly, the index order of ptsand pts_restfollows the original adata.var_namesorder, whereas the other fields are ordered by statistical significance (p-value or score). This inconsistency caused confusion in my analysis.

Minimal code sample
# /// script
# requires-python = ">=3.12"
# dependencies = [
#   "scanpy@git+https://github.com/scverse/scanpy.git@main",
# ]
# ///
#
# This script automatically imports the development branch of scanpy to check for issues

import scanpy as sc
# your reproducer code
Error output

Versions

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 behavior through sc.tl.rank_genes_groups and inspect the resulting adata.uns["rank_genes_groups"] fields, especially pts and pts_rest versus names, pvals, logfoldchanges, pvals_adj, and scores. Trace where these results are assembled, then add coverage showing that the affected fields use a consistent ordering and representation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics, data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.