Module: Cell_BLAST.latent

Latent space / encoder modules for DIRECTi

Classes:

CatGau(input_dim, latent_dim, cat_dim[, ...])

Build a double latent module, with a continuous Gaussian latent variable and a one-hot categorical latent variable for intrinsic clustering of the data.

Gau(input_dim, latent_dim[, h_dim, depth, ...])

Build a Gaussian latent module.

Latent(input_dim, latent_dim[, h_dim, ...])

Abstract base class for latent variable modules.

Regularizer(latent_dim[, h_dim, depth, ...])

SemiSupervisedCatGau(input_dim, latent_dim, ...)

Build a double latent module, with a continuous Gaussian latent variable and a one-hot categorical latent variable for intrinsic clustering of the data.

class Cell_BLAST.latent.CatGau(input_dim, latent_dim, cat_dim, h_dim=128, depth=1, dropout=0.0, lambda_reg=0.001, fine_tune=False, deviation_reg=0.0, name='CatGau', _class='CatGau', **kwargs)[source]

Build a double latent module, with a continuous Gaussian latent variable and a one-hot categorical latent variable for intrinsic clustering of the data. These two latent variabels are then combined into a single cell embedding vector.

Parameters:
  • input_dim (int) – Dimensionality of the input tensor.

  • latent_dim (int) – Dimensionality of the latent variable.

  • cat_dim (int) – Number of intrinsic clusters.

  • h_dim (int) – Dimensionality of the hidden layers in the encoder MLP.

  • depth (int) – Number of hidden layers in the encoder MLP.

  • dropout (float) – Dropout rate.

  • lambda_reg (float) – Regularization strength on the latent variable.

  • name (str) – Name of the module.

Methods:

forward(x)

Defines the computation performed at every call.

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses. :rtype: Tuple[Tensor]

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Cell_BLAST.latent.Gau(input_dim, latent_dim, h_dim=128, depth=1, dropout=0.0, lambda_reg=0.001, fine_tune=False, deviation_reg=0.0, name='Gau', _class='Gau', **kwargs)[source]

Build a Gaussian latent module. The Gaussian latent variable is used as cell embedding.

Parameters:
  • input_dim (int) – Dimensionality of the input tensor.

  • latent_dim (int) – Dimensionality of the latent variable.

  • h_dim (int) – Dimensionality of the hidden layers in the encoder MLP.

  • depth (int) – Number of hidden layers in the encoder MLP.

  • dropout (float) – Dropout rate.

  • lambda_reg (float) – Regularization strength on the latent variable.

  • name (str) – Name of the module.

Methods:

forward(x)

Defines the computation performed at every call.

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses. :rtype: Tensor

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Cell_BLAST.latent.Latent(input_dim, latent_dim, h_dim=128, depth=1, dropout=0.0, lambda_reg=0.0, fine_tune=False, deviation_reg=0.0, name='Latent', _class='Latent', **kwargs)[source]

Abstract base class for latent variable modules.

class Cell_BLAST.latent.Regularizer(latent_dim, h_dim=128, depth=1, dropout=0.0, name='Reg', _class='Regularizer', **kwargs)[source]

Methods:

forward(x)

Defines the computation performed at every call.

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses. :rtype: Tensor

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Cell_BLAST.latent.SemiSupervisedCatGau(input_dim, latent_dim, cat_dim, h_dim=128, depth=1, dropout=0.0, lambda_sup=10.0, background_catp=0.001, lambda_reg=0.001, fine_tune=False, deviation_reg=0.0, name='SemiSupervisedCatGau', _class='SemiSupervisedCatGau', **kwargs)[source]

Build a double latent module, with a continuous Gaussian latent variable and a one-hot categorical latent variable for intrinsic clustering of the data. The categorical latent supports semi-supervision. The two latent variables are then combined into a single cell embedding vector.

Parameters:
  • input_dim (int) – Dimensionality of the input tensor.

  • latent_dim (int) – Dimensionality of the Gaussian latent variable.

  • cat_dim (int) – Number of intrinsic clusters.

  • h_dim (int) – Dimensionality of the hidden layers in the encoder MLP.

  • depth (int) – Number of hidden layers in the encoder MLP.

  • dropout (float) – Dropout rate.

  • lambda_sup (float) – Supervision strength.

  • background_catp (float) – Unnormalized background prior distribution of the intrinsic clustering latent. For each supervised cell in a minibatch, unnormalized prior probability of the corresponding cluster will increase by 1, so this parameter determines how much to trust supervision class frequency, and it balances between supervision and identifying new clusters.

  • lambda_reg (float) – Regularization strength on the latent variables.

  • name (str) – Name of latent module.

Methods:

forward(x)

Defines the computation performed at every call.

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses. :rtype: Tuple[Tensor]

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.