anndata icon indicating copy to clipboard operation
anndata copied to clipboard

UMAP of gene subset of adata

Open malonzm1 opened this issue 9 months ago • 3 comments

Please make sure these conditions are met

  • [X] I have checked that this issue has not already been reported.
  • [X] I have confirmed this bug exists on the latest version of anndata.
  • [ ] (optional) I have confirmed this bug exists on the master branch of anndata.

Report

I'm able to get a subset of adata using a gene list but when I run sc.tl.pca I get ValueError: Output dtype not compatible with inputs.

Code:

adata0 = adata[:, gene_list]
sc.tl.pca(adata0)

Traceback:

File /PUHTI_TYKKY_Cq2gHLh/miniconda/envs/env1/lib/python3.9/site-packages/anndata/_core/anndata.py:683, in AnnData.X(self)
    680     X = None
    681 elif self.is_view:
    682     X = as_view(
--> 683         _subset(self._adata_ref.X, (self._oidx, self._vidx)),
    684         ElementRef(self, "X"),
    685     )
    686 else:
    687     X = self._X

File /PUHTI_TYKKY_Cq2gHLh/miniconda/envs/env1/lib/python3.9/functools.py:888, in singledispatch.<locals>.wrapper(*args, **kw)
    884 if not args:
    885     raise TypeError(f'{funcname} requires at least '
    886                     '1 positional argument')
--> 888 return dispatch(args[0].__class__)(*args, **kw)

File /PUHTI_TYKKY_Cq2gHLh/miniconda/envs/env1/lib/python3.9/site-packages/anndata/_core/index.py:168, in _subset_spmatrix(a, subset_idx)
    166 if len(subset_idx) > 1 and all(isinstance(x, cabc.Iterable) for x in subset_idx):
    167     subset_idx = (subset_idx[0].reshape(-1, 1), *subset_idx[1:])
--> 168 return a[subset_idx]

File /PUHTI_TYKKY_Cq2gHLh/miniconda/envs/env1/lib/python3.9/site-packages/scipy/sparse/_index.py:70, in IndexMixin.__getitem__(self, key)
     68         return self._get_sliceXslice(row, col)
     69     elif col.ndim == 1:
---> 70         return self._get_sliceXarray(row, col)
     71     raise IndexError('index results in >2 dimensions')
     72 elif row.ndim == 1:

File /PUHTI_TYKKY_Cq2gHLh/miniconda/envs/env1/lib/python3.9/site-packages/scipy/sparse/_csr.py:207, in _csr_base._get_sliceXarray(self, row, col)
    206 def _get_sliceXarray(self, row, col):
--> 207     return self._major_slice(row)._minor_index_fancy(col)

File /PUHTI_TYKKY_Cq2gHLh/miniconda/envs/env1/lib/python3.9/site-packages/scipy/sparse/_compressed.py:774, in _cs_matrix._minor_index_fancy(self, idx)
    772 col_offsets = np.zeros(N, dtype=idx_dtype)
    773 res_indptr = np.empty_like(self.indptr)
--> 774 csr_column_index1(k, idx, M, N, self.indptr, self.indices,
    775                   col_offsets, res_indptr)
    777 # pass 2: copy indices/data for selected idxs
    778 col_order = np.argsort(idx).astype(idx_dtype, copy=False)

ValueError: Output dtype not compatible with inputs.

Please advise.

Versions

igraph              0.11.3
importlib_resources NA
jedi                0.19.1
joblib              1.3.2
kiwisolver          1.4.5
leidenalg           0.10.2
llvmlite            0.41.1
matplotlib          3.8.2
mpl_toolkits        NA
mpmath              1.3.0
natsort             8.4.0
numba               0.58.1
numpy               1.26.3
packaging           23.2
parso               0.8.3
pexpect             4.9.0
pickleshare         0.7.5
prompt_toolkit      3.0.42
psutil              5.9.8
ptyprocess          0.7.0
pure_eval           0.2.2
pygments            2.17.2
pyparsing           3.1.1
pytz                2023.4
six                 1.16.0
sklearn             1.4.0
stack_data          0.6.2
sympy               1.12
texttable           1.7.0
threadpoolctl       3.2.0
torch               2.1.2.post101
torchgen            NA
tqdm                4.66.1
traitlets           5.14.1
typing_extensions   NA
wcwidth             0.2.13
yaml                6.0.1
zipp                NA
zoneinfo            NA
-----
Python 3.9.18 | packaged by conda-forge | (main, Dec 23 2023, 16:33:10) [GCC 12.3.0]
Linux-4.18.0-372.96.1.el8_6.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2024-05-04 09:47

malonzm1 avatar May 04 '24 06:05 malonzm1