Aggregates clone-level drug response predictions to patient-level using various weighting strategies based on clone abundance. This function merges the former each_patient_viability (single drug) and each_patient_viabilityv2 (multi-drug) into a unified interface.
Usage
predict_patients(
clone_pred,
prepared_data,
clone_counts = NULL,
mode = "weighted_max",
zscore = TRUE
)Arguments
- clone_pred
Matrix from
predict_drugs(), with clones as rows and drugs as columns. Row names should match clone column names fromprepare_data().- prepared_data
List from
prepare_data(), containing$clone_viability_templateand$clone_counts. Alternatively, you can passclone_countsdirectly as a data frame (legacy mode).- clone_counts
Optional. Data frame with patients as rows and clone IDs as columns. Only needed if
prepared_datais not a list fromprepare_data().- mode
Character. Aggregation method:
- "weighted_max"
Maximum of weighted viability across clones. Default.
- "max"
Maximum viability across clones (most resistant clone)
- "weighted_average"
Weighted average of clone viability by clone abundance
- "min"
Minimum viability across clones (most sensitive clone)
- "average"
Average of clone viability
- zscore
Logical. Whether to z-score scale drug columns across patients before aggregation. Default = TRUE. Matches the original PERCEPTION pipeline.
Value
A data frame with patients as rows and drugs as columns, containing aggregated viability scores.
Examples
if (FALSE) { # \dontrun{
# Simple workflow: pass prepare_data() output directly
prepared <- prepare_data(patient_scRNA)
clone_pred <- predict_drugs(models, prepared$clone_expression)
patient_pred <- predict_patients(clone_pred, prepared)
# Legacy workflow: manually build clone_viability_matrix
clone_viability_df <- data.frame(
patient = patient_ids,
clone_id = clone_ids,
clone_pred
)
patient_pred <- predict_patients(clone_viability_df, clone_counts)
} # }
