scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.89k stars 595 forks source link

ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual. self.data[key] = value #2428

Open navi889 opened 1 year ago

navi889 commented 1 year ago
#remove all ribosomal genes
malat1 = adata1.var_names.str.startswith('MALAT1')
ribo_genes = adata1.var_names.str.startswith(("RPS","RPL"))
# we need to redefine the mito_genes since they were first 
# calculated on the full object before removing low expressed genes.
mito_genes = adata1.var_names.str.startswith('MT-')
hb_genes = adata1.var_names.str.contains('^HB[^(P)]')

remove = np.add(mito_genes, malat1)
remove = np.add(remove, hb_genes)
keep = np.invert(remove)

adata3 = adata1[:,keep]

adata3

Versions

anndata 0.8.0 scanpy 1.7.2

I am getting this error "ImplicitModificationWarning: Trying to modify attribute ._uns of view, initializing view as actual. self.data[key] = value " as soon as i write the above code(subset data based on genes i need) and then the kernel crashes because of memory issues

zys-BIG commented 1 year ago

same issue, any ideas?