Module: Cell_BLAST.rmbatch

Batch effect removing modules for DIRECTi

Classes:

AdaptiveMNNAdversarial(*args, **kwargs)

Adversarial(batch_dim, latent_dim[, h_dim, ...])

Build a batch effect correction module that uses adversarial batch alignment.

MNN(batch_dim, latent_dim[, n_neighbors, ...])

Build a batch effect correction module that uses mutual nearest neighbor (MNN) distance regularization.

MNNAdversarial(batch_dim, latent_dim[, ...])

Build a batch effect correction module that uses adversarial batch alignment among cells with mutual nearest neighbors.

RMBatch(batch_dim, latent_dim[, delay, ...])

Parent class for systematical bias / batch effect removal modules.

class Cell_BLAST.rmbatch.AdaptiveMNNAdversarial(*args, **kwargs)[source]
class Cell_BLAST.rmbatch.Adversarial(batch_dim, latent_dim, h_dim=128, depth=1, dropout=0.0, lambda_reg=0.01, n_steps=1, delay=20, name='AdvBatch', _class='Adversarial', **kwargs)[source]

Build a batch effect correction module that uses adversarial batch alignment.

Parameters:
  • batch_dim (int) – Number of batches.

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

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

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

  • dropout (float) – Dropout rate.

  • lambda_reg (float) – Strength of batch effect correction,

  • n_steps (int) – How many discriminator steps to run for each encoder step.

  • delay (int) – How many epoches to delay before using Adversarial batch correction.

  • name (str) – Name of the module.

Methods:

forward(x, mask)

Defines the computation performed at every call.

forward(x, mask)[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.rmbatch.MNN(batch_dim, latent_dim, n_neighbors=5, lambda_reg=1.0, delay=20, name='MNN', _class='MNN', **kwargs)[source]

Build a batch effect correction module that uses mutual nearest neighbor (MNN) distance regularization.

Parameters:
  • batch_dim (int) – Number of batches.

  • n_neighbors (int) – Number of nearest neighbors to use when selecting mutual nearest neighbors.

  • lambda_reg (float) – Strength of batch effect correction.

  • delay (int) – How many epoches to delay before using MNN batch correction.

  • name (str) – Name of the module.

class Cell_BLAST.rmbatch.MNNAdversarial(batch_dim, latent_dim, h_dim=128, depth=1, dropout=0.0, lambda_reg=0.01, n_steps=1, n_neighbors=5, delay=20, name='MNNAdvBatch', _class='MNNAdversarial', **kwargs)[source]

Build a batch effect correction module that uses adversarial batch alignment among cells with mutual nearest neighbors.

Parameters:
  • batch_dim (int) – Number of batches.

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

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

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

  • dropout (float) – Dropout rate.

  • lambda_reg (float) – Strength of batch effect correction,

  • n_steps (int) – How many discriminator steps to run for each encoder step.

  • n_neighbors (int) – Number of nearest neighbors to use when selecting mutual nearest neighbors.

  • delay (int) – How many epoches to delay before using MNNAdversarial batch correction.

  • name (str) – Name of the module.

class Cell_BLAST.rmbatch.RMBatch(batch_dim, latent_dim, delay=20, name='RMBatch', _class='RMBatch', **kwargs)[source]

Parent class for systematical bias / batch effect removal modules.

Methods:

forward(x, mask)

Defines the computation performed at every call.

forward(x, mask)[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.