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

tutorial_inference_Norman.ipynb is out-of-date #44

Open
jzqin opened this issue Jan 19, 2024 · 5 comments
Open

tutorial_inference_Norman.ipynb is out-of-date #44

jzqin opened this issue Jan 19, 2024 · 5 comments

Comments

@jzqin
Copy link

jzqin commented Jan 19, 2024

When trying to run the tutorial_inference_Norman.ipynb file, loading the pretrained model generates the following error:

TypeError                                 Traceback (most recent call last)
Cell In[111], line 6
      1 gears_model = GEARS(pert_data, 
      2                     device = 'cpu',
      3                     weight_bias_track = False,
      4                     proj_name = 'gears',
      5                     exp_name = 'test')
----> 6 gears_model.load_pretrained('../model/model_ckpt')

File ~/miniconda3/envs/gears/lib/python3.10/site-packages/gears/gears.py:257, in GEARS.load_pretrained(self, path)
    254     config = pickle.load(f)
    256 del config['device'], config['num_genes'], config['num_perts']
--> 257 self.model_initialize(**config)
    258 self.config = config
    260 state_dict = torch.load(os.path.join(path, 'model.pt'), map_location = torch.device('cpu'))

TypeError: GEARS.model_initialize() got an unexpected keyword argument 'cell_fitness_pred'

This is because the model.py file was updated with the commit 8da5e36, which removed the cell_fitness_pred argument, but the model checkpoint provided via
dataverse_download('https://dataverse.harvard.edu/api/access/datafile/6979956', './model.zip') does not use the updated model.

@yhr91
Copy link
Collaborator

yhr91 commented Aug 19, 2024

Sorry for the dealyed response! I've updated the tutorial files and this should now work out of the box.

@yhr91 yhr91 closed this as completed Aug 19, 2024
@KyleFerchen
Copy link

I am still getting this error as of 2024/10/07:

>>> gears_model.load_pretrained('./model_ckpt')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/users/fero3l/env/gears/lib/python3.10/site-packages/gears/gears.py", line 257, in load_pretrained
    self.model_initialize(**config)
TypeError: GEARS.model_initialize() got an unexpected keyword argument 'cell_fitness_pred'

@yhr91 yhr91 reopened this Oct 15, 2024
@ManuelMoradiellos
Copy link

Hi! I want to join in this conversation as well, because I was trying to replicate Fig. 4 and Fig. 5b from the paper as I wanted to create the predictions' metrics heatmap for my own data, and I got the exact same error when loading the Norman pretrained model.

I will try with another dataset but maybe it's something related to the Norman one.
Thanks in advance for the package and help provided~

@jzqin
Copy link
Author

jzqin commented Dec 2, 2024

@ManuelMoradiellos the GEARS_misc package uses a different (older) version of GEARS compared to the main repo. I suggest cloning the GEARS_misc repo and using it by adding the directory to your local path, through something like

sys.path.append('/path/to/GEARS_misc/')
from gears import PertData, GEARS

@ManuelMoradiellos
Copy link

ManuelMoradiellos commented Dec 3, 2024

@jzqin thanks for your comment and for you help!

Even though I was able to install all packages needed to run the GEARS_misc repo, but when I use PertData() with the Norman dataset from the 6979957 I later have some problem initializing the pretrained model obtained form 6979956, there's size mismatch in the information loaded.

Are those the correct link to run the same code or were they updated in some regard?

Bests

Edit: I leave my mistake here, as I just noticed that it was clearly stated in the notebooks/code that in order to replicate the results we first need to train the model and then run the predictions, there's no pretrained model for the GEARS_misc code. Sorry for my näive comment

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

4 participants