squid.predictor

Module Contents

Classes

BasePredictor

Base class for running inference on in silico mutated sequences.

ScalarPredictor

Module for handling scalar-based model predictions.

ProfilePredictor

Module for handling profile-based model predictions.

BPNetPredictor

Module for handling BPNet (Kipoi) model predictions.

Functions

predict_in_batches(x[, x_ref, model_pred_fun, ...])

Function to compute model predictions in batch mode.

profile_sum(pred[, save_dir])

Function to transform predictions to scalars using summation.

profile_pca(pred[, save_dir])

Function to transform predictions to scalars using principal component analysis (PCA).

class squid.predictor.BasePredictor[source]

Base class for running inference on in silico mutated sequences.

save_dir[source]
abstract __call__(x, x_ref=None, save_window=None)[source]
class squid.predictor.ScalarPredictor(pred_fun, task_idx=0, batch_size=64, save_window=None, **kwargs)[source]

Bases: BasePredictor

Module for handling scalar-based model predictions.

Parameters:
  • pred_fun (built-in function) – Function for returning model predictions.

  • task_idx (int) – Task index corresponding to a specific output head.

  • batch_size (int) – The number of predictions per batch.

Returns:

Batch of scalar predictions corresponding to inputs.

Return type:

torch.Tensor

__call__(x, x_ref=None, save_window=None)[source]
class squid.predictor.ProfilePredictor(pred_fun, task_idx=0, batch_size=64, reduce_fun=np.sum, save_dir=None, save_window=None, **kwargs)[source]

Bases: BasePredictor

Module for handling profile-based model predictions.

Parameters:
  • pred_fun (function) – Function for returning model predictions.

  • task_idx (int) – Task index corresponding to a specific output head.

  • batch_size (int) – The number of predictions per batch.

  • reduce_fun (function) – Function for reducing profile prediction to scalar.

Returns:

Batch of scalar predictions corresponding to inputs.

Return type:

torch.Tensor

__call__(x, x_ref=None, save_window=None)[source]
class squid.predictor.BPNetPredictor(pred_fun, task_idx=0, batch_size=64, reduce_fun='wn', axis=1, save_dir=None, save_window=None, **kwargs)[source]

Bases: BasePredictor

Module for handling BPNet (Kipoi) model predictions.

Parameters:
  • pred_fun (function) – Function for returning model predictions.

  • task_idx (int) – Task index corresponding to a specific output head.

  • batch_size (int) – The number of predictions per batch.

  • reduce_fun (function) – Function for reducing profile prediction to scalar.

Returns:

Batch of scalar predictions corresponding to inputs.

Return type:

torch.Tensor

__call__(x, x_ref=None, save_window=None)[source]
squid.predictor.predict_in_batches(x, x_ref=None, model_pred_fun=None, batch_size=None, task_idx=None, save_window=None, **kwargs)[source]

Function to compute model predictions in batch mode.

Parameters:
  • x (numpy.ndarray) – One-hot sequences (shape: (N, L, A)).

  • x_ref (numpy.ndarray, optional) – One-hot reference sequence (shape: (L, A)). Required if save_window is not None.

  • model_pred_fun (function) – Built-in function for accessing model inference on inputs.

  • batch_size (int) – The number of predictions per batch of model inference.

  • save_window ([int, int], optional) – Window used for delimiting sequences that are exported in ‘x_mut’ array

Returns:

Model predictions.

Return type:

numpy.ndarray

squid.predictor.profile_sum(pred, save_dir=None)[source]

Function to transform predictions to scalars using summation.

Parameters:

pred (np.ndarray) – Batch of profile-based predictions.

Returns:

Batch of scalar predictions.

Return type:

numpy.ndarray

squid.predictor.profile_pca(pred, save_dir=None)[source]

Function to transform predictions to scalars using principal component analysis (PCA).

Parameters:

pred (np.ndarray) – Batch of profile-based predictions.

Returns:

Batch of scalar predictions formed from projection of embedded profiles onto the first principal component.

Return type:

numpy.ndarray