squid.predictor
Module Contents
Classes
Base class for running inference on in silico mutated sequences. |
|
Module for handling scalar-based model predictions. |
|
Module for handling profile-based model predictions. |
|
Module for handling BPNet (Kipoi) model predictions. |
Functions
|
Function to compute model predictions in batch mode. |
|
Function to transform predictions to scalars using summation. |
|
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.
- class squid.predictor.ScalarPredictor(pred_fun, task_idx=0, batch_size=64, save_window=None, **kwargs)[source]
Bases:
BasePredictorModule for handling scalar-based model predictions.
- Parameters:
- Returns:
Batch of scalar predictions corresponding to inputs.
- Return type:
torch.Tensor
- 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:
BasePredictorModule for handling profile-based model predictions.
- Parameters:
- Returns:
Batch of scalar predictions corresponding to inputs.
- Return type:
torch.Tensor
- 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:
BasePredictorModule for handling BPNet (Kipoi) model predictions.
- Parameters:
- Returns:
Batch of scalar predictions corresponding to inputs.
- Return type:
torch.Tensor
- 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