scverse / anndata

Annotated data.
http://anndata.readthedocs.io
BSD 3-Clause "New" or "Revised" License
577 stars 153 forks source link

Issues subsetting AnnData object with reticulate #802

Open imerelli opened 2 years ago

imerelli commented 2 years ago

Hi, I'm using reticulate to perform the scanpy tutorial for single cell data analysis.

R

library(reticulate) reticulate::repl_python()

mkdir data

wget http://cf.10xgenomics.com/samples/cell-exp/1.1.0/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz -O data/pbmc3k_filtered_gene_bc_matrices.tar.gz

cd data; tar -xzf pbmc3k_filtered_gene_bc_matrices.tar.gz

python

import scanpy as sc adata = sc.read_10x_mtx('data/filtered_gene_bc_matrices/hg19/') sc.pp.calculate_qc_metrics(adata, percent_top=None, log1p=False, inplace=True) adata=adata[adata.obs.n_genes_by_counts < 2500, :]

Error in py_call_impl(callable, dots$args, dots$keywords) : AttributeError: 'AnnData' object has no attribute '_X'

This python code works in a jupyter notebook. scanpy==1.9.1, reticulate==1.25 It seems that subsetting an AnnData object using reticulate generates some internal errors. Have you any suggestion to solve this?

ivirshup commented 2 years ago

Can you provide us with more info about your reticulate environment? Like the version of anndata?

imerelli commented 2 years ago

>>> import session_info

>>> session_info.show()

anndata 0.8.0 scanpy 1.9.1 session_info 1.0.0

Python 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:51:59) [GCC 10.3.0] Linux-3.10.0-1160.62.1.el7.x86_64-x86_64-with-glibc2.17

Session information updated at 2022-09-07 05:07

imerelli commented 2 years ago

Any news about this?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. Please add a comment if you want to keep the issue open. Thank you for your contributions!

ivirshup commented 1 year ago

This seems like it's tied to reticulate, and we don't have the bandwidth to have "support for anndata via reticulate" as a tested use case.

I've seen this error come up before, so I believe there is something going on.

Someone else figuring out what's going on and making a PR (probably to reticulate?) would be appreciated.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. Please add a comment if you want to keep the issue open. Thank you for your contributions!