theislab / scgen

Single cell perturbation prediction
https://scgen.readthedocs.io
GNU General Public License v3.0
255 stars 51 forks source link

TypeError: Can't instantiate abstract class SCGEN with abstract methods setup_anndata #53

Closed BrianLlll closed 2 years ago

BrianLlll commented 2 years ago

Hi, Thanks for your excellent contribution. I recently encountered a bug when I ran " scgen.SCGEN(train)". The error information is:

TypeError Traceback (most recent call last)

in () ----> 1 model = scgen.SCGEN(train) 2 model.save("../model_batch_removal.pt", overwrite=True) TypeError: Can't instantiate abstract class SCGEN with abstract methods setup_anndata However, this code works well one week ago with the same data. Could you pls help me with this issue? Thank you. Brian
adamgayoso commented 2 years ago

@Cottoneyejoe95 , to fix this just need to copy setup_anndata as inside here:

https://github.com/YosefLab/scvi-tools/blob/11ef44a043cca303a83413422bbebd4a1963bc0f/scvi/model/_scvi.py#L129-L141

And then remove the global one that is imported here:

https://github.com/theislab/scgen/blob/ae4af373082b933ddf7c4733e38bbdfe656b2595/scgen/__init__.py#L3

and on this page:

https://github.com/theislab/scgen/blob/master/docs/api/index.rst

SoloveyMaria commented 2 years ago

Dear @adamgayoso, I am having the same issue as Brian. Following your suggestion, I copied the function code from the https://github.com/YosefLab/scvi-tools/blob/11ef44a043cca303a83413422bbebd4a1963bc0f/scvi/model/_scvi.py#L129-L141 beginning from the line 129 down to the line165 to my jypter notebook, but received this error File "/tmp/ipykernel_42033/933877342.py", line 2 @setup_anndata_dsp.dedent ^ IndentationError: unexpected indent Would you be so kind as to give a more detailed instruction on how to exactly fix the issue?

BrianLlll commented 2 years ago

Hi @adamgayoso, I also followed your suggestion to copy the setup_anndata function and use this function to register the object. However, I still had the same issue when I ran "scgen.SCGEN(train)" with the same error information as before. Could you pls kindly provide some more help on this issue? Thank you.

adamgayoso commented 2 years ago

@SoloveyMaria @BrianLlll the solution I proposed is for developers of this package. For users, you just need to downgrade scvi-tools, using pip3 install --upgrade scvi-tools==0.13.0. This will temporarily fix your issue until the devs fix the package

BrianLlll commented 2 years ago

@adamgayoso It works finally!

M0hammadL commented 2 years ago

thanks, @adamgayoso for the tip, I added 0.13.0 version now as a requirement for temporary fixing and will update it later.

adamgayoso commented 2 years ago

@M0hammadL someone from our team will make a PR to fix

adamgayoso commented 2 years ago

reopening