Failing to import SCVI-tools modules: has AnnDatasetFromAnnData been replaced?

Hello! I am attempting to learn how to use totalVI to analyze big CITE seq datasets after reading This paper regarding thymic development. There was an abundance of code provided, and I had hoped to work through it to reanalyze.

Unfortunately, I think either I’m failing to import/install scvi-tools properly, or the packages/commands used might have changed. Notably, running the following seems to cause an error:

import scvi
from scvi.dataset import GeneExpressionDataset, CellMeasurement, AnnDatasetFromAnnData, Dataset10X
from scvi.models import VAE, TOTALVI
from scvi.inference import TotalPosterior, TotalTrainer, Posterior, UnsupervisedTrainer

induces ModuleNotFound errors, where “scvi.models”, “scvi.inference”, and “scvi.dataset” do not exist.

I only find these mentioned in older tutorials- is the code I’m attempting to replicate just very old?

I later hoped to run the following to concatenate two samples, after filtering and processing the data somewhat:


# Berkeley data
dataset_totalVI_Berkeley = AnnDatasetFromAnnData(ad = dataset_Berkeley[:, hvg_Berkeley],
                                                cell_measurements_col_mappings = {"protein_expression":"protein_names"})
dataset_totalVI_Berkeley


# BioLegend data
dataset_totalVI_BioLegend = AnnDatasetFromAnnData(ad = dataset_BioLegend[:, hvg_BioLegend],
                                                cell_measurements_col_mappings = {"protein_expression":"protein_names"})
dataset_totalVI_BioLegend

# Concatenate two datasets into one
dataset = GeneExpressionDataset()
dataset.populate_from_datasets(
    [copy.deepcopy(dataset_totalVI_Berkeley), copy.deepcopy(dataset_totalVI_BioLegend)],
)

Any help would be appreciated, whether its helping me learn that my installation is broken, or by helping modernize the code

Hi, yes it looks like you’re trying to reproduce an older version of scvi-tools. Please refer to the recent totalVI tutorial for our updated API!

Ah, Bummer! Thanks for the quick confirmation, I’ll get working on updating things.