dpeerlab / spectra

Supervised Pathway DEConvolution of InTerpretable Gene ProgRAms
MIT License
134 stars 17 forks source link

issue with self.rho = nn.ParameterDict(self.rho) #31

Open deanslee opened 9 months ago

deanslee commented 9 months ago

Hi all, I was running through the code below in the provided tutorial and came across an error.

model = Spectra.est_spectra(adata=adata, gene_set_dictionary=annotations, use_highly_variable=True, cell_type_key="cell_type_annotations", use_weights=True, lam=0.1, delta=0.001, kappa=None, rho=0.001, use_cell_types=True, n_top_vals=50, label_factors=True, overlap_threshold=0.2, clean_gs=True, min_gs_num=3, num_epochs=2)

Screenshot 2023-10-20 at 10 58 46 PM Screenshot 2023-10-20 at 10 59 07 PM

When rho=None, est_spectra runs just fine. The same error with rho=0.001 also happens with kappa=0.001.

deanslee commented 9 months ago

I might be wrong, but my current understanding is that the issue with nn.ParameterDict(self.rho) is that self.rho needs to be two dimensions.

This is my attempt to reproduce the error:

Screenshot 2023-10-20 at 11 07 09 PM

Then running self_rho = nn.ParameterDict(self_rho) reproduces

TypeError: cannot assign 'torch.DoubleTensor' object to parameter 'B_GC' (torch.nn.Parameter or None required)

deanslee commented 9 months ago

Could this issue be a result of this commit?