Choosing number of latent variables

Hi,

Is there a way to choose between the number of latent variables when doing scvi integration? Does the hyperparameter tuning provide this option?

Thanks,
Kamalika

Yes, of course. You set it when defining the model: SCVI(adata, n_latent=x)

In our hyperparameters tuner, one can do:

run_autotune(
    SCVI,
    adata,
    metrics=["elbo_validation"],
    mode="min",
    search_space={
        "model_params": {
            "n_latent": tune.choice([10, 20]),
        },
    },
    ...)
1 Like

Thanks a lot for your response. Do I need anymore dependencies for running autotune? I have used the following

from scvi import autotune
from ray import tune

and

results = autotune.run_autotune(
SCVI,
adata,
metrics=[“elbo_validation”],
mode=“min”,
search_space={
“model_params”: {
“n_latent”: tune.choice([10, 20]),
},
},
…)

It’s throwing an error regarding hyperopt library.

raise ModuleNotFoundError(f"Please install {missing_modules} to use this functionality.")
ModuleNotFoundError: Please install [‘hyperopt’] to use this functionality.

You need to install hyperopt:

pip install hyperopt

or originally: pip install scvi-tools[autotune]