[x] I have checked that this issue has not already been reported.
[x] I have confirmed this bug exists on the latest version of anndata.
[x] (optional) I have confirmed this bug exists on the master branch of anndata.
Report
The AnnData Initializer verifies index and columns of the input X match var and obs, but does not do the same for layers resulting in possible bugs especially when initializing with layers but no X.
Code:
import numpy as np
import pandas as pd
import anndata as ad
var = pd.DataFrame(index=["gene1", "gene2"])
different_indices = ["gene2", "gene1"]
layer_data = pd.DataFrame(np.array([[5, 6], [7, 8]]), columns=different_indices)
layers = {"layer1": layer_data}
adata = ad.AnnData(obs=obs, var=var, layers=layers)
Versions
-----
anndata 0.11.1.dev10+gaf6480e
session_info 1.0.0
-----
cython_runtime NA
dateutil 2.9.0.post0
exceptiongroup 1.2.2
h5py 3.12.1
natsort 8.4.0
numpy 2.0.2
packaging 24.2
pandas 2.2.3
pytz 2024.2
scipy 1.14.1
six 1.16.0
zoneinfo NA
-----
Python 3.10.15 | packaged by conda-forge | (main, Oct 16 2024, 01:24:20) [Clang 17.0.6 ]
macOS-14.6.1-arm64-arm-64bit
-----
Session information updated at 2024-11-15 21:08
Please make sure these conditions are met
Report
The AnnData Initializer verifies index and columns of the input X match var and obs, but does not do the same for layers resulting in possible bugs especially when initializing with layers but no X.
Code:
Versions