scvi.external.SOLO

class scvi.external.SOLO(adata, **classifier_kwargs)[source]

Doublet detection in scRNA-seq [Bernstein19].

Most users will initialize the model using the class method from_scvi_model(), which takes as input a pre-trained SCVI object.

Parameters
adata : AnnDataAnnData

AnnData object that has been registered via setup_anndata(). Object should contain latent representation of real cells and doublets as adata.X. Object should also be registered, using .X and labels_key=”_solo_doub_sim”.

**classifier_kwargs

Keyword args for Classifier

Examples

In the case of scVI trained with multiple batches:

>>> adata = anndata.read_h5ad(path_to_anndata)
>>> scvi.data.setup_anndata(adata, batch_key="batch")
>>> vae = scvi.model.SCVI(adata)
>>> vae.train()
>>> solo_batch_1 = scvi.external.SOLO.from_scvi_model(vae, restrict_to_batch="batch 1")
>>> solo_batch_1.train()
>>> solo_batch_1.predict()

Otherwise:

>>> adata = anndata.read_h5ad(path_to_anndata)
>>> scvi.data.setup_anndata(adata)
>>> vae = scvi.model.SCVI(adata)
>>> vae.train()
>>> solo = scvi.external.SOLO.from_scvi_model(vae)
>>> solo.train()
>>> solo.predict()

Notes

Solo should be trained on one lane of data at a time. An SCVI instance that was trained with multiple batches can be used as input, but Solo should be created and run multiple times, each with a new restrict_to_batch in from_scvi_model().

Attributes

device

history

Returns computed metrics during training.

is_trained

test_indices

train_indices

validation_indices

Methods

create_doublets(adata, doublet_ratio[, …])

Simulate doublets.

from_scvi_model(scvi_model[, adata, …])

Instantiate a SOLO model from an scvi model.

load(dir_path[, adata, use_gpu])

Instantiate a model from the saved output.

predict([soft, include_simulated_doublets])

Return doublet predictions.

save(dir_path[, overwrite, save_anndata])

Save the state of the model.

to_device(device)

Move model to device.

train([max_epochs, lr, use_gpu, train_size, …])

Trains the model.