Please help with :IndexError: tuple index out of range for cell_states_to_model

#119
by jinbo1129 - opened

hello, thanks for this great tool and your quick response !!!
I try to do the in_silico_perturbation with my own dataset, where are only two cellstates: normal and healthy, so I edit the code to:

# the embedding towards non-failing (nf) state
isp = InSilicoPerturber(perturb_type="delete",
                        perturb_rank_shift=None,
                        genes_to_perturb="all",
                        combos=0,
                        anchor_gene=None,
                        model_type="CellClassifier",
                        num_classes=2,      ## change according to my own data !!!
                        emb_mode="cell",
                        cell_emb_style="mean_pool",
                        cell_states_to_model={"disease":(["Normal"],["Disease"])},
                        max_ncells=2000,
                        emb_layer=0,
                        forward_batch_size=400,
                        nproc=16)

Than I met with the errors:

IndexError                                Traceback (most recent call last)
    551     # get dictionary of average cell state embeddings for comparison
--> 552     state_embs_dict = get_cell_state_avg_embs(model,
    553                                               filtered_input_data,
    554                                               self.cell_states_to_model,
    555                                               layer_to_quant,
    556                                               self.gene_token_dict,
    557                                               self.forward_batch_size,
    558                                               self.nproc)
    559 self.in_silico_perturb(model,
    560                       filtered_input_data,
    561                       layer_to_quant,
    562                       state_embs_dict,
    563                       output_directory,
    564                       output_prefix)

--> 163     possible_states = [value[0]+value[1]+value[2] for value in cell_states_to_model.values()][0]
    164     state_embs_dict = dict()
    165     for possible_state in possible_states:

IndexError: tuple index out of range

Should I change the codes of "in_silico_perturber.py" according to my own dataset ?

Thanks !!!

    cell_states_to_model: None, dict
        Cell states to model if testing perturbations that achieve goal state change.
        Single-item dictionary with key being cell attribute (e.g. "disease").
        Value is tuple of three lists indicating start state, goal end state, and alternate possible end states.
        If no alternate possible end states, third list should be empty (i.e. the third list should be []).
jinbo1129 changed discussion status to closed

Sign up or log in to comment