Open baconchan opened 2 months ago
This bug has been reported here: #307
Starting from v0.10.9, anndata no longer supports pandas DataFrames or Series in varm fields. Fortunately, PyDeseq2 has addressed this bug in v0.4.11. I recommend updating your PyDeseq2 to v0.4.11 to resolve this issue.
Best wishes, Lei
This bug has been fixed in the latest version of OmicVerse.
result=dds.deg_analysis(treatment_groups,control_groups,method='DEseq2', multipletests_method=None)
Fitting size factors... ... done in 0.01 seconds.
Fitting dispersions... ... done in 29.57 seconds.
Fitting dispersion trend curve... ... done in 6.88 seconds.
Fitting MAP dispersions... logres_prior=1.4874080250589685, sigma_prior=1.0924739582107421 ... done in 35.02 seconds.
Fitting LFCs... ... done in 31.84 seconds.
ValueError Traceback (most recent call last) Cell In[8], line 3 1 treatment_groups=['D1','D2','D3','D4'] 2 control_groups=['C1','C2','C3','C4'] ----> 3 result=dds.deg_analysis(treatment_groups,control_groups,method='DEseq2', 4 multipletests_method=None)
File ~/miniconda3/envs/omicverse2/lib/python3.10/site-packages/omicverse/bulk/_Deseq2.py:609, in pyDEG.deg_analysis(self, group1, group2, method, alpha, multipletests_method, n_cpus, cooks_filter, independent_filter) 606 dds.calculate_cooks() 607 if dds.refit_cooks: 608 # Replace outlier counts --> 609 dds.refit() 610 stat_res = DeseqStats(dds, alpha=alpha, cooks_filter=cooks_filter, independent_filter=independent_filter) 611 stat_res.run_wald_test()
File ~/miniconda3/envs/omicverse2/lib/python3.10/site-packages/pydeseq2/dds.py:813, in DeseqDataSet.refit(self) 807 """Refit Cook outliers. 808 809 Replace values that are filtered out based on the Cooks distance with imputed 810 values, and then re-run the whole DESeq2 pipeline on replaced values. 811 """ 812 # Replace outlier counts --> 813 self._replace_outliers() 814 if not self.quiet: 815 print( 816 f"Refitting {sum(self.varm['replaced']) } outliers.\n", file=sys.stderr 817 )
File ~/miniconda3/envs/omicverse2/lib/python3.10/site-packages/pydeseq2/dds.py:903, in DeseqDataSet._replace_outliers(self) 894 n_or_more = ( 895 self.obsm["design_matrix"][ 896 self.obsm["design_matrix"].columns[-1] 897 ].value_counts() 898 >= self.min_replicates 899 ) 901 if n_or_more.sum() == 0: 902 # No sample can be replaced. Set self.replaced to False and exit. --> 903 self.varm["replaced"] = pd.Series(False, index=self.var_names) 904 return 906 replaceable = n_or_more[ 907 self.obsm["design_matrix"][self.obsm["design_matrix"].columns[-1]] 908 ]
File ~/miniconda3/envs/omicverse2/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py:216, in AlignedActual.setitem(self, key, value) 215 def setitem(self, key: str, value: Value): --> 216 value = self._validate_value(value, key) 217 self._data[key] = value
File ~/miniconda3/envs/omicverse2/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py:279, in AxisArraysBase._validate_value(self, val, key) 277 msg = "Index.equals and pd.testing.assert_index_equal disagree" 278 raise AssertionError(msg) --> 279 return super()._validate_value(val, key)
File ~/miniconda3/envs/omicverse2/lib/python3.10/site-packages/anndata/_core/aligned_mapping.py:100, in AlignedMappingBase._validate_value(self, val, key) 97 raise ValueError(msg) 99 name = f"{self.attrname.title().rstrip('s')} {key!r}" --> 100 return coerce_array(val, name=name, allow_df=self._allow_df)
File ~/miniconda3/envs/omicverse2/lib/python3.10/site-packages/anndata/_core/storage.py:104, in coerce_array(value, name, allow_df, allow_array_like) 102 if e is not None: 103 msg += " (Failed to convert it to an array, see above for details.)" --> 104 raise ValueError(msg) from e
ValueError: Varm 'replaced' needs to be of one of np.ndarray, numpy.ma.core.MaskedArray, scipy.sparse.spmatrix, awkward.Array, h5py.Dataset, zarr.Array, zappy.base.ZappyArray, anndata.experimental.[CSC,CSR]Dataset, dask.array.Array, cupy.ndarray, or cupyx.scipy.sparse.spmatrix, not <class 'pandas.core.series.Series'>.
omicverse 1.6.7