From 2075a4ca9291870a5c426abdd5790a3250fee6f6 Mon Sep 17 00:00:00 2001 From: Tiago Silva Date: Tue, 4 Oct 2022 11:12:23 -0400 Subject: [PATCH] #546 Updating days_to_follow_up and vital status Should we add a parameter to control this update? --- R/clinical.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/R/clinical.R b/R/clinical.R index a0b6547f5..10087c151 100644 --- a/R/clinical.R +++ b/R/clinical.R @@ -540,6 +540,22 @@ GDCprepare_clinic <- function( clin$primary_pathology <- NULL } + # Update clinical data with follow-ups: days_to_last_followup and vital_status + message("Updating days_to_last_followup and vital_status from follow_up information using last entry") + followup <- parseFollowup(files,xpath,clinical.info) + + followup_last <- followup %>% dplyr::group_by(bcr_patient_barcode) %>% dplyr::summarise( + days_to_last_followup = max(as.numeric(days_to_last_followup),na.rm = TRUE), + vital_status = vital_status[ + ifelse( + any(followup$days_to_last_followup %in% ""), + which(followup$days_to_last_followup %in% ""), + which.max(days_to_last_followup) + ) + ] + ) + clin$days_to_last_followup <- followup_last$days_to_last_followup[match(clin$bcr_patient_barcode,followup_last$bcr_patient_barcode)] + clin$vital_status <- followup_last$vital_status[match(clin$bcr_patient_barcode,followup_last$bcr_patient_barcode)] } if (tolower(clinical.info) == "sample") {