scvi.model.base.ArchesMixin#

class scvi.model.base.ArchesMixin[source]#

Universal scArches implementation.

Methods table#

load_query_data(adata, reference_model[, ...])

Online update of a reference model with scArches algorithm [Lotfollahi21].

prepare_query_anndata(adata, reference_model)

Prepare data for query integration.

Methods#

load_query_data#

classmethod ArchesMixin.load_query_data(adata, reference_model, inplace_subset_query_vars=False, use_gpu=None, unfrozen=False, freeze_dropout=False, freeze_expression=True, freeze_decoder_first_layer=True, freeze_batchnorm_encoder=True, freeze_batchnorm_decoder=False, freeze_classifier=True)[source]#

Online update of a reference model with scArches algorithm [Lotfollahi21].

Parameters:
adata : AnnData

AnnData organized in the same way as data used to train model. It is not necessary to run setup_anndata, as AnnData is validated against the registry.

reference_model : str | BaseModelClassUnion[str, BaseModelClass]

Either an already instantiated model of the same class, or a path to saved outputs for reference model.

inplace_subset_query_vars : bool (default: False)

Whether to subset and rearrange query vars inplace based on vars used to train reference model.

use_gpu : str | int | bool | NoneUnion[str, int, bool, None] (default: None)

Load model on default GPU if available (if None or True), or index of GPU to use (if int), or name of GPU (if str), or use CPU (if False).

unfrozen : bool (default: False)

Override all other freeze options for a fully unfrozen model

freeze_dropout : bool (default: False)

Whether to freeze dropout during training

freeze_expression : bool (default: True)

Freeze neurons corersponding to expression in first layer

freeze_decoder_first_layer : bool (default: True)

Freeze neurons corersponding to first layer in decoder

freeze_batchnorm_encoder : bool (default: True)

Whether to freeze batchnorm weight and bias during training for encoder

freeze_batchnorm_decoder : bool (default: False)

Whether to freeze batchnorm weight and bias during training for decoder

freeze_classifier : bool (default: True)

Whether to freeze classifier completely. Only applies to SCANVI.

prepare_query_anndata#

static ArchesMixin.prepare_query_anndata(adata, reference_model, return_reference_var_names=False, inplace=True)[source]#

Prepare data for query integration.

This function will return a new AnnData object with padded zeros for missing features, as well as correctly sorted features.

Parameters:
adata : AnnData

AnnData organized in the same way as data used to train model. It is not necessary to run setup_anndata, as AnnData is validated against the registry.

reference_model : str | BaseModelClassUnion[str, BaseModelClass]

Either an already instantiated model of the same class, or a path to saved outputs for reference model.

return_reference_var_names : bool (default: False)

Only load and return reference var names if True.

inplace : bool (default: True)

Whether to subset and rearrange query vars inplace or return new AnnData.

Return type:

AnnData | Index | NoneUnion[AnnData, Index, None]

Returns:

Query adata ready to use in load_query_data unless return_reference_var_names in which case a pd.Index of reference var names is returned.