adata.var.sort_index(inplace=True) does not sort adata.X
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
- 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 master branch of scanpy.
When sorting the adata object using adata.var.sort_index(inplace=True) the adata.X is not sorting accordingly (see example below).
import numpy as np
import pandas as pd
import scanpy as sc
import matplotlib.pyplot as plt
sc.settings.verbosity = 3
sc.logging.print_header()
adata = sc.datasets.pbmc3k()
adata.to_df()['MPO'].sum()
adata.var.sort_index(inplace=True)
adata.to_df()['MPO'].sum()
Versions
anndata 0.8.0
scanpy 1.9.1
PIL 9.2.0
asttokens NA
backcall 0.2.0
beta_ufunc NA
binom_ufunc NA
cffi 1.15.1
cycler 0.10.0
cython_runtime NA
dateutil 2.8.2
debugpy 1.5.1
decorator 5.1.1
defusedxml 0.7.1
entrypoints 0.4
executing 0.8.3
google NA
h5py 3.7.0
hypergeom_ufunc NA
igraph 0.9.11
ipykernel 6.17.1
ipython_genutils 0.2.0
ipywidgets 8.0.2
jedi 0.18.1
joblib 1.2.0
kiwisolver 1.4.4
leidenalg 0.8.10
llvmlite 0.39.1
loompy 3.0.7
matplotlib 3.6.0
matplotlib_inline NA
mpl_toolkits NA
natsort 8.2.0
nbinom_ufunc NA
ncf_ufunc NA
numba 0.56.2
numpy 1.23.3
numpy_groupies 0.9.19
packaging 21.3
pandas 1.4.4
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pkg_resources NA
platformdirs 2.6.0
prompt_toolkit 3.0.20
psutil 5.9.4
ptyprocess 0.7.0
pure_eval 0.2.2
pycparser 2.21
pydev_ipython NA
pydevconsole NA
pydevd 2.6.0
pydevd_concurrency_analyser NA
pydevd_file_utils NA
pydevd_plugins NA
pydevd_tracing NA
pygments 2.11.2
pynndescent 0.5.7
pyparsing 3.0.9
pytz 2022.2.1
scipy 1.9.1
scvelo 0.2.4
session_info 1.0.0
setuptools_scm NA
six 1.16.0
sklearn 1.1.2
stack_data 0.2.0
statsmodels 0.13.2
texttable 1.6.4
threadpoolctl 3.1.0
tornado 6.2
tqdm 4.64.1
traitlets 5.6.0
typing_extensions NA
umap 0.5.3
wcwidth 0.2.5
yaml 5.4.1
zipp NA
zmq 24.0.1
IPython 8.4.0
jupyter_client 7.4.8
jupyter_core 5.1.0
notebook 6.5.2
Python 3.9.13 (main, Aug 25 2022, 23:26:10) [GCC 11.2.0]
Linux-5.4.0-1092-aws-x86_64-with-glibc2.27
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided pbmc3k example with the reported scanpy and anndata versions, comparing adata.var.index, adata.to_df(), and adata.X before and after adata.var.sort_index(inplace=True). Trace the implementation behind that entry point and add regression coverage for the reported mismatch. Done means sorting adata.var keeps adata.X and the resulting data-frame values aligned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100