Open dertrotl opened 1 month ago
Hi @dertrotl,
This looks like a versioning issue or perhaps a format issue with the input matrix. Can you double check if your .X matrix is a csr_matrix or alternatively numpy array?
Also, providing some info on your session could help.
Daniel
Hi @dbdimitrov,
thank you for your response.
I checked the format of the input matrix,
type(adata.X)
scipy.sparse._csr.csr_matrix
Tried converting it like this adata.X = adata.X.toarray()
, which resolved into the same error.
Some session information:
scipy version: 1.13.1
anndata version: 0.10.9
scanpy version: 1.10.3
numpy version: 1.26.4
liana version: 1.4.0
pandas version: 2.2.2
decoupler version: 1.8.0
python version: 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
Thanks!
Seems to work if one is trying not add the results to the adata object, e.g. setting inplace=False
:
tt = li.mt.bivariate(adata,
resource_name='consensus', # NOTE: uses HUMAN gene symbols!
local_name='morans', # Name of the function
global_name="morans", # Name global function
n_perms=100, # Number of permutations to calculate a p-value
mask_negatives=False, # Whether to mask LowLow/NegativeNegative interactions
add_categories=True, # Whether to add local categories to the results
nz_prop=0.2, # Minimum expr. proportion for ligands/receptors and their subunits
use_raw=False,
verbose=True,
inplace = False
)
Output tt
is saved as tuple with tt[0]
containing data frame and tt[1]
an adata object.
Hi @dertrotl,
Thanks a lot for raising this issue. I encountered it also myself, it seems like AnnData now enforces specific types in obsm, and one can no longer assign an AnnData object there. I will change it in next update.
Best wishes, Daniel
PS. tbh, I couldn't think of an elegant way to fix this such that one can save in place. Commonly, people would store a matrix in obsm, and then auxiliary information in uns, etc. I personally don't like that, rebuilding an AnnData object from this scattered data would be a pain. So, I will instead just drop the inplace parameter and would always return an AnnData with all the information in it - i.e. the one that is currently stored in obsm.
If anyone has a better idea let me know :)
Hey, first of all, thanks a lot for this great package!
However, I had some issues following your Bivariate Ligand-Receptor Relationships tutorial. When running the following code from your tutorial:
I get the following error:
Obsm 'local_scores' 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 'anndata._core.anndata.AnnData'>. ( see screeshot)
Thank you for your help!