From 65d41b2c2d820ca922f4ac06dc0e238d4eae7f2d Mon Sep 17 00:00:00 2001 From: xuewei cao <36172337+xueweic@users.noreply.github.com> Date: Wed, 23 Apr 2025 08:04:09 -0400 Subject: [PATCH 1/3] Update colocboost_plot.R --- R/colocboost_plot.R | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/R/colocboost_plot.R b/R/colocboost_plot.R index fcc56d4..cf31216 100644 --- a/R/colocboost_plot.R +++ b/R/colocboost_plot.R @@ -120,7 +120,7 @@ colocboost_plot <- function(cb_output, y = "log10p", y = y, points_color = points_color, cos_color = cos_color, ylim_each = ylim_each, title_specific = title_specific, outcome_legend_pos = outcome_legend_pos, outcome_legend_size = outcome_legend_size, - cos_legend_pos = cos_legend_pos, + cos_legend_pos = cos_legend_pos, plot_ucos = plot_ucos, show_variable = show_variable, lab_style = lab_style, axis_style = axis_style, title_style = title_style, ... ) @@ -467,6 +467,7 @@ get_input_plot <- function(cb_output, plot_cos_idx = NULL, "Zscores" = Z, "vcp" = vcp, "cos_vcp" = cos_vcp, + "ucos_cos_int_weights" = cos_vcp, "coef" = coef, "cos" = coloc_cos, "cos_hits" = coloc_hits, @@ -481,6 +482,7 @@ get_input_plot <- function(cb_output, plot_cos_idx = NULL, ucos <- ucos_details$ucos$ucos_index ucos_outcome_index <- ucos_details$ucos_outcomes$outcome_index ucos_hits <- lapply(ucos, function(x) x[[1]]) + weights <- ucos_details$ucos_weight # check inclusion of other options select_ucos <- 1:length(ucos) if (!is.null(plot_ucos_idx)) { @@ -502,6 +504,21 @@ get_input_plot <- function(cb_output, plot_cos_idx = NULL, plot_input$cos_hits <- c(plot_input$cos_hits, ucos_hits[select_ucos]) plot_input$coloc_index <- c(plot_input$coloc_index, ucos_outcome_index[select_ucos]) plot_input$select_cos <- c(plot_input$select_cos, ncos + select_ucos) + # add the recalibrated cos and ucos weights + ucos_weights <- lapply(1:cb_output$data_info$n_outcomes, function(l){ + pp <- which(sapply(ucos_outcome_index, function(oo) oo == l)) + w <- weights[pp] + w <- do.call(cbind, w) + 1 - apply(1-w, 1, prod) + }) + cos_vcp <- plot_input$cos_vcp + combined <- lapply(1:cb_output$data_info$n_outcomes, function(l){ + ucos_w <- ucos_weights[[l]] + cos_w <- cos_vcp[[l]] + 1 - (1-ucos_w)*(1-cos_w) + }) + names(combined) <- names(plot_input$cos_vcp) + plot_input$ucos_cos_int_weights <- combined } } @@ -602,6 +619,7 @@ plot_initial <- function(cb_plot_input, y = "log10p", outcome_legend_size = 1.5, outcome_legend_pos = "right", cos_legend_pos = "bottomleft", + plot_ucos = FALSE, show_variable = FALSE, lab_style = c(2, 1), axis_style = c(1, 1), @@ -643,8 +661,13 @@ plot_initial <- function(cb_plot_input, y = "log10p", plot_data <- cb_plot_input$Zscores ylab <- "Z score" } else if (y == "cos_vcp") { - plot_data <- cb_plot_input$cos_vcp - ylab <- "CoS-specific VCP" + if (plot_ucos){ + plot_data <- cb_plot_input$ucos_cos_int_weights + ylab <- "Analogous integrated VPA from CoS and uCoS" + } else { + plot_data <- cb_plot_input$cos_vcp + ylab <- "CoS-specific VCP" + } args$ylim <- c(0, 1) } else if (y == "vcp") { plot_data <- cb_plot_input$vcp From 44d9b9b9eaf18968bdfaf9942084cf81eb3755eb Mon Sep 17 00:00:00 2001 From: xuewei cao <36172337+xueweic@users.noreply.github.com> Date: Wed, 23 Apr 2025 08:14:03 -0400 Subject: [PATCH 2/3] Update colocboost_plot.R --- R/colocboost_plot.R | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/R/colocboost_plot.R b/R/colocboost_plot.R index cf31216..a0150e7 100644 --- a/R/colocboost_plot.R +++ b/R/colocboost_plot.R @@ -482,7 +482,6 @@ get_input_plot <- function(cb_output, plot_cos_idx = NULL, ucos <- ucos_details$ucos$ucos_index ucos_outcome_index <- ucos_details$ucos_outcomes$outcome_index ucos_hits <- lapply(ucos, function(x) x[[1]]) - weights <- ucos_details$ucos_weight # check inclusion of other options select_ucos <- 1:length(ucos) if (!is.null(plot_ucos_idx)) { @@ -505,11 +504,16 @@ get_input_plot <- function(cb_output, plot_cos_idx = NULL, plot_input$coloc_index <- c(plot_input$coloc_index, ucos_outcome_index[select_ucos]) plot_input$select_cos <- c(plot_input$select_cos, ncos + select_ucos) # add the recalibrated cos and ucos weights + weights <- ucos_details$ucos_weight ucos_weights <- lapply(1:cb_output$data_info$n_outcomes, function(l){ pp <- which(sapply(ucos_outcome_index, function(oo) oo == l)) - w <- weights[pp] - w <- do.call(cbind, w) - 1 - apply(1-w, 1, prod) + if (length(pp) == 0){ + return(rep(0, length(weights[[1]]))) + } else { + w <- weights[pp] + w <- do.call(cbind, w) + return(1 - apply(1-w, 1, prod)) + } }) cos_vcp <- plot_input$cos_vcp combined <- lapply(1:cb_output$data_info$n_outcomes, function(l){ @@ -663,7 +667,7 @@ plot_initial <- function(cb_plot_input, y = "log10p", } else if (y == "cos_vcp") { if (plot_ucos){ plot_data <- cb_plot_input$ucos_cos_int_weights - ylab <- "Analogous integrated VPA from CoS and uCoS" + ylab <- "Integrated VPA from CoS and uCoS" } else { plot_data <- cb_plot_input$cos_vcp ylab <- "CoS-specific VCP" From ec7cd046bf3f15b6eae82b0151609bdb1dd748d6 Mon Sep 17 00:00:00 2001 From: xuewei cao <36172337+xueweic@users.noreply.github.com> Date: Wed, 23 Apr 2025 08:27:50 -0400 Subject: [PATCH 3/3] Update Ambiguous_Colocalization.Rmd --- vignettes/Ambiguous_Colocalization.Rmd | 1 + 1 file changed, 1 insertion(+) diff --git a/vignettes/Ambiguous_Colocalization.Rmd b/vignettes/Ambiguous_Colocalization.Rmd index 814312d..9d8c4c6 100644 --- a/vignettes/Ambiguous_Colocalization.Rmd +++ b/vignettes/Ambiguous_Colocalization.Rmd @@ -109,6 +109,7 @@ To visulize the fine-mapping results, ```{r plot-susie} susieR::susie_plot(susie_eQTL, y = "PIP", pos = 2000:n_variables) susieR::susie_plot(susie_GWAS, y = "PIP", pos = 2000:n_variables) +``` # 3. Get the ambiguous colocalization results and summary