error in perturbation with anchor gene

#298
by jialei233 - opened

isp = InSilicoPerturber(perturb_type="delete",
perturb_rank_shift=None,
genes_to_perturb='all',
combos=1,
anchor_gene=['ENSG00000179295'],
model_type="CellClassifier",
num_classes=3,
emb_mode="cell",
cell_emb_style="mean_pool",
filter_data=filter_data_dict,
cell_states_to_model=cell_states_to_model,
state_embs_dict=state_embs_dict,
max_ncells=3000,
emb_layer=0,
forward_batch_size=160,
nproc=12)

I want to perturbate all the gene with the anchor gene, and before this I have checked and the anchor gene is indeed in my dataset. The error occured like this:


AttributeError Traceback (most recent call last)
Cell In[8], line 1
----> 1 isp = InSilicoPerturber(perturb_type="delete",
2 perturb_rank_shift=None,
3 genes_to_perturb='all',
4 combos=1,
5 anchor_gene=['ENSG00000179295'],
6 model_type="CellClassifier",
7 num_classes=3,
8 emb_mode="cell",
9 cell_emb_style="mean_pool",
10 filter_data=filter_data_dict,
11 cell_states_to_model=cell_states_to_model,
12 state_embs_dict=state_embs_dict,
13 max_ncells=3000,
14 emb_layer=0,
15 forward_batch_size=160,
16 nproc=12)

File /mnt/Geneformer/geneformer/in_silico_perturber.py:212, in InSilicoPerturber.init(self, perturb_type, perturb_rank_shift, genes_to_perturb, combos, anchor_gene, model_type, num_classes, emb_mode, cell_emb_style, filter_data, cell_states_to_model, state_embs_dict, max_ncells, cell_inds_to_perturb, emb_layer, forward_batch_size, nproc, token_dictionary_file)
209 self.forward_batch_size = forward_batch_size
210 self.nproc = nproc
--> 212 self.validate_options()
214 # load token dictionary (Ensembl IDs:token)
215 with open(token_dictionary_file, "rb") as f:

File /mnt/Geneformer/geneformer/in_silico_perturber.py:258, in InSilicoPerturber.validate_options(self)
253 logger.error(
254 "In silico inhibition and activation currently under development. "
255 "Current valid options for 'perturb_type': 'delete' or 'overexpress'"
256 )
257 raise
--> 258 if (self.combos > 0) and (self.anchor_token is None):
259 logger.error(
260 "Combination perturbation without anchor gene is currently under development. "
261 "Currently, must provide anchor gene for combination perturbation."
262 )
263 raise

AttributeError: 'InSilicoPerturber' object has no attribute 'anchor_token'

I wonder why the object has no attribute 'anchor_token', and how to slove this?

Thank you for your interest in Geneformer and for bringing this to our attention. We pushed changes to fix this - please pull the updated version and retry. Thank you!

ctheodoris changed discussion status to closed

Sign up or log in to comment