scparadise.scadam.predict#
- scparadise.scadam.predict(adata, path_model, layer=None, batch_size=256, device='auto', prefix='pred_', detect_unknown=False, method='voting', threshold=2.0, temperature=2.0, mc_passes=5, verbose=True)[source]#
Predict cell types and cell type probilities using pretrained scAdam model. It is also possible to check if a cell has an unknown cell type for the scAdam model (detect_unknown = True).
- Parameters:
adata (AnnData) – Annotated data matrix.
path_model (str, path object) – Path to the folder containing the trained scAdam model.
layer (str (default: None)) – If specified, use adata.layers[layer] for expression values instead of adata.X.
batch_size (int, (default: 256)) – Number of examples per batch.
device (str (default: 'auto')) – Type of device to use in prediction (‘cpu’, ‘cuda’). Set ‘auto’ for automatic selection.
prefix (str (default: ‘pred_’)) – Prefix for new columns in adata.obs
detect_unknown (bool (default: False)) – Detection of unknown cell types. Parameters ‘method’, ‘temperature’, ‘mc_passes’, ‘threshold’ are not used if ‘detect_unknown’ = False.
method (str (default: 'voting')) – Method of unknown cell type detection. gradient - uses the norm of the gradient with respect to the last annotation level embedding as an uncertainty score. entropy - uses the entropy of the softmax probabilities on the last annotation level. distance - uses the distance in embedding space to the centroid of the predicted class. voting - combines the three previous criteria with majority voting. combined - builds one continuous combined score from all three individual methods with combined threshold.
threshold (float (default = 2.0)) – Ashman coefficient threshold. Threshold > 2 indicates good peak separation. For a more subtle separation, threshold > 1.5 can be used.
temperature (float (default: 2.0)) – A parameter that controls the confidence of the model in its predictions. If temperature > 1 - model appears less confident. If temperature < 1 - model appears more confident.
mc_passes (int (default: 5)) – It is the number of forward passes you run with dropout left on for the same data (Monte Carlo dropout). Necessary for calculating the gradient score.
verbose (bool (default: True)) – Show progress bar for each batch during prediction.
- Returns:
adata – Annotated adata object with predicted cell types in adata.obs. if detect_unknown = True, adds methods scores in adata.obs.
- Return type:
AnnData