Skip to content

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

@erlun1

Description

@erlun1

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

Details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Triage 🩺This issue needs to be triaged by a maintainer

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions