scverse / scanpy

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

sc.pl.heatmap: KeyError: "Values ['CD79A'], are not valid obs/ var names or indices. #2068

Closed DUAN-GAO closed 2 months ago

DUAN-GAO commented 2 years ago

Hello, after clustering I am trying to use heatmap to visualize the marker gene but got below error: could anyone help, many thanks.

ax = sc.pl.heatmap(adata,marker_genes_dict,groupby='louvain_r1',save="0.png")
KeyError: "Values ['CD79A'], from ['CD79A', 'MS4A1', 'CD3D', 'CD8A', 'CD8B', 'GNLY', 'NKG7', 'CST3', 'LYZ', 'FCGR3A', 'FCER1A'], are not valid obs/ var names or indices."

Versions

anndata 0.7.5 scanpy 1.6.1
hyjforesight commented 2 years ago

I guess you use the HVGs, change use_raw=True

Gloriacyy commented 2 months ago

@hyjforesight I met similar problem, you're right!! thanks a lot. I have filterd hvgs before sc.tl.rank_genes_groups, adata= adata.raw.to_adata(), then pl.heatmap, it worked

flying-sheep commented 2 months ago

yup! genes you filtered out are not available unless you use use_raw