
Cox Model for Calculating Hazard Ratios From Clinical End-points
get_survival.RdRun a Cox model to calculate hazard ratio with confidence intervals.
Usage
get_survival(
these_predictions = NULL,
these_samples_metadata = NULL,
subtype_class = "5_class",
scale = NULL,
bin_scores = TRUE,
n_bins = 10,
this_subtype = NULL,
predictor_columns = NULL,
exclude_columns = NULL,
surv_time = NULL,
surv_event = NULL,
row_to_col = FALSE,
sample_id_col = NULL
)Arguments
- these_predictions
Required parameter. A data frame with predictions scores, subtype and metadata information.
- these_samples_metadata
Required, a data frame with metadata associated with the prediction calls, Note, the function will subset the return to samples are included in this object.
- subtype_class
Can be one of the following; 5_class or 7_class. Default is 5_class.
- scale
Optional parameter. A numeric value to scale the numeric scores. If provided, all numeric scores will be multiplied by this value.
- bin_scores
Boolean parameter. Set to TRUE to bin the numeric scores into discrete bins. Default is TRUE
- n_bins
Optional parameter. The number of bins to use when binning numeric scores. Default is 10.
- this_subtype
Optional parameter. Allows the user to subset the return to a specific subtype within the selected class. If not specified, the function will return a data frame with subtype information for all the subtypes within the specified class.
- predictor_columns
Optional, should be a vector with column names, either from the provided metadata or signature score object, to be tested for. If not provided, the function will subset data to the signature scores returned with
classify_samples.- exclude_columns
Optional argument, specify columns you wish to exclude from the standard predictor columns. Note, this parameter is only validated if predictor_columns is NULL (default).
- surv_time
Required parameter, should be the name of the column in the metadata with survival time. Should be of value numeric.
- surv_event
Required parameter, should be the name of the column in the metadata with survival event. Should be of value factor, with two levels.
- row_to_col
Boolean parameter. Set to TRUE to transform row names of the metadata to a new column called sample_id. Default is FALSE.
- sample_id_col
Parameter dictating the column name with sample IDs, the function expects this column to be sample_id but the user can override this if they know the name for this column.
Details
This function takes a data frame with prediction data these_predictions and executes
a cox model to retrieve hazard ratio with confidence intervals based on a categorical variable
(e.g response, tumor grade, etc.) from a provided metadata table. The function expects the
incoming data to be the output from classify_samples(), together with metadata
information of interest (i.e two level categorical) and subtype classification information. The
user have the option to point the function to the categorical variables with predictor_columns.
The return can be further subset by subtype by using the this_subtype variable, should be one
of the valid subtypes within the specified class. The user is required to provide the funciton
with correct column names in the metadata for survival time and survival event (see surv_time
and surv_event).
Examples
#run classifier
sjodahl_classes = classify_samples(this_data = sjodahl_2017,
log_transform = FALSE,
adjust = TRUE,
impute = TRUE,
include_data = TRUE,
verbose = FALSE)
#run general linear models
sjodahl_surv = get_survival(these_predictions = sjodahl_classes,
these_samples_metadata = sjodahl_2017_meta,
subtype_class = "5_class",
this_subtype = "Uro",
surv_time = "surv_css_time",
surv_event = "surv_css_event")
#> Filtering prediction data on the selected subtype(s)...
#> 121 samples kept after filtering on subtype and metadata...
#view data
head(sjodahl_surv)
#> score p_value hazard_ratio hazard_conf_2.5 hazard_conf_97.5
#> 1 proliferation_score 0.34017390 0.9004548 0.7259184 1.116956
#> 2 progression_score 0.82366518 0.9768376 0.7948835 1.200442
#> 3 stromal141_up 0.04386189 1.1752640 1.0044526 1.375123
#> 4 immune141_up 0.64642520 1.0370748 0.8876886 1.211601
#> 5 b_cells 0.75392239 1.0257559 0.8749675 1.202530
#> 6 t_cells 0.60827514 0.9571147 0.8094116 1.131771
#> subtype
#> 1 Uro
#> 2 Uro
#> 3 Uro
#> 4 Uro
#> 5 Uro
#> 6 Uro