dynverse / anndata

Annotated multivariate observation data in R
https://anndata.dynverse.org
Other
43 stars 4 forks source link

'dimnames' applied to non-array #15

Closed akhst7 closed 2 years ago

akhst7 commented 2 years ago

This is probably related to the issue-803759711. I imported h5ad just as I normally do;

ann<-read_h5ad("adata.h5ad")

and when I checked X as follows;

ann$X
Error in dimnames(out) <- dimnames(self) : 
  'dimnames' applied to non-array

I guess all the space matrix including the ones in layers (e.g. spliced) is not accessible form R. It was working fine a month ago. It may have some to do with recent updates of h5dy (3.6.0) ?

rcannood commented 2 years ago

Hey akhst7!

I'll take a look at it asap. In the meantime, could you tell me which version of R, Python and anndata (the python kind) you're using?

Robrecht

akhst7 commented 2 years ago

@rcannood , my R, Python, anndata python are as follows;

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] anndata_0.7.5.3    reticulate_1.24    SeuratObject_4.0.4

loaded via a namespace (and not attached):
 [1] compiler_4.1.2   here_1.0.1       assertthat_0.2.1 R6_2.5.1         Matrix_1.4-0     rprojroot_2.0.2  cli_3.2.0       
 [8] tools_4.1.2      Rcpp_1.0.8       grid_4.1.2       jsonlite_1.8.0   rlang_1.0.2      png_0.1-7        lattice_0.20-45 
> py_config()
python:         /opt/homebrew/Caskroom/miniforge/base/envs/velocity/bin/python
libpython:      /opt/homebrew/Caskroom/miniforge/base/envs/velocity/lib/libpython3.10.dylib
pythonhome:     /opt/homebrew/Caskroom/miniforge/base/envs/velocity:/opt/homebrew/Caskroom/miniforge/base/envs/velocity
version:        3.10.2 | packaged by conda-forge | (main, Feb  1 2022, 19:29:01) [Clang 11.1.0 ]
numpy:          /opt/homebrew/Caskroom/miniforge/base/envs/velocity/lib/python3.10/site-packages/numpy
numpy_version:  1.21.5
❯ conda list                                                                                     08:49:48 PM
# packages in environment at /opt/homebrew/Caskroom/miniforge/base/envs/velocity:
#
# Name                    Version                   Build  Channel
anndata                   0.7.8                    pypi_0    pypi

I really appreciate your help !!

rcannood commented 2 years ago

I see -- the problem lies with scipy deprecating classes like scipy.sparse.csc.csc_matrix and renaming them to scipy.sparse._csc.csc_matrix. I feel like this is something that should be solved in the reticulate conversion functions, but I can implement a workaround in anndata for now if need be.

rcannood commented 2 years ago

(If you need something that works now, a temporary workaround could also be downgrading to scipy <1.8.0)

rcannood commented 2 years ago

I created a PR at rstudio/reticulate#1173.

@akhst7 if you want, you could try installing my fork of reticulate to see if this solves your issue: r remotes::install("rcannood/reticulate").

akhst7 commented 2 years ago

@rcannood, thanks for digging this out. So both downgrading scipy (1.7.3) and installing your reticulate commit (with scipy 1.8.0) works. BTW, how did you figure out the culprit was scipy ?

mayingxiang commented 2 years ago

@rcannood Hi! I'm facing the "Error in dimnames(out) <- dimnames(self) : 'dimnames' applied to non-array" issue right now and trying to solve it by "remotes::install_github("rcannood/rstudio")", but don't have permissions to access the repo. I would like to ask for permission to install your reticulate. Thanks!

rcannood commented 2 years ago

@mayingxiang Hi Andy. Oops, I meant to say remotes::install_github("rcannood/reticulate"). I've edited my post in the meantime.

However, the PR has been merged into rstudio/reticulate, so you could also simply install the development version of reticulate: remotes::install_github("rstudio/reticulate").

mayingxiang commented 2 years ago

@rcannood Thank you! It's working now.