scvi-tools
scvi-tools copied to clipboard
Add changes for tracking scib-metrics in autotune
Here's an example code snippet for how this works with SCVI:
import scvi
from scvi.autotune import ModelTuner
from scvi.train._scib_callback import ScibCallback
adata = scvi.data.synthetic_iid()
model_cls = scvi.model.SCVI
model_cls.setup_anndata(adata, batch_key="batch", labels_key="labels")
tuner = ModelTuner(model_cls)
tuner.fit(
adata,
use_defaults=True,
metric="validation Batch correction", # necessary
train_kwargs={"callbacks": [ScibCallback(stage="validation")]}, # necessary
validate_metrics=False, # necessary
)
Code is not nice yet as the TrainingPlan
has to accumulate and store the raw counts, latent representation, batches, and labels for this to work.