Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: SPECTRA_Model.train() got an unexpected keyword argument 'label_factors' #30

Open
bitcometz opened this issue Sep 27, 2023 · 1 comment

Comments

@bitcometz
Copy link

hello, thanks for this great tool !!!
I run this tool with CPU successefully but failed with GPU:

#import packages
import numpy as np
import json
import scanpy as sc
from collections import OrderedDict
import scipy
import pandas as pd
import matplotlib.pyplot as plt

#spectra imports
import Spectra as spc
from Spectra import Spectra_util as spc_tl
from Spectra import K_est as kst
from Spectra import default_gene_sets

## GPU
from Spectra import Spectra_gpu as spc_gpu

#filter gene set annotation dict for genes contained in adata
my_annotations = spc_tl.check_gene_set_dictionary(
    adata,
    my_annotations,
    obs_key='Disease subtype2',
    global_key='global')

# fit the model (We will run this with only 2 epochs to decrease runtime in this tutorial)
model = spc_gpu.est_spectra(adata=adata,
    gene_set_dictionary=my_annotations,
    use_highly_variable=True,
    cell_type_key="Disease subtype2",
    use_weights=True,
    lam=0.1, # varies depending on data and gene sets, try between 0.5 and 0.001
    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=500 #here running only 2 epochs for time reasons, we recommend 10,000 epochs for most datasets
)

and the running log:

CUDA Available:  True
Initializing model...
Building parameter set...
CUDA memory:  1.788089856
Beginning training...
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-13-232fdfc3e7ab>](https://localhost:8080/#) in <cell line: 2>()
      1 # fit the model (We will run this with only 2 epochs to decrease runtime in this tutorial)
----> 2 model = spc_gpu.est_spectra(adata=adata,
      3     gene_set_dictionary=my_annotations,
      4     use_highly_variable=True,
      5     cell_type_key="Disease subtype2",

[/usr/local/lib/python3.10/dist-packages/Spectra/Spectra_gpu.py](https://localhost:8080/#) 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)
    886     spectra.initialize(gene_set_dictionary, word2id, X, init_scores)
    887     print("Beginning training...")
--> 888     spectra.train(X = X, labels = labels,**kwargs)
    889 
    890     adata.uns["SPECTRA_factors"] = spectra.factors

TypeError: SPECTRA_Model.train() got an unexpected keyword argument 'label_factors'

Could you help with this problem ? Thanks !!!

@bitcometz
Copy link
Author

bitcometz commented Sep 27, 2023

Besides, after I remove those parameters not in the spc_gpu, I got the results.
However, there are no adata.uns['SPECTRA_overlap'],
So I do not konw the exact meanings of the index for adata.obsm['SPECTRA_cell_scores'], I do not where to find the info of index:
0-X-global-X-all_pyrimidine_synthesis
...
...

and there are some stragen results from CPU:
image

Thanks !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant