Skip to contents

Performs bagged (bootstrap aggregating) predictions using an ensemble of ccModel objects. This function averages predictions from multiple models to improve stability and accuracy.

Usage

predClassBag.optimized(ccModel, Exp, scORpat)

Arguments

ccModel

A list of ccModel objects representing the ensemble of models to use for bagged prediction. Each model should be a valid ccModel instance.

Exp

A matrix or data frame containing the expression data to be classified.

scORpat

A character string specifying whether the data represents single-cell ("sc") or phenotype ("pat") data. This parameter is passed to the underlying prediction functions.

Value

A matrix of averaged predictions where each element represents the aggregated probability or classification score across all models in the ensemble. The output is computed as the mean of all individual model predictions.

Details

This function implements model bagging by:

  • Iterating over each model in the ccModel list using purrr::map

  • Selecting the appropriate prediction function based on the model's architecture ("DenseNet" vs "Standard")

  • Averaging all predictions using Reduce("+", out) / length(out)

The function supports two architectures:

  • "DenseNet": Uses DEGAS::predClass2 for prediction

  • "Standard": Uses DEGAS::predClass1 for prediction

If an unsupported architecture is encountered, the function will abort with an informative error message.

References

Johnson TS, Yu CY, Huang Z, Xu S, Wang T, Dong C, et al. Diagnostic Evidence GAuge of Single cells (DEGAS): a flexible deep transfer learning framework for prioritizing cells in relation to disease. Genome Med. 2022 Feb 1;14(1):11.

Examples

if (FALSE) { # \dontrun{
# Create an ensemble of models
model_list <- list(model1, model2, model3)

# Perform bagged prediction on expression data
predictions <- predClassBag(
  ccModel = model_list,
  Exp = expression_matrix,
  scORpat = "sc"
)

# Use the averaged predictions for downstream analysis
class_assignments <- ifelse(predictions > 0.5, "Class1", "Class2")
} # }