The disturbed task reported an error
Thank you for your good work and your patience in answering earlier questions. I'm currently running the Gene perturbation mission and reporting an error at the last step. May I ask you how to solve this problem? Thank you!
The code is as follows:
cell_states_to_model={"state_key": "disease",
"start_state": "dcm",
"goal_state": "nf",
"alt_states": ["hcm"]}
isp = InSilicoPerturber(perturb_type="delete",
perturb_rank_shift=None,
genes_to_perturb="all",
combos=0,
anchor_gene=None,
model_type="CellClassifier",
num_classes=3,
emb_mode="cell",
cell_emb_style="mean_pool",
cell_states_to_model=cell_states_to_model,
filter_data={"cell_type":["Cardiomyocyte1","Cardiomyocyte2","Cardiomyocyte3"]},
cell_states_to_model={'state_key': 'disease',
'start_state': 'dcm',
'goal_state': 'nf',
'alt_states': ['hcm']},
max_ncells=30,
emb_layer=0,
forward_batch_size=30,
nproc=8)
isp.perturb_data("/root/Geneformer/geneformer-12L-30M/",
"/root/Geneformer/examples/human_dcm_hcm_nf_small1.dataset/",
"/root/Geneformer/examples/new/",
"a")
ispstats = InSilicoPerturberStats(mode="goal_state_shift",
genes_perturbed="all",
combos=0,
anchor_gene=None,
cell_states_to_model=cell_states_to_model
)
ispstats.get_stats("/root/Geneformer/examples/new/",
None,
"/root/Geneformer/examples/new",
"a")
The error content is as follows:
Traceback (most recent call last):
File "", line 1, in
The File "/ root/miniconda3 / envs/myenv/lib/python3.10 / site - packages/geneformer/in_silico_perturber_stats. Py", line 694, in get_stats
cos_sims_df = isp_stats_to_goal_state(cos_sims_df_initial, dict_list, self.cell_states_to_model, self.genes_perturbed)
The File "/ root/miniconda3 / envs/myenv/lib/python3.10 / site - packages/geneformer/in_silico_perturber_stats. Py", line 170, in isp_stats_to_goal_state
goal_end_random_megalist = [goal_end for start_state,goal_end,alt_end in random_tuples]
The File "/ root/miniconda3 / envs/myenv/lib/python3.10 / site - packages/geneformer/in_silico_perturber_stats. Py", line 170, in
goal_end_random_megalist = [goal_end for start_state,goal_end,alt_end in random_tuples]
TypeError: cannot unpack non-iterable float object
Thank you for your question. There are a few issues in your code that may be helpful to address.
- it appears you are using the pretrained 12L-30M model, but you are loading it as a CellClassifier with 3 classes, so it is adding a random weights classification head on top that will randomize your embeddings given you are extracting them from the last layer (emb_layer=0).
- If you use the 30M model, you provide the appropriate token dictionary to the function as the default is using the 95M dictionary.
- The error you are getting could possibly because I don't see you having provided a state_embs_dict, which is necessary for the cell_states_to_model mode.