RuntimeError: Sizes of tensors

#90
by Renqing - opened

Hello, when i run the InSilicoPerturber function to do gene perturbation.
code is:
isp = InSilicoPerturber(perturb_type="delete",
perturb_rank_shift=None,
genes_to_perturb=perturb_gene_list,
combos=0,
anchor_gene=None,
model_type="CellClassifier",#Pretrained
num_classes=3,
emb_mode="cell",
cell_emb_style="mean_pool",
filter_data={"cell_type":["Cardiomyocyte1","Cardiomyocyte2","Cardiomyocyte3"]},
cell_states_to_model={"disease":(["nf"],["hcm"],["dcm"])},
max_ncells=None,
emb_layer=0,
forward_batch_size=4,
nproc=16,
save_raw_data=False)
isp.perturb_data("/cell_disease/230627_geneformer_CellClassifier_L2048_B4_LR5e-05_LSlinear_WU500_E10_Oadamw_F0/",
dataset,
"/cell_classification/test_silico_all/",
out_f)

ERROR is:
File ~/anaconda3/envs/shiny_py38/lib/python3.8/site-packages/geneformer/in_silico_perturber.py:262, in quant_cos_sims(model, perturb_type, perturbation_batch, forward_batch_size, layer_to_quant, original_emb, indices_to_perturb, cell_states_to_model, state_embs_dict)
260 else:
261 for state in possible_states:
--> 262 cos_sims_vs_alt_dict[state] = torch.cat(cos_sims_vs_alt_dict[state])
263 return cos_sims_vs_alt_dict

RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 1 but got size 2047 for tensor number 76 in the list.

My dataset:

image.png

Progress bar when reporting an error:

image.png

I clone repository today, and the same problem occurs when the progress bar reaches the one shown above.

image.png

image.png

The perturbed genes [perturb_gene_list ] I used came from the list of 728 unique genes provided in part In silico treatment analysis of your article.

image.png

image.png

When I set the genes_to_perturb parameter to all instead of the provided gene list no error is reported so far, the current progress bar is as follows:

image.png

So what is the cause of this? If it is convenient I can email you the input data of my error report to help find the cause.

Input gene list code:

image.png

image.png

The latest information
The same error is reported when the genes_to_perturb parameter is set to all

(closing due to duplicate discussion)

ctheodoris changed discussion status to closed

Sign up or log in to comment