From f919a3152728396503c1d2ae9119b333e5f3d422 Mon Sep 17 00:00:00 2001 From: Jens Sauer Date: Mon, 16 Nov 2020 12:24:20 +0100 Subject: [PATCH 1/3] utils: Add sma_load_data() This function loads the data and adjust some wrong column types. It shoulb be used from all other scripts to load the data. It the same source data for all following calculations. The data is stored inside a 'tibble' from the 'tidyverse' package. --- utils.R | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/utils.R b/utils.R index 7d7bc48..c8c6105 100644 --- a/utils.R +++ b/utils.R @@ -3,6 +3,8 @@ # License: GPL version 3 # Jens Mathis Sauer (c) 2020 +library(tidyverse) + # # Write plot to filename # @@ -27,3 +29,47 @@ sma_plot_file <- function(fname, ftype, title_list, legend_list, fun, ...) { # hide "null device 1" in garbage garbage <- dev.off() } + +# +# Load secMalASCT data +# +# This loads the secMalASCT data from a CSV file and adjusts some +# columns to the correct type. +# +sma_load_data <- function(file) { + sma <- as_tibble(read.csv(file, header = TRUE)) + + # Type adjustments + sma$follow_up_multi <- as.logical(sma$follow_up_multi) + sma$nicotin_history <- as.logical(sma$nicotin_history) + sma$relapse_treatment_asct <- as.logical(sma$relapse_treatment_asct) + sma$relapse_treatment_chemotherapy <- as.logical(sma$relapse_treatment_chemotherapy) + sma$relapse_treatment_radiotherapy <- as.logical(sma$relapse_treatment_radiotherapy) + sma$relapse_treatment_surgery <- as.logical(sma$relapse_treatment_surgery) + + sma$pre_rt <- as.logical(sma$pre_rt) + sma$pre_rt_type <- as.factor(sma$pre_rt_type) + sma$post_rt <- as.logical(sma$post_rt) + sma$post_rt_type <- as.factor(sma$post_rt_type) + + sma$pre_alkylating_agents <- as.logical(sma$pre_alkylating_agents) + sma$pre_topoisomerase <- as.logical(sma$pre_topoisomerase) + sma$pre_anthracyclines <- as.logical(sma$pre_anthracyclines) + + sma$peri_alkylating_agents <- as.logical(sma$peri_alkylating_agents) + sma$peri_topoisomerase <- as.logical(sma$peri_topoisomerase) + sma$peri_anthracyclines <- as.logical(sma$peri_anthracyclines) + + sma$post_alkylating_agents <- as.logical(sma$post_alkylating_agents) + sma$post_topoisomerase <- as.logical(sma$post_topoisomerase) + sma$post_anthracyclines <- as.logical(sma$post_anthracyclines) + + sma$maintenance_treatment <- as.logical(sma$maintenance_treatment) + sma$maintenance_treatment_time <- as.integer(sma$maintenance_treatment_time) + sma$maintenance_treatment_type <- as.factor(sma$maintenance_treatment_type) + + sma$thalidomid <- as.logical(sma$thalidomid) + sma$bortezomib <- as.logical(sma$bortezomib) + + return(sma) +} From 27579452c3c96cf05a68df0df929764d1361e34c Mon Sep 17 00:00:00 2001 From: Jens Sauer Date: Mon, 16 Nov 2020 12:27:35 +0100 Subject: [PATCH 2/3] survival: Use new data load function Load the data with the new introduced function sma_load_data(). --- survival.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/survival.R b/survival.R index e55a243..5bc657f 100644 --- a/survival.R +++ b/survival.R @@ -6,7 +6,7 @@ library(survival) source("utils.R") -secmal <- read.csv2("current.csv", header=TRUE) +secmal <- sma_load_data("current.csv") # Setup survival object surv_dx <- Surv(time = secmal$event_time_dx, event = secmal$event_status) From d87d3143c27bcfa8a9dd66c9b181a1f40ac39c9f Mon Sep 17 00:00:00 2001 From: Jens Sauer Date: Mon, 16 Nov 2020 12:37:41 +0100 Subject: [PATCH 3/3] README: List tidyverse as used package Add 'tidyverse' to used package list in README. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5e6e865..4e984b1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ secMalASCT statistical analysis =============================== + +R packages used +--------------- +* tidyverse