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 #91

Open GGboy-Zzz opened 8 months ago

GGboy-Zzz commented 8 months ago

I have been trying to merge multiple single cell data using scgen recently, but when I tried to run the tutorial, an error occurred,as follows,

TypeError Traceback (most recent call last)

in 1 scgen.SCGEN.setup_anndata(train, batch_key="batch", labels_key="cell_type") ----> 2 model = scgen.SCGEN(train) 3 model.save("/home/zhuyong/test_scgen/saved_models/model_batch_removal.pt", overwrite=True) TypeError: Can't instantiate abstract class SCGEN with abstract methods setup_anndata I referred to issue #53 #54 etc and confirmed that my scvi-tools version is 0.14.0. I even reinstalled version 0.13.0, but it still doesn't work. Do you have any good suggestions? @adamgayoso @M0hammadL
Tigerrr07 commented 7 months ago

Hello, I encountered the same issue as you. I was able to solve it by following these steps:

  1. Install scgen from the repo using the following commands:
    conda create -n scgen-dev python=3.8 -y
    pip install torch==1.12.0+cu102 torchvision==0.13.0+cu102 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu102  # a given version of pytorch, here I use torch1.12.0+cu102
    pip install git+https://github.com/theislab/scgen.git  # or git clone the repo and run pip install .
  2. Modify train_new in the python code as follows::
    train_new = train[~((train.obs["cell_type"] == "CD4T") &
                    (train.obs["condition"] == "stimulated"))].copy()

    This solution worked for me and the tutorial. I hope it is helpful for you too!