Skip to content

Empty index when using pt.tl.PseudobulkSpace() #1003

@LuisHeinzlmeier

Description

@LuisHeinzlmeier

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 pertpy.
  • (optional) I have confirmed this bug exists on the main branch.

Report

This error does not occur when using dc.pp.pseudobulk().

Code:

>>> import pertpy as pt
>>> adata = pt.dt.zhang_2021()
>>> adata = adata[adata.obs["Origin"] == "t", :].copy()
>>> adata.layers["counts"] = adata.X.copy()
>>> ps = pt.tl.PseudobulkSpace()
>>> pdata = ps.compute(
...     adata,
...     target_col="Patient",
...     groups_col="Cluster",
...     layer_key="counts",
...     mode="sum",
... )
>>> pds2 = pt.tl.PyDESeq2(pdata, design="~Efficacy+Treatment")
>>> res_df = pds2.compare_groups(
...     pdata,
...     column="Efficacy",
...     baseline="SD",
...     groups_to_compare=["PR", "PD"],
... )

Traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    res_df = pds2.compare_groups(
        pdata,
    ...<2 lines>...
        groups_to_compare=["PR", "PD"],
    )
  File "/Users/luisheinzlmeier/Desktop/Repos/pertpy/pertpy/tools/_differential_gene_expression/_base.py", line 903, in compare_groups
    model.fit(**fit_kwargs)
    ~~~~~~~~~^^^^^^^^^^^^^^
  File "/Users/luisheinzlmeier/Desktop/Repos/pertpy/pertpy/tools/_differential_gene_expression/_pydeseq2.py", line 62, in fit
    dds = DeseqDataSet(
        adata=adata_for_dds,
    ...<3 lines>...
        **kwargs,
    )
  File "/Users/luisheinzlmeier/Library/Application Support/hatch/env/virtual/pertpy/RYWIBvOS/hatch-test.py3.14-stable/lib/python3.14/site-packages/pydeseq2/dds.py", line 302, in __init__
    self.obsm["design_matrix"] = self.design
    ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/luisheinzlmeier/Library/Application Support/hatch/env/virtual/pertpy/RYWIBvOS/hatch-test.py3.14-stable/lib/python3.14/site-packages/anndata/_core/aligned_mapping.py", line 219, in __setitem__
    value = self._validate_value(value, key)
  File "/Users/luisheinzlmeier/Library/Application Support/hatch/env/virtual/pertpy/RYWIBvOS/hatch-test.py3.14-stable/lib/python3.14/site-packages/anndata/_core/aligned_mapping.py", line 278, in _validate_value
    raise ValueError(msg) from None
ValueError: value.index does not match parent’s obs names:
Index are different

Attribute "inferred_type" are different
[left]:  empty
[right]: string

Versions

| Package | Version |
| ------- | ------- |
| pertpy  | 1.1.0   |
| anndata | 0.12.16 |

| Dependency          | Version                |
| ------------------- | ---------------------- |
| jaxlib              | 0.10.1                 |
| interface_meta      | 2.0.1                  |
| ott-jax             | 0.6.0                  |
| llvmlite            | 0.47.0                 |
| fsspec              | 2026.4.0               |
| cycler              | 0.12.1                 |
| h5py                | 3.16.0                 |
| asttokens           | 3.0.1                  |
| mudata              | 0.3.8                  |
| etils               | 1.14.0                 |
| scikit-learn        | 1.8.0                  |
| pure_eval           | 0.2.3                  |
| blitzgsea           | 1.3.54                 |
| packaging           | 26.2                   |
| jaxtyping           | 0.3.10                 |
| typing_extensions   | 4.15.0                 |
| fast-array-utils    | 1.4.1                  |
| comm                | 0.2.3                  |
| decorator           | 5.3.1                  |
| matplotlib          | 3.10.9                 |
| zarr                | 3.2.1                  |
| scverse-misc        | 0.0.7                  |
| numpyro             | 0.21.0                 |
| sparsecca           | 0.3.1                  |
| ml_dtypes           | 0.5.4                  |
| joblib              | 1.5.3                  |
| wrapt               | 2.2.1                  |
| donfig              | 0.8.1.post1            |
| executing           | 2.2.1                  |
| multipledispatch    | 1.0.0 (0.6.0)          |
| adjustText          | 1.3.0                  |
| pyarrow             | 24.0.0                 |
| equinox             | 0.13.8                 |
| stack-data          | 0.6.3                  |
| pandas              | 2.3.3                  |
| jax                 | 0.10.1                 |
| charset-normalizer  | 3.4.7                  |
| kiwisolver          | 1.5.0                  |
| wcwidth             | 0.7.0                  |
| legacy-api-wrap     | 1.5                    |
| parso               | 0.8.7                  |
| session-info2       | 0.4.1                  |
| psutil              | 7.2.2                  |
| platformdirs        | 4.10.0                 |
| six                 | 1.17.0                 |
| opt_einsum          | 3.4.0                  |
| pytz                | 2026.2                 |
| flax                | 0.12.7                 |
| seaborn             | 0.13.2                 |
| numpy               | 2.4.6                  |
| Pygments            | 2.20.0                 |
| patsy               | 1.0.2                  |
| filelock            | 3.29.0                 |
| tqdm                | 4.67.3                 |
| msgpack             | 1.1.2                  |
| threadpoolctl       | 3.6.0                  |
| pyparsing           | 3.3.2                  |
| optax               | 0.2.8                  |
| mpmath              | 1.3.0                  |
| absl-py             | 2.4.0                  |
| wadler_lindig       | 0.1.7                  |
| statsmodels         | 0.14.6                 |
| coverage            | 7.14.1                 |
| numba               | 0.65.1                 |
| lineax              | 0.1.1                  |
| jaxopt              | 0.8.5                  |
| setuptools          | 81.0.0                 |
| PubChemPy           | 1.0.5                  |
| google-crc32c       | 1.8.0                  |
| python-dateutil     | 2.9.0.post0            |
| certifi             | 2026.5.20 (2026.05.20) |
| rich                | 15.0.0                 |
| formulaic-contrasts | 1.0.0                  |
| scikit-misc         | 0.5.2                  |
| pooch               | 1.9.0 (v1.9.0)         |
| jedi                | 0.20.0                 |
| PyYAML              | 6.0.3                  |
| pillow              | 12.2.0                 |
| formulaic           | 1.2.1                  |
| traitlets           | 5.15.0                 |
| natsort             | 8.4.0                  |
| scipy               | 1.17.1                 |
| scanpy              | 1.12.1                 |
| numcodecs           | 0.16.5                 |
| xarray              | 2026.4.0               |
| ipython             | 9.13.0                 |
| prompt_toolkit      | 3.0.52                 |
| pydeseq2            | 0.5.4                  |
| narwhals            | 2.21.2                 |
| ipywidgets          | 8.1.8                  |
| pyomo               | 6.10.0                 |

| Component | Info                                                                   |
| --------- | ---------------------------------------------------------------------- |
| Python    | 3.14.5 (main, May 10 2026, 10:21:34) [Clang 17.0.0 (clang-1700.6.4.2)] |
| OS        | macOS-15.7.4-arm64-arm-64bit-Mach-O                                    |
| Updated   | 2026-06-01 06:20                                                       |

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions