BayraktarLab / cell2location

Comprehensive mapping of tissue cell architecture via integrated single cell and spatial transcriptomics (cell2location model)
https://cell2location.readthedocs.io/en/latest/
Apache License 2.0
318 stars 58 forks source link

Using scATAC-seq dataset to deconvolute 10x Visium dataset #374

Open Jadeapple opened 4 months ago

Jadeapple commented 4 months ago

Hello, I want to use scATAC-seq dataset to deconvolute 10x Visium dataset, is it feasible?

When I prepare anndata for the regression model, some warings appeared as follows: cell2location.models.RegressionModel.setup_anndata(adata=adata_sc, ... batch_key='orig.ident', # 10X reaction / sample / batch ... labels_key='celltype' # cell type, covariate used for constructing signatures ... )

:119: FutureWarning: SparseDataset is deprecated and will be removed in late 2024. It has been replaced by the public classes CSRDataset and CSCDataset. For instance checks, use `isinstance(X, (anndata.experimental.CSRDataset, anndata.experimental.CSCDataset))` instead. For creation, use `anndata.experimental.sparse_dataset(X)` instead. An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu. What should I do?
royassis commented 1 month ago

Hey

I found an example in the anndata.experimental.sparse_dataset docstring.

Here is my example code:


import anndata
import h5py
from anndata.experimental import sparse_dataset, read_elem

with h5py.File("somefile.h5ad", "r") as f:
    X = sparse_dataset(f["X"])
    adata = anndata.AnnData(
       layers={"backed": X}, obs=read_elem(f["obs"]), var=read_elem(f["var"])
    )
    print(adata.layers["backed"])
royassis commented 1 month ago

Writing this anndata object to a new file does not keep the X dataset in the new format.