@@ -303,7 +303,7 @@ GDCquery_clinic <- function(
303
303
304
304
if (" follow_ups" %in% colnames(results )){
305
305
follow_ups <- rbindlist(lapply(results $ follow_ups , function (x ) if (is.null(x )) data.frame (NA ) else x ),fill = T )
306
- follow_ups $ submitter_id <- gsub(" _follow_up*" ," " , follow_ups $ submitter_id )
306
+ follow_ups $ submitter_id <- gsub(" _follow_up. *" ," " , follow_ups $ submitter_id )
307
307
308
308
# we are getting more results than what we should
309
309
follow_ups <- follow_ups [follow_ups $ submitter_id %in% df $ submitter_id ,]
@@ -315,7 +315,42 @@ GDCquery_clinic <- function(
315
315
days_to_last_follow_up = ifelse(any(! is.na(days_to_follow_up )),max(days_to_follow_up ,na.rm = TRUE ),NA )
316
316
)
317
317
318
- df <- dplyr :: full_join(df ,follow_ups_last , by = " submitter_id" )
318
+ follow_ups_last <- follow_ups %> %
319
+ dplyr :: select(
320
+ c(
321
+ submitter_id ,
322
+ days_to_follow_up ,
323
+ # days_to_recurrence,
324
+ # progression_or_recurrence_type,
325
+ disease_response
326
+ )
327
+ ) %> %
328
+ dplyr :: filter(! is.na(submitter_id ), ! is.na(days_to_follow_up )) %> %
329
+ dplyr :: group_by(submitter_id ) %> %
330
+ dplyr :: filter(dplyr :: row_number() == which.max(days_to_follow_up )) %> %
331
+ dplyr :: ungroup() %> %
332
+ dplyr :: rename_at(disease_response ,.funs = function (x ) paste0(" follow_ups_" ,x ))
333
+
334
+ df <- dplyr :: full_join(df , follow_ups_last , by = " submitter_id" )
335
+
336
+ # Keep all follow ups
337
+ # follow_ups <- follow_ups %>%
338
+ # dplyr::select(
339
+ # c(
340
+ # submitter_id,
341
+ # days_to_follow_up,
342
+ # days_to_recurrence,
343
+ # progression_or_recurrence_type,
344
+ # disease_response
345
+ # )
346
+ # ) %>%
347
+ # dplyr::group_by(submitter_id) %>%
348
+ # dplyr::summarise(
349
+ # across(everything(),~ paste(., collapse = ";"))
350
+ # ) %>% dplyr::rename_at(-1,.funs = function(x) paste0("follow_ups_",x))
351
+ #
352
+ # df <- dplyr::full_join(df, follow_ups, by = "submitter_id")
353
+
319
354
}
320
355
321
356
if ( " treatments" %in% colnames(df )) {
0 commit comments