Helper Module for Deep Learning.
Pathway Modules Variational Auto-Encoder (pmVAE).
[1] pmVAE: Learning Interpretable Single-Cell Representations with Pathway Modules, Gilles Gut, biorxiv 2021.
Code: https://github.com/ratschlab/pmvae
-
class
pynet.models.vae.pmvae.PMVAE(membership_mask, latent_dim, hidden_layers, bias_last_layer=False, add_auxiliary_module=True, terms=None, activation=None)[source]¶ -
__init__(membership_mask, latent_dim, hidden_layers, bias_last_layer=False, add_auxiliary_module=True, terms=None, activation=None)[source]¶ pmVAE constructs a pathway-factorized latent space.
- Parameters
membership_mask: bool array (pathways, genes)
a binary mask encoding which genes belong to wich pathways.
latent_dim: int
the dimension of each module latent space.
hidden_layers: list of int
the dimension of each module encoder/decoder hidden layer.
bias_last_layer: bool, default False
use a bias term on the final decoder output.
add_auxiliary_module: bool, default True
include a fully connected pathway module.
terms: list of str (pathways, ), default None
the pathway names.
activation: klass, default None
the activation function.
-
static
build_base_masks(membership_mask, hidden_layers, latent_dim)[source]¶ Builds the masks used by the encoders/decoders.
- Parameters
membership_mask: bool array (pathways, genes)
a binary mask encoding which genes belong to wich pathways.
latent_dim: int
the dimension of each module latent space.
hidden_layers: list of int
the dimension of each module encoder/decoder hidden layer.
- Returns
base: list of array
pathway mask assigns genes to pathway modules, and separation masks keep modules separated. Encoder modifies the last separation mask to give mu/logvar, and the decoder reverses and transposes the masks.
-
static
build_decoder(membership_mask, hidden_layers, latent_dim, activation, batch_norm=True, bias_last_layer=False)[source]¶ Build the decoder/merger modules.
-
static
build_encoder(membership_mask, hidden_layers, latent_dim, activation, batch_norm=True)[source]¶ Build the encoder module.
-
static
build_module_isolation_mask(nmodules, module_output_dim)[source]¶ Isolates a single module for gradient steps. Used for the local reconstruciton terms, drops all modules except one.
-
static
build_pathway_mask(nfeats, membership_mask, hidden_layers)[source]¶ Connects genes to pathway modules. Repeats the membership mask for each module input node. See M in Methods 2.2.
-
static
build_separation_mask(input_dim, out_put_dim, nmodules)[source]¶ Removes connections betweens pathway modules. Block diagonal matrix, see Sigma in Methods 2.2.
-
decode(z)[source]¶ Computes the generative distribution p(x | z).
- Parameters
z: torch.Tensor (batch_size, latent_dim)
the stochastic latent state z.
- Returns
p(x | z): @callable
the distribution p(x | z) with shape (batch_size, data_size).
-
Follow us
Inspired by AZMIND template.