Introduction
This vignette demonstrates how to perform robust survival and
statistical analyses using LundTaxR, focusing on two key functions:
get_glm and get_survival. These functions
streamline the process of running generalized linear models and Cox
proportional hazards models using your molecular subtype and signature
score data, integrating seamlessly with your sample metadata. Both
functions handle common preprocessing steps internally, such as binning
numeric variables and wrangling prediction outputs, so you can focus on
interpreting results.
1. Generalized Linear Model Analysis with get_glm
The get_glm function enables you to test associations
between molecular signature scores (or other predictors) and categorical
variables of interest (such as response, grade, gender, or region). It
supports both Mann-Whitney tests and generalized linear regression, and
can be customized to focus on specific subtypes or predictor sets.
Example 1: Testing Signature Scores by Gender
results <- classify_samples(
this_data = sjodahl_2017,
include_data = TRUE,
verbose = FALSE
)
# Run GLM comparing signature scores by gender
glm_results_gender <- get_glm(
these_predictions = results,
these_samples_metadata = sjodahl_2017_meta,
subtype_class = "5_class",
categorical_factor = "gender"
)
knitr::kable(head(glm_results_gender))
| proliferation_score |
0.2876215 |
0.9349577 |
0.8038649 |
1.0892350 |
gender |
all |
| progression_score |
0.4406753 |
0.9378858 |
0.8001656 |
1.0980705 |
gender |
all |
| stromal141_up |
0.5364414 |
0.9561336 |
0.8295723 |
1.1014490 |
gender |
all |
| immune141_up |
0.0869924 |
0.8786143 |
0.7616828 |
1.0100169 |
gender |
all |
| b_cells |
0.6963593 |
0.9587575 |
0.8286159 |
1.1131523 |
gender |
all |
| t_cells |
0.0347652 |
0.8593952 |
0.7399484 |
0.9953762 |
gender |
all |
Example 2: Restricting to a Specific Subtype (e.g., GU)
glm_results_gu <- get_glm(
these_predictions = results,
these_samples_metadata = sjodahl_2017_meta,
subtype_class = "5_class",
this_subtype = "GU",
categorical_factor = "gender"
)
knitr::kable(head(glm_results_gu))
| proliferation_score |
0.2100151 |
1.3911470 |
0.8355183 |
2.4605491 |
gender |
GU |
| progression_score |
0.6787651 |
1.1529189 |
0.6620496 |
2.0649017 |
gender |
GU |
| stromal141_up |
0.1809123 |
0.7720693 |
0.5113234 |
1.1230869 |
gender |
GU |
| immune141_up |
0.1157470 |
0.7355648 |
0.4722463 |
1.0831048 |
gender |
GU |
| b_cells |
0.0411555 |
0.7652588 |
0.5496156 |
1.0421317 |
gender |
GU |
| t_cells |
0.0190872 |
0.6587721 |
0.4249717 |
0.9650018 |
gender |
GU |
Example 3: Custom Predictor Columns and Scaling
glm_results_custom <- get_glm(
these_predictions = results,
these_samples_metadata = sjodahl_2017_meta,
subtype_class = "5_class",
categorical_factor = "gender",
predictor_columns = c("b_cells", "proliferation_score"),
scale = 100
)
knitr::kable(head(glm_results_custom))
| b_cells |
0.6963593 |
0.9587575 |
0.8286159 |
1.113152 |
gender |
all |
| proliferation_score |
0.2876215 |
0.9349577 |
0.8038649 |
1.089235 |
gender |
all |
2. Survival Analysis with get_survival
The get_survival function provides a convenient
interface for running Cox proportional hazards models, allowing you to
estimate hazard ratios for molecular signatures or subtypes with respect
to clinical outcomes. The function expects survival time and event
columns in your metadata, and can be customized for different subtypes
or predictor sets.
Example 1: Cox Model for Overall Survival
surv_results_os <- get_survival(
these_predictions = results,
these_samples_metadata = sjodahl_2017_meta,
subtype_class = "5_class",
surv_time = "surv_os_time",
surv_event = "surv_os_event"
)
knitr::kable(head(surv_results_os))
| proliferation_score |
0.8545504 |
1.0081948 |
0.9239491 |
1.100122 |
all |
| progression_score |
0.9255769 |
0.9958385 |
0.9124072 |
1.086899 |
all |
| stromal141_up |
0.0950648 |
1.0719405 |
0.9879748 |
1.163042 |
all |
| immune141_up |
0.7804632 |
0.9886373 |
0.9122971 |
1.071365 |
all |
| b_cells |
0.2217137 |
0.9464709 |
0.8665334 |
1.033783 |
all |
| t_cells |
0.1117570 |
0.9315574 |
0.8536170 |
1.016614 |
all |
Example 2: Subtype-Specific Survival Analysis (e.g., Uro)
surv_results_uro <- get_survival(
these_predictions = results,
these_samples_metadata = sjodahl_2017_meta,
subtype_class = "5_class",
this_subtype = "Uro",
surv_time = "surv_os_time",
surv_event = "surv_os_event"
)
knitr::kable(head(surv_results_uro))
| proliferation_score |
0.8920954 |
0.9871613 |
0.8190416 |
1.189790 |
Uro |
| progression_score |
0.7033291 |
1.0365889 |
0.8615622 |
1.247172 |
Uro |
| stromal141_up |
0.1893854 |
1.1023689 |
0.9530485 |
1.275084 |
Uro |
| immune141_up |
0.8553808 |
0.9869615 |
0.8570494 |
1.136566 |
Uro |
| b_cells |
0.6284895 |
0.9635444 |
0.8289731 |
1.119961 |
Uro |
| t_cells |
0.2289869 |
0.9100363 |
0.7804668 |
1.061116 |
Uro |
Example 3: Custom Predictor Columns and Binning
surv_results_custom <- get_survival(
these_predictions = results,
these_samples_metadata = sjodahl_2017_meta,
subtype_class = "5_class",
surv_time = "surv_os_time",
surv_event = "surv_os_event",
predictor_columns = "proliferation_score",
n_bins = 5
)
knitr::kable(head(surv_results_custom))
| proliferation_score |
0.9871195 |
1.001409 |
0.844044 |
1.188114 |
all |
By leveraging get_glm and get_survival, you
can efficiently perform statistical and survival analyses on your
LundTaxR classification results, supporting robust clinical and
translational research workflows.