Skip to content

Commit

Permalink
#546 Updating days_to_follow_up and vital status
Browse files Browse the repository at this point in the history
Should we add a parameter to control this update?
  • Loading branch information
Tiago Silva authored and Tiago Silva committed Oct 4, 2022
1 parent 3d99f1c commit 2075a4c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions R/clinical.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 2075a4c

Please sign in to comment.