CellAssign keyword error: After Integration

Hello All,

I have done integration using scvi protocol. Total cell count 65,785 from 4 batches.

I would like to Annotate the clusters using CellAssign module.
error message
raise KeyError(KeyError: “Values [‘PLP1’, ‘MOG’, ‘ST18’, ‘MBP’, ‘OLIG1’, ‘ACTN2’, ‘COL18A1’, ‘DHCR24’, ‘LRRC63’,], are not valid obs/ var names or indices.”

I have also looked inside my adata.var these listed genes are present in the adata.var.

type or paste code here
import scvi
import anndata
import scanpy as sc
import numpy as np
import pandas as pd
##read annadata
adata=anndata.read_h5ad("/home/akila/adata_scvi.h5ad")
adata.var_names_make_unique()
adata.obs_names_make_unique()

##read marker gene list
marker_gene_mat = pd.read_csv('/home/Akila/Shell/celltype.csv', index_col=0)

## copy marker gene list to adata object
bdata = adata[:, marker_gene_mat.index].copy()

Hi,

Thanks for using scvi-tools. This sounds like an issue with your AnnData object rather than an scvi-tools issue. Could you show the output of adata.var_names[:5]? Its possible your call to adata.var_names_make_unique() altered the gene names such that your indexing no longer works.

Thanks for your reply.
Here is the screen shot of the adata.var (before/after indexing)

Looks like your var_names are the gene ids (e.g. ENSG00000186827.11) rather than the gene names. To filter the columns by gene names you have to do something like this: adata[:, adata.var["gene_name"] == marker_gene_mat.index].