This function fits a per-feature survival model to the full (non-resampled) data matrix using the observed sample metadata, producing the final statistics used for ranking features.

fit_survival(x, meta.info, formula.str, competing_risks)

Arguments

x

A data matrix where rows represent features (e.g., proteins, metabolites) and columns represent samples.

meta.info

A data frame containing the metadata for the samples. Must include time, event, and any additional covariates used in formula.str.

formula.str

A string specifying the formula to be used in model fitting. Must include a Surv(time, event) term. The per-feature coefficient term (y) is prepended automatically.

competing_risks

Logical. If FALSE (default), a Cox proportional hazards model is fitted per feature using coxph. If TRUE, a competing risks model is fitted per feature using crr from the cmprsk package.

Value

A list containing the following elements:

d

A numeric vector of absolute coefficients (\(|\beta|\)) for each feature.

s

A numeric vector of standard errors of the coefficients for each feature.

exp_coef

A numeric vector of exponentiated coefficients (hazard ratios, \(e^{\beta}\)) for each feature.

Details

For each feature (row), the function appends the feature expression values as y to the sample metadata and fits either a Cox proportional hazards model (competing_risks = FALSE) or a subdistribution hazard model (competing_risks = TRUE). The coefficient, its standard error, and the exponentiated coefficient (hazard ratio) for the feature term y are extracted.

Unlike permutating_survival and bootstrap_survival, this function operates on the observed (non-permuted, non-resampled) data to produce the final statistics used for feature ranking.

See also