From d87c7b81934062f2ab495334b38dcccb81342af9 Mon Sep 17 00:00:00 2001 From: yun Date: Sun, 25 Dec 2022 16:07:49 +0800 Subject: [PATCH 1/2] fix error: when `drv_to_cancel` has only 0 length --- R/remove_patients.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/remove_patients.R b/R/remove_patients.R index ff2d5cc..da73f37 100644 --- a/R/remove_patients.R +++ b/R/remove_patients.R @@ -46,10 +46,9 @@ remove_patients = function(x, if(length(drv_to_cancel) > 0) { message(paste(drv_to_cancel, collapse = ', '), ": driver events that now are found in only one patient, will be now removed ...") + x = remove_drivers(x, drv_to_cancel, check = FALSE) } - x = remove_drivers(x, drv_to_cancel, check = FALSE) - # if has clusters, force to recompute if(has_clusters(x)) { message("- The cohort has clusters which will be cancelled, please re-compute the clusters ...") From d4f31305d5233a06da2eb334482963cdc73c5887 Mon Sep 17 00:00:00 2001 From: yun Date: Sun, 25 Dec 2022 16:57:44 +0800 Subject: [PATCH 2/2] fix error when `p1_IT` or `p2_IT` is NULL --- R/revolver_cluster.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/R/revolver_cluster.R b/R/revolver_cluster.R index a0ec574..09e7f54 100644 --- a/R/revolver_cluster.R +++ b/R/revolver_cluster.R @@ -83,11 +83,12 @@ revolver_cluster = function( if (pb.status) pb$tick()$print() # Both patient have a transfer that we take and augment with E - p1_IT = ITransfer(x, patients[p1], data = 'fits', type = 'drivers') %>% - left_join(E, by = c('from', 'to')) + p1_IT = ITransfer(x, patients[p1], data = 'fits', type = 'drivers') + if (!is.null(p1_IT)) p1_IT <- left_join(p1_IT, E, by = c('from', 'to')) - p2_IT = ITransfer(x, patients[p2], data = 'fits', type = 'drivers') %>% - left_join(E, by = c('from', 'to')) + p2_IT = ITransfer(x, patients[p2], data = 'fits', type = 'drivers') + if (!is.null(p2_IT)) p2_IT <- left_join(p2_IT, E, by = c('from', 'to')) + # The distance is the absolute value of non-shared edges distances[patients[p1], patients[p2]] = bind_rows(p1_IT, p2_IT) %>%