Skip to contents

Fit and evaluate one XGBoost model for a single perturbation.

Usage

make_xgb_model(
  perturbation,
  indx,
  total,
  dataset,
  response_cutoff = 0.5,
  decreasing = FALSE,
  nfolds = 3,
  nrepeats = 3,
  nrounds = 200,
  max_depth = 3,
  f_subsample = 1,
  min_score = 0.01,
  shuffle = FALSE,
  seed = 1L,
  n_threads = 4,
  xgb_params = NULL,
  cor_n_features = NULL,
  shap_top_n = 100L
)

Arguments

perturbation

Column name of the perturbation to model.

indx

Integer model index used for progress reporting.

total

Total number of models used for progress reporting.

dataset

Data frame containing the perturbation response and predictor columns. Sample names are row names.

response_cutoff

Default biological response cutoff used to define target events for classification-style summaries and downstream event probabilities.

decreasing

If TRUE, values at or below response_cutoff define the target event; otherwise values at or above the cutoff define the target event.

nfolds

Number of cross-validation folds.

nrepeats

Number of repeated cross-validation runs.

nrounds

Maximum number of XGBoost boosting rounds.

max_depth

Maximum tree depth.

f_subsample

Fraction of training rows sampled for each boosting round.

min_score

Minimum mean R-squared required to retain the fitted model.

shuffle

If TRUE, shuffle response values before model fitting.

seed

Base random seed. A deterministic perturbation-specific seed is derived from this value so model results do not depend on target order. Both values are stored in each returned model object as seed and target_seed.

n_threads

Number of threads passed to XGBoost.

xgb_params

Optional named list overriding supported XGBoost parameters.

cor_n_features

Optional number of target-correlated features to retain. When set, features are ranked by absolute correlation within each cross-validation training fold and reranked using all training samples for the final refit. NULL disables correlation filtering.

shap_top_n

Maximum number of non-intercept SHAP features retained per sample before remaining contributions are collapsed into __other__.

Value

A POWERUP model object containing fitted models, cross-validation metrics, predictions, uncertainty estimates, and SHAP values.

Examples

if (FALSE) { # \dontrun{
fit <- make_xgb_model("ko_ctnnb1", 1, 1, my_data)
} # }