Skip to contents

Splits patients into groups based on expression of a single gene (e.g., median split) and runs Kaplan-Meier analysis with log-rank test. Connects differential expression results to clinical outcomes.

Usage

run_km_by_expression(
  surv_data,
  expr_matrix,
  gene,
  split = c("median", "tertile", "quartile", "top_bottom_20"),
  min_per_group = 5L
)

Arguments

surv_data

Data frame from [prepare_survival_data()] with columns `patient_id`, `time_days`, `status`

expr_matrix

Numeric matrix (genes x samples) of transformed expression values (e.g., VST). Column names must match `surv_data$patient_id`.

gene

Gene name (must be a rowname of `expr_matrix`)

split

Split method: "median" (default), "tertile", "quartile", or "top_bottom_20"

min_per_group

Minimum patients per group (default 5)

Value

List compatible with [plot_km()]: fit, logrank_p, median_survival, n_per_group, strata, gene, split_method. Returns a list with `fit = NULL` and a `note` if requirements not met.