Skip to content

Wrong class supplied to anndata #319

@e-coral

Description

@e-coral

Describe the bug
capcruncher pipeline fails with
ValueError: Varm 'replaced' needs to be of one of <class 'numpy.ndarray'>, <class 'numpy.ma.core.MaskedArray'>, <class 'scipy.sparse._csr.csr_matrix'>, <class 'scipy.sparse._csc.csc_matrix'>, <class 'scipy.sparse._csr.csr_array'>, <class 'scipy.sparse._csc.csc_array'>, <class 'anndata.compat.AwkArray'>, <class 'h5py._hl.dataset.Dataset'>, <class 'anndata.compat.ZarrArray'>, <class 'anndata.compat.ZappyArray'>, <class 'anndata.abc.CSRDataset'>, <class 'anndata.abc.CSCDataset'>, <class 'anndata.compat.DaskArray'>, <class 'anndata.compat.CupyArray'>, or <class 'anndata.compat.CupySparseMatrix'>, not <class 'pandas.core.series.Series'>.

I can't really see how this wouldn't have come up in tests, unless maybe there's a versioning issue with Anndata, whereby different versions of the tool accept different variable classes. Anndata is not listed in the capcruncher requirements file, so I guess the latest version was installed by default as a dependency of a capcruncher dependency.

Potentially relevant pip list info for the conda environment I'm using:
anndata 0.11.4
numpy 1.26.4
pandas 2.1.1
scipy 1.13.1
h5py 3.13.0

To Reproduce
Run the pipeline including differential interactions. If the error isn't reproduced, then try with the above versions of various dependencies.

Expected behavior
This error should not occur. The correct type of data needs to be supplied to the anndata call (see further logging info below), either by changing the supplied data type, or if there is a versioning issue, by specifying the version of anndata to be installed with capcruncher

Additional context
full error message:

File "/path/to/miniconda3/lib/python3.10/site-packages/capcruncher/cli/interactions_differential.py", line 32, in get_differential_interactions
    dds.deseq2()
  File "/path/to/miniconda3/lib/python3.10/site-packages/pydeseq2/dds.py", line 328, in deseq2
    self.refit()
  File "/path/to/miniconda3/lib/python3.10/site-packages/pydeseq2/dds.py", line 738, in refit
    self._replace_outliers()
  File "/path/to/miniconda3/lib/python3.10/site-packages/pydeseq2/dds.py", line 825, in _replace_outliers
    self.varm["replaced"] = pd.Series(False, index=self.var_names)
  File "/path/to/miniconda3/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py", line 214, in __setitem__
    value = self._validate_value(value, key)
  File "/path/to/miniconda3/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py", line 277, in _validate_value
    return super()._validate_value(val, key)
  File "/path/to/miniconda3/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py", line 99, in _validate_value
    return coerce_array(val, name=name, allow_df=self._allow_df)
  File "/path/to/miniconda3/lib/python3.10/site-packages/anndata/_core/storage.py", line 66, in coerce_array
    raise ValueError(msg) from e
ValueError: Varm 'replaced' needs to be of one of <class 'numpy.ndarray'>, <class 'numpy.ma.core.MaskedArray'>, <class 'scipy.sparse._csr.csr_matrix'>, <class 'scipy.sparse._csc.csc_matrix'>, <class 'scipy.sparse._csr.csr_array'>, <class 'scipy.sparse._csc.csc_array'>, <class 'anndata.compat.AwkArray'>, <class 'h5py._hl.dataset.Dataset'>, <class 'anndata.compat.ZarrArray'>, <class 'anndata.compat.ZappyArray'>, <class 'anndata.abc.CSRDataset'>, <class 'anndata.abc.CSCDataset'>, <class 'anndata.compat.DaskArray'>, <class 'anndata.compat.CupyArray'>, or <class 'anndata.compat.CupySparseMatrix'>, not <class 'pandas.core.series.Series'>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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