dpeerlab / spectra

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

train() got an unexpected keyword argument 'label_factors' #22

Closed ccruizm closed 1 year ago

ccruizm commented 1 year ago

Hi there,

When using spc.est_spectra, I am getting the error train() got an unexpected keyword argument 'label_factors'. I installed it from GitHub recently and can see that labels_fatcors is part of spectra.py., I am trying to understand why I am getting this error.

Any insights you can provide will be helpful! Thanks!

ccruizm commented 1 year ago

I commented the label_factors line, and now the next argument also says that it is not part of the function

model = spc.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 = 0.00001, rho = 0.00001, 
                        use_cell_types = True, n_top_vals = 25, 
                        # label_factors = True, #whether to label the factors by their overlap coefficient with the input gene sets
                        overlap_threshold = 0.2, #minimum overlap coefficient that has to be surpassed to assign a label to a factor
                        num_epochs=200 #for demonstration purposes we will only run 2 epochs, we recommend 10,000 epochs
                       )

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[20], line 2
      1 #fit the model (We will run this with only 2 epochs to decrease runtime in this tutorial)
----> 2 model = spc.est_spectra(adata = adata, gene_set_dictionary = annotations, 
      3                         use_highly_variable = True, cell_type_key = "cell_type_annotations", 
      4                         use_weights = True, lam = 0.1, 
      5                         delta=0.001,kappa = 0.00001, rho = 0.00001, 
      6                         use_cell_types = True, n_top_vals = 25, 
      7                         # label_factors = True, #whether to label the factors by their overlap coefficient with the input gene sets
      8                         overlap_threshold = 0.2, #minimum overlap coefficient that has to be surpassed to assign a label to a factor
      9                         num_epochs=200 #for demonstration purposes we will only run 2 epochs, we recommend 10,000 epochs
     10                        )

File /hpc/pmc_stunnenberg/cruiz/miniconda3/envs/spectra/lib/python3.9/site-packages/spectra/spectra.py:1223, in est_spectra(adata, gene_set_dictionary, L, use_highly_variable, cell_type_key, use_weights, lam, delta, kappa, rho, use_cell_types, n_top_vals, filter_sets, **kwargs)
   1219 spectra = SPECTRA_Model(X = X, labels = labels,  L = L, vocab = vocab, gs_dict = gene_set_dictionary, use_weights = use_weights, lam = lam, delta=delta,kappa = kappa, rho = rho, use_cell_types = use_cell_types)
   1221 spectra.initialize(gene_set_dictionary, word2id, X, init_scores)
-> 1223 spectra.train(X = X, labels = labels,**kwargs)
   1225 adata.uns["SPECTRA_factors"] = spectra.factors
   1226 adata.obsm["SPECTRA_cell_scores"] = spectra.cell_scores

TypeError: train() got an unexpected keyword argument 'overlap_threshold'
ccruizm commented 1 year ago

I do not know where the problem is, I used another HPC and made a new installation and there it works. Since it is not reproducible I am closing this.