Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError in score_genes_for_marginals Despite Matching Genes in Gene List #771

Open
pooji-96 opened this issue Dec 13, 2024 · 5 comments
Assignees

Comments

@pooji-96
Copy link

Hello,

I am encountering a ValueError when running the score_genes_for_marginals function, despite the fact that the genes in my list match several valid genes in the dataset. When I check the gene list, the genes do match those present in adata.var_names.

stp = stp.score_genes_for_marginals(gene_set_proliferation = "mouse", gene_set_apoptosis = "mouse")

WARNING: genes are not in var_names and ignored: Index(['Anln', 'Anp32e', 'Atad2', 'Aurka', 'Aurkb', 'Birc5', 'Blm', 'Brip1',
'Bub1', 'Casp8ap2', 'Cbx5', 'Ccnb2', 'Ccne2', 'Cdc20', 'Cdc25c',
'Cdc45', 'Cdc6', 'Cdca2', 'Cdca3', 'Cdca7', 'Cdca8', 'Cdk1', 'Cenpa',
'Cenpe', 'Cenpf', 'Chaf1b', 'Ckap2', 'Ckap2l', 'Ckap5', 'Cks1b', 'Cks2',
'Clspn', 'Ctcf', 'Dlgap5', 'Dscc1', 'Dtl', 'E2f8', 'Ect2', 'Exo1',
'Fam64a', 'Fen1', 'G2e3', 'Gas2l3', 'Gins2', 'Gmnn', 'Gtse1', 'Hells',
'Hjurp', 'Hmgb2', 'Hmmr', 'Hn1', 'Kif11', 'Kif20b', 'Kif23', 'Kif2c',
'Lbr', 'Mcm2', 'Mcm4', 'Mcm5', 'Mcm6', 'Mki67', 'Mlf1ip', 'Msh2',
'Nasp', 'Ncapd2', 'Ndc80', 'Nek2', 'Nuf2', 'Nusap1', 'Pcna', 'Pola1',
'Pold3', 'Prim1', 'Psrc1', 'Rad51', 'Rad51ap1', 'Rangap1', 'Rfc2',
'Rpa2', 'Rrm1', 'Rrm2', 'Slbp', 'Smc4', 'Tacc3', 'Tipin', 'Tmpo',
'Top2a', 'Tpx2', 'Ttk', 'Tubb4b', 'Tyms', 'Ube2c', 'Ubr7', 'Uhrf1',
'Ung', 'Usp1', 'Wdr76'],
dtype='object')


ValueError Traceback (most recent call last)
Cell In[16], line 1
----> 1 stp = stp.score_genes_for_marginals(gene_set_proliferation = "mouse", gene_set_apoptosis = "mouse")

File ~/.local/lib/python3.11/site-packages/moscot/base/problems/birth_death.py:108, in BirthDeathMixin.score_genes_for_marginals(self, gene_set_proliferation, gene_set_apoptosis, proliferation_key, apoptosis_key, **kwargs)
106 gene_set_proliferation = proliferation_markers(gene_set_proliferation) # type: ignore[arg-type]
107 if gene_set_proliferation is not None:
--> 108 sc.tl.score_genes(self.adata, gene_set_proliferation, score_name=proliferation_key, **kwargs)
109 self.proliferation_key = proliferation_key
110 else:

File ~/.local/lib/python3.11/site-packages/legacy_api_wrap/init.py:80, in legacy_api..wrapper..fn_compatible(*args_all, **kw)
77 @wraps(fn)
78 def fn_compatible(*args_all: P.args, **kw: P.kwargs) -> R:
79 if len(args_all) <= n_positional:
---> 80 return fn(*args_all, **kw)
82 args_pos: P.args
83 args_pos, args_rest = args_all[:n_positional], args_all[n_positional:]

File ~/.local/lib/python3.11/site-packages/scanpy/tools/_score_genes.py:134, in score_genes(adata, gene_list, ctrl_size, gene_pool, n_bins, score_name, random_state, copy, use_raw)
132 logg.warning(f"genes are not in var_names and ignored: {genes_to_ignore}")
133 if len(gene_list) == 0:
--> 134 raise ValueError("No valid genes were passed for scoring.")
136 if gene_pool is None:
137 gene_pool = pd.Index(var_names, dtype="string")

ValueError: No valid genes were passed for scoring.

I would appreciate any guidance on why this might be happening.

@MUCDK
Copy link
Collaborator

MUCDK commented Dec 17, 2024

Hi @pooji-96 ,

We will look into this!
Would you mind posting a small reproducible example?

@selmanozleyen
Copy link
Collaborator

Yes @pooji-96 also any details regarding your version would be super helpful. Can you also print your var_names so we can compare?

@pooji-96
Copy link
Author

Hello @MUCDK and @selmanozleyen,

Thank you both for your responses! I have attached the code file for your reference, which outlines the steps I have followed using Moscot on the dataset I am working with.
I have also attached a file containing the list of var_names from the dataset for comparison.
Additionally, I am using Moscot version 0.3.5 in the code. Let me know if you need any other details.
Looking forward to your feedback!
adata.var_names.txt
adata1.var_names.txt
Code.txt

@LeonStadelmann
Copy link
Collaborator

Hey @pooji-96 , thanks for providing your code!
Have you tried setting use_raw=False, so using stp = stp.score_genes_for_marginals(gene_set_proliferation = "mouse", gene_set_apoptosis = "mouse", use_raw=False) instead? Just to rule out any issues with the anndata object similiar to this one: scverse/scanpy#3266.

@pooji-96
Copy link
Author

Hello @LeonStadelmann ,
I haven't tried that yet, but I'll run it and see if it helps. Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants