No valid genes for scoring

I’m trying to score a list of genes in my integrated dataset by running the following code:
my_gene = pd.read_csv("/home/unix/marieb/regev_lab_cell_cycle_genes.txt")

len(my_gene)
96

sc.tl.score_genes(adata, gene_list=my_gene, score_name=‘my_score’)

But I get the following error:

ValueError Traceback (most recent call last)
in
----> 1 sc.tl.score_genes(adata, gene_list=my_gene, score_name=‘my_score’)

~/.local/lib/python3.8/site-packages/scanpy/tools/_score_genes.py in score_genes(adata, gene_list, ctrl_size, gene_pool, n_bins, score_name, random_state, copy, use_raw)
112
113 if len(gene_list) == 0:
→ 114 raise ValueError(“No valid genes were passed for scoring.”)
115
116 if gene_pool is None:

ValueError: No valid genes were passed for scoring.

Please help me try to understand why this error comes up

It happens also when I try to set my gene list as something as simple as my_genes = [‘APOD’, ‘OLIG2’], which I know are expressed in my integrated dataset.

Thank you

Hi @marieb,

Are you sure you still have these genes in your integrated dataset? Maybe you performed some HVG selection which removed the genes you are looking for from the data. You can check this by:

import numpy as np

np.any([str(idx) in my_gene for idx in adata.obs_names])

If this returns False, none of the genes in your list arre in adata.obs_names, which is what they are compared with. You can always check against adata.obs_names if a particular gene is in your adata object. Just remember to convert .obs_names to string before you check for matching.