diff --git a/NAMESPACE b/NAMESPACE index 98c00be..0ae59be 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export(colocboost) export(colocboost_plot) export(get_cormat) +export(get_cos) export(get_cos_summary) export(get_strong_colocalization) importFrom(grDevices,adjustcolor) diff --git a/R/colocboost.R b/R/colocboost.R index 2e56ad8..ec8c822 100644 --- a/R/colocboost.R +++ b/R/colocboost.R @@ -95,10 +95,29 @@ #' \item{cos_details}{A object with all information for colocalization results.} #' \item{data_info}{A object with detailed information from input data} #' \item{model_info}{A object with detailed information for colocboost model} +#' +#' @examples +#' # colocboost example +#' set.seed(1) +#' N = 1000 +#' P = 100 +#' # Generate X with LD structure +#' sigma <- 0.9^abs(outer(1:P, 1:P, "-")) +#' X <- MASS::mvrnorm(N, rep(0, P), sigma) +#' colnames(X) <- paste0("SNP", 1:P) +#' L = 3 +#' true_beta <- matrix(0, P, L) +#' true_beta[5, 1] <- 0.5 # SNP5 affects trait 1 +#' true_beta[5, 2] <- 0.4 # SNP5 also affects trait 2 (colocalized) +#' true_beta[10, 2] <- 0.3 # SNP10 only affects trait 2 +#' true_beta[20, 3] <- 0.6 # SNP20 only affects trait 3 +#' Y <- matrix(0, N, L) +#' for (l in 1:L){ Y[, l] <- X %*% true_beta[, l] + rnorm(N, 0, 1) } +#' res <- colocboost(X = X, Y = Y) #' +#' @family colocboost #' @importFrom stats na.omit #' @export - colocboost <- function(X = NULL, Y = NULL, # individual data sumstat = NULL, LD = NULL, # summary statistics: either Z, bhat, sebhat, N, var_Y, ###### - index dict for X match multiple Y / LD match multiple sumstat diff --git a/R/colocboost_inference.R b/R/colocboost_inference.R index e68abb3..44b7979 100644 --- a/R/colocboost_inference.R +++ b/R/colocboost_inference.R @@ -34,8 +34,7 @@ colocboost_post_inference <- function() { #' #' @return A correlation matrix (LD matrix). #' -#' @rdname colocboost_post_inference -#' @keywords cb_post_inference +#' @family colocboost_utilities #' @export get_cormat <- function(X, intercepte = FALSE) { X <- t(X) diff --git a/R/colocboost_output.R b/R/colocboost_output.R index ea91655..002c761 100644 --- a/R/colocboost_output.R +++ b/R/colocboost_output.R @@ -7,7 +7,7 @@ #' @param cb_output Output object from `colocboost` analysis #' @param outcome_names Optional vector of names of outcomes, which has the same order as Y in the original analysis. #' @param interest_outcome Optional vector specifying a subset of outcomes from \code{outcome_names} to focus on. When provided, only colocalization events that include at least one of these outcomes will be returned. -#' @param gene_name Optional character string. When provided, adds a column with this gene name to the output table for easier filtering in downstream analyses. +#' @param region_name Optional character string. When provided, adds a column with this gene name to the output table for easier filtering in downstream analyses. #' #' @return A summary table for colocalization events with the following columns: #' \item{focal_outcome}{The focal outcome being analyzed if exists. Otherwise, it is \code{FALSE}.} @@ -23,12 +23,12 @@ #' \item{colocalized_variables}{List of colocalized variables} #' \item{colocalized_variables_vcp}{Variant colocalization probabilities for all colocalized variables} #' -#' @keywords cb_get_functions +#' @family colocboost_inference #' @export get_cos_summary <- function(cb_output, outcome_names = NULL, interest_outcome = NULL, - gene_name = NULL) { + region_name = NULL) { if (!inherits(cb_output, "colocboost")) { stop("Input must from colocboost output!") } @@ -65,8 +65,8 @@ get_cos_summary <- function(cb_output, summary_table[, 10] <- unlist(sapply(coloc_sets, function(tmp) paste0(tmp, collapse = "; "))) summary_table[, 11] <- unlist(sapply(cb_output$cos_details$cos$cos_variables, function(tmp) paste0(tmp, collapse = "; "))) summary_table[, 12] <- unlist(sapply(coloc_sets, function(tmp) paste0(vcp[tmp], collapse = "; "))) - if (!is.null(gene_name)) { - summary_table$gene_name <- gene_name + if (!is.null(region_name)) { + summary_table$region_name <- region_name } # - if focal colocalization focal_outcome_idx <- which(cb_output$data_info$outcome_info$is_focal) @@ -128,7 +128,7 @@ get_cos_summary <- function(cb_output, #' \item{data_info}{A object with detailed information from input data} #' \item{model_info}{A object with detailed information for colocboost model} #' -#' @keywords cb_get_functions +#' @family colocboost_inference #' @export get_strong_colocalization <- function(cb_output, cos_npc_cutoff = 0.5, @@ -359,22 +359,22 @@ get_strong_colocalization <- function(cb_output, #' #' @param cb_output Output object from `colocboost` analysis #' @param outcome_names Optional vector of names of outcomes, which has the same order as Y in the original analysis. -#' @param gene_name Optional character string. When provided, adds a column with this gene name to the output table for easier filtering in downstream analyses. +#' @param region_name Optional character string. When provided, adds a column with this gene name to the output table for easier filtering in downstream analyses. #' #' @return A summary table for fine-mapped events with the following columns: #' \item{outcomes}{Outcomes analyzed } #' \item{ucos_id}{Unique identifier for fine-mapped confidence sets } #' \item{purity}{Minimum absolute correlation of variables with in fine-mapped confidence sets } -#' \item{top_variable}{The variable with highest posterior inclusion probability (PIP) } -#' \item{top_variable_pip}{Posterior inclusion probability (PIP) for the top variable} +#' \item{top_variable}{The variable with highest variant-level probability of association (VPA) } +#' \item{top_variable_vpa}{Variant-level probability of association (VPA) for the top variable} #' \item{n_variables}{Number of variables in colocalization confidence set (CoS)} #' \item{ucos_index}{Indices of fine-mapped variables} #' \item{ucos_variables}{List of fine-mapped variables} -#' \item{ucos_variables_pip}{Posterior inclusion probability (PIP) for all fine-mapped variables} +#' \item{ucos_variables_vpa}{Variant-level probability of association (VPA) for all fine-mapped variables} #' -#' @keywords cb_get_functions +#' @family colocboost_inference #' @noRd -get_ucos_summary <- function(cb_output, outcome_names = NULL, gene_name = NULL) { +get_ucos_summary <- function(cb_output, outcome_names = NULL, region_name = NULL) { if (!inherits(cb_output, "colocboost")) { stop("Input must from colocboost object!") } @@ -385,26 +385,26 @@ get_ucos_summary <- function(cb_output, outcome_names = NULL, gene_name = NULL) if (!is.null(outcome_names)) { cs_outcome <- outcome_names } - pip <- as.numeric(cb_output$pip) + vpa <- as.numeric(cb_output$vpa) summary_table <- matrix(NA, nrow = length(specific_cs$ucos$ucos_index), ncol = 9) colnames(summary_table) <- c( "outcomes", "ucos_id", "purity", - "top_variable", "top_variable_pip", "n_variables", "ucos_index", - "ucos_variables", "ucos_variables_pip" + "top_variable", "top_variable_vpa", "n_variables", "ucos_index", + "ucos_variables", "ucos_variables_vpa" ) summary_table <- as.data.frame(summary_table) summary_table[, 1] <- cs_outcome[unlist(specific_cs$ucos_outcomes$outcome_index)] summary_table[, 2] <- names(specific_cs$ucos$ucos_index) summary_table[, 3] <- as.numeric(diag(as.matrix(specific_cs$ucos_purity$min_abs_cor))) summary_table[, 4] <- unlist(sapply(specific_cs$ucos$ucos_variables, function(tmp) tmp[1])) - summary_table[, 5] <- sapply(specific_cs$ucos$ucos_index, function(tmp) max(pip[tmp])) + summary_table[, 5] <- sapply(specific_cs$ucos$ucos_index, function(tmp) max(vpa[tmp])) summary_table[, 6] <- as.numeric(sapply(specific_cs$ucos$ucos_index, length)) summary_table[, 7] <- unlist(sapply(specific_cs$ucos$ucos_index, function(tmp) paste0(tmp, collapse = "; "))) summary_table[, 8] <- unlist(sapply(specific_cs$ucos$ucos_variables, function(tmp) paste0(tmp, collapse = "; "))) - summary_table[, 9] <- unlist(sapply(specific_cs$ucos$ucos_index, function(tmp) paste0(pip[tmp], collapse = "; "))) - if (!is.null(gene_name)) { - summary_table$gene_name <- gene_name + summary_table[, 9] <- unlist(sapply(specific_cs$ucos$ucos_index, function(tmp) paste0(vpa[tmp], collapse = "; "))) + if (!is.null(region_name)) { + summary_table$region_name <- region_name } } else { summary_table <- NULL @@ -413,9 +413,17 @@ get_ucos_summary <- function(cb_output, outcome_names = NULL, gene_name = NULL) } #' Extract CoS simply change the coverage without checking purity -#' @keywords cb_get_functions -#' @noRd -get_cos_different_coverage <- function(cb_output, coverage = 0.95) { +#' +#' @description `get_cos` get the colocalization confidence sets (CoS) with different coverage. +#' +#' @param cb_output Output object from `colocboost` analysis +#' @param coverage A number between 0 and 1 specifying the \dQuote{coverage} of the estimated colocalization confidence sets (CoS) (default is 0.95). +#' +#' @return A list of indices of variables in each CoS. +#' +#' @family colocboost_utilities +#' @export +get_cos <- function(cb_output, coverage = 0.95) { cos_vcp <- cb_output$cos_details$cos_vcp cos_diff_coverage <- lapply(cos_vcp, function(w) { unlist(get_in_cos(w, coverage = coverage)) diff --git a/R/colocboost_plot.R b/R/colocboost_plot.R index 7841f18..15f0616 100644 --- a/R/colocboost_plot.R +++ b/R/colocboost_plot.R @@ -6,7 +6,7 @@ #' #' @param cb_output Output object from `colocboost` analysis #' @param y Specifies the y-axis values, default is "log10p" for -log10 transformed marginal association p-values. -#' @param pos Optional plotting range of x-axis to zoom in to a specific region. +#' @param grange Optional plotting range of x-axis to zoom in to a specific region. #' @param plot_focal_only Logical, if TRUE only plots colocalization with focal outcome, default is FALSE. #' @param plot_cos_idx Optional indices of CoS to plot #' @param outcome_idx Optional indices of outcomes to include in the plot. \code{outcome_idx=NULL} to plot only the outcomes having colocalization. @@ -17,7 +17,7 @@ #' @param outcome_names Optional vector of outcomes names for the subtitle of each figure. \code{outcome_names=NULL} for the outcome name shown in \code{data_info}. #' @param plot_cols Number of columns in the plot grid, default is 2. If you have many colocalization. please consider increasing this. #' @param variant_coord Logical, if TRUE uses variant coordinates on x-axis, default is FALSE. This is required the variable names including position information. -#' @param show_hits Logical, if TRUE shows top variables for each CoS, default is FALSE +#' @param show_top_variables Logical, if TRUE shows top variables for each CoS, default is FALSE #' @param show_cos_to_uncoloc Logical, if TRUE shows colocalization to uncolocalized outcomes to diagnose, default is FALSE #' @param show_cos_to_uncoloc_idx Optional indices for showing CoS to all uncolocalized outcomes #' @param show_cos_to_uncoloc_outcome Optional outcomes for showing CoS to uncolocalized outcomes @@ -37,11 +37,11 @@ #' @importFrom utils head tail #' @importFrom graphics abline axis legend mtext par points text #' @importFrom grDevices adjustcolor -#' -#' @keywords cb_plot +#' +#' @family colocboost_plot #' @export colocboost_plot <- function(cb_output, y = "log10p", - pos = NULL, + grange = NULL, plot_focal_only = FALSE, plot_cos_idx = NULL, outcome_idx = NULL, @@ -52,7 +52,7 @@ colocboost_plot <- function(cb_output, y = "log10p", outcome_names = NULL, plot_cols = 2, variant_coord = FALSE, - show_hits = FALSE, + show_top_variables = FALSE, show_cos_to_uncoloc = FALSE, show_cos_to_uncoloc_idx = NULL, show_cos_to_uncoloc_outcome = NULL, @@ -91,20 +91,20 @@ colocboost_plot <- function(cb_output, y = "log10p", ) colocboost_plot_basic <- function(cb_plot_input, cb_plot_init, - outcome_idx = NULL, pos = NULL, + outcome_idx = NULL, grange = NULL, plot_cols = 2, add_vertical = FALSE, add_vertical_idx = NULL, - show_hits = TRUE, + show_top_variables = TRUE, ...) { args <- list(...) args <- c(args, cb_plot_init[c("xlab", "ylab")]) args$col <- cb_plot_init$bg - if (is.null(pos)) { + if (is.null(grange)) { args$x <- cb_plot_init$x y <- cb_plot_init$y } else { - args$x <- cb_plot_init$x[pos] - y <- lapply(cb_plot_init$y, function(yy) yy[pos]) + args$x <- cb_plot_init$x[grange] + y <- lapply(cb_plot_init$y, function(yy) yy[grange]) } args$pch <- cb_plot_init$pch args$cex.axis <- cb_plot_init$axis_size @@ -199,7 +199,7 @@ colocboost_plot <- function(cb_output, y = "log10p", x0 <- intersect(args$x, cs) y1 <- args$y[match(x0, args$x)] points(x0, y1, pch = 21, bg = legend_text$col[i.cs], col = NA, cex = 2.5, lwd = 2.5) - if (show_hits) { + if (show_top_variables) { # add the hits points with "red" cs_hits <- as.numeric(cb_plot_input$cos_hits[[i.cs]]) x_hits <- intersect(args$x, cs_hits) @@ -250,10 +250,10 @@ colocboost_plot <- function(cb_output, y = "log10p", } colocboost_plot_basic(cb_plot_input, cb_plot_init, - pos = pos, + grange = grange, outcome_idx = outcome_idx, plot_cols = plot_cols, add_vertical = add_vertical, add_vertical_idx = add_vertical_idx, - show_hits = show_hits, + show_top_variables = show_top_variables, ... ) } @@ -378,7 +378,8 @@ get_input_plot <- function(cb_output, plot_cos_idx = NULL, "coef" = coef, "cos" = coloc_cos, "cos_hits" = coloc_hits, - "coloc_index" = coloc_index + "coloc_index" = coloc_index, + "select_cos" = select_cs ) # check if plot cos to uncolocalized outcome @@ -493,7 +494,7 @@ plot_initial <- function(cb_plot_input, y = "log10p", # cos_color <- c("#1F70A9", "#33A02C", "#CAB2D6", "#EA7827") } - args$col <- cos_color + args$col <- cos_color[cb_plot_input$select_cos] # - set data and x-lab and y-lab if (y == "log10p") { diff --git a/R/data.R b/R/data.R index 047d996..a094387 100644 --- a/R/data.R +++ b/R/data.R @@ -10,6 +10,7 @@ #' \item{TrueCausalVariants}{List of causal variants} #' } #' @source See Cao et. al. 2025 for details. TO-DO-LIST +#' @family colocboost_data "Ind_5traits" #' Summary level data for 5 traits @@ -23,6 +24,7 @@ #' \item{TrueCausalVariants}{List of causal variants} #' } #' @source See Cao et. al. 2025 for details. TO-DO-LIST +#' @family colocboost_data "Sumstat_5traits" @@ -38,6 +40,7 @@ #' \item{TrueCausalVariants}{List of causal variants} #' } #' @source See Cao et. al. 2025 for details. TO-DO-LIST +#' @family colocboost_data "Heterogeneous_Effect" @@ -53,6 +56,7 @@ #' \item{TrueCausalVariants}{List of causal variants} #' } #' @source See Cao et. al. 2025 for details. TO-DO-LIST +#' @family colocboost_data "Weaker_GWAS_Effect" @@ -68,4 +72,5 @@ #' \item{TrueCausalVariants}{List of causal variants} #' } #' @source See Cao et. al. 2025 for details. TO-DO-LIST +#' @family colocboost_data "Non_Causal_Strongest_Marginal" diff --git a/_pkgdown.yml b/_pkgdown.yml index bf4cfdc..2015fba 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -2,3 +2,29 @@ url: https://statfungen.github.io/colocboost template: bootstrap: 5 + +reference: + - title: "Example Data" + desc: "Example datasets for demonstration and testing" + contents: + - has_concept("colocboost_data") + + - title: "ColocBoost Main Function" + desc: "Core functions for colocalization analysis" + contents: + - has_concept("colocboost") + + - title: "Post Inference" + desc: "Functions for post-analysis inference of ColocBoost results" + contents: + - has_concept("colocboost_inference") + + - title: "Visualization" + desc: "Functions for visualizing ColocBoost results" + contents: + - has_concept("colocboost_plot") + + - title: "Utilities" + desc: "Helper functions and utilities" + contents: + - has_concept("colocboost_utilities") diff --git a/man/Heterogeneous_Effect.Rd b/man/Heterogeneous_Effect.Rd index 99a6f6f..45ae8b2 100644 --- a/man/Heterogeneous_Effect.Rd +++ b/man/Heterogeneous_Effect.Rd @@ -24,4 +24,12 @@ Heterogeneous_Effect \description{ An example dataset with simulated statistics and LD for 5 traits } +\seealso{ +Other colocboost_data: +\code{\link{Ind_5traits}}, +\code{\link{Non_Causal_Strongest_Marginal}}, +\code{\link{Sumstat_5traits}}, +\code{\link{Weaker_GWAS_Effect}} +} +\concept{colocboost_data} \keyword{datasets} diff --git a/man/Ind_5traits.Rd b/man/Ind_5traits.Rd index 6bf0c09..5d1e6f1 100644 --- a/man/Ind_5traits.Rd +++ b/man/Ind_5traits.Rd @@ -24,4 +24,12 @@ Ind_5traits \description{ An example dataset with simulated genotypes and outcomes for 5 traits } +\seealso{ +Other colocboost_data: +\code{\link{Heterogeneous_Effect}}, +\code{\link{Non_Causal_Strongest_Marginal}}, +\code{\link{Sumstat_5traits}}, +\code{\link{Weaker_GWAS_Effect}} +} +\concept{colocboost_data} \keyword{datasets} diff --git a/man/Non_Causal_Strongest_Marginal.Rd b/man/Non_Causal_Strongest_Marginal.Rd index 147ff55..8f6b848 100644 --- a/man/Non_Causal_Strongest_Marginal.Rd +++ b/man/Non_Causal_Strongest_Marginal.Rd @@ -24,4 +24,12 @@ Non_Causal_Strongest_Marginal \description{ An example dataset with simulated statistics and LD for 5 traits } +\seealso{ +Other colocboost_data: +\code{\link{Heterogeneous_Effect}}, +\code{\link{Ind_5traits}}, +\code{\link{Sumstat_5traits}}, +\code{\link{Weaker_GWAS_Effect}} +} +\concept{colocboost_data} \keyword{datasets} diff --git a/man/Sumstat_5traits.Rd b/man/Sumstat_5traits.Rd index 954fa66..068b26e 100644 --- a/man/Sumstat_5traits.Rd +++ b/man/Sumstat_5traits.Rd @@ -23,4 +23,12 @@ Sumstat_5traits \description{ An example dataset with simulated statistics and LD for 5 traits } +\seealso{ +Other colocboost_data: +\code{\link{Heterogeneous_Effect}}, +\code{\link{Ind_5traits}}, +\code{\link{Non_Causal_Strongest_Marginal}}, +\code{\link{Weaker_GWAS_Effect}} +} +\concept{colocboost_data} \keyword{datasets} diff --git a/man/Weaker_GWAS_Effect.Rd b/man/Weaker_GWAS_Effect.Rd index ca5b6b3..734a889 100644 --- a/man/Weaker_GWAS_Effect.Rd +++ b/man/Weaker_GWAS_Effect.Rd @@ -24,4 +24,12 @@ Weaker_GWAS_Effect \description{ An example dataset with simulated statistics and LD for 5 traits } +\seealso{ +Other colocboost_data: +\code{\link{Heterogeneous_Effect}}, +\code{\link{Ind_5traits}}, +\code{\link{Non_Causal_Strongest_Marginal}}, +\code{\link{Sumstat_5traits}} +} +\concept{colocboost_data} \keyword{datasets} diff --git a/man/colocboost.Rd b/man/colocboost.Rd index a05ad1e..3a20304 100644 --- a/man/colocboost.Rd +++ b/man/colocboost.Rd @@ -12,8 +12,8 @@ colocboost( dict_YX = NULL, dict_sumstatLD = NULL, outcome_names = NULL, - target_outcome_idx = NULL, - target_outcome_variables = TRUE, + focal_outcome_idx = NULL, + focal_outcome_variables = TRUE, overlap_variables = FALSE, intercept = TRUE, standardize = TRUE, @@ -32,7 +32,7 @@ colocboost( jk_equiv_loglik = 1, coloc_thresh = 0.1, lambda = 0.5, - lambda_target_outcome = 1, + lambda_focal_outcome = 1, func_simplex = "LD_z2z", func_multi_test = "lfdr", stop_null = 1, @@ -86,9 +86,9 @@ The innovation: do not provide the same matrix in \code{LD} to reduce the comput \item{outcome_names}{The names of outcomes, which has the same order for Y.} -\item{target_outcome_idx}{The index of the target outcome if perform GWAS-xQTL ColocBoost} +\item{focal_outcome_idx}{The index of the focal outcome if perform GWAS-xQTL ColocBoost} -\item{target_outcome_variables}{If \code{target_outcome_variables = TRUE}, only consider the variables exist in the target outcome.} +\item{focal_outcome_variables}{If \code{focal_outcome_variables = TRUE}, only consider the variables exist in the focal outcome.} \item{overlap_variables}{If \code{overlap_variables = TRUE}, only perform colocalization in the overlapped region.} @@ -127,7 +127,7 @@ we need to have the higher learning rate to improve the computational efficiency \item{lambda}{The ratio [0,1] for z^2 and z in fun_prior simplex, defult is 0.5} -\item{lambda_target_outcome}{The ratio for z^2 and z in fun_prior simplex for the target outcome, default is 1} +\item{lambda_focal_outcome}{The ratio for z^2 and z in fun_prior simplex for the focal outcome, default is 1} \item{func_simplex}{The data-driven local association simplex \eqn{\delta} for smoothing the weights. Default is "LD_z2z" is the elastic net for z-score and also weighted by LD.} @@ -210,3 +210,24 @@ There is an additional step to help merge the confidence sets with small \code{b (default is 0.8) but within the same locus. This step addresses potential instabilities in linkage disequilibrium (LD) estimation that may arise from small sample sizes or discrepancies in minor allele frequencies (MAF) across different confidence sets. } +\examples{ +# colocboost example +set.seed(1) +N = 1000 +P = 100 +# Generate X with LD structure +sigma <- 0.9^abs(outer(1:P, 1:P, "-")) +X <- MASS::mvrnorm(N, rep(0, P), sigma) +colnames(X) <- paste0("SNP", 1:P) +L = 3 +true_beta <- matrix(0, P, L) +true_beta[5, 1] <- 0.5 # SNP5 affects trait 1 +true_beta[5, 2] <- 0.4 # SNP5 also affects trait 2 (colocalized) +true_beta[10, 2] <- 0.3 # SNP10 only affects trait 2 +true_beta[20, 3] <- 0.6 # SNP20 only affects trait 3 +Y <- matrix(0, N, L) +for (l in 1:L){ Y[, l] <- X \%*\% true_beta[, l] + rnorm(N, 0, 1) } +res <- colocboost(X = X, Y = Y) + +} +\concept{colocboost} diff --git a/man/colocboost_plot.Rd b/man/colocboost_plot.Rd index 27c1475..318d514 100644 --- a/man/colocboost_plot.Rd +++ b/man/colocboost_plot.Rd @@ -7,8 +7,8 @@ colocboost_plot( cb_output, y = "log10p", - pos = NULL, - plot_target_only = FALSE, + grange = NULL, + plot_focal_only = FALSE, plot_cos_idx = NULL, outcome_idx = NULL, points_color = "grey80", @@ -18,7 +18,7 @@ colocboost_plot( outcome_names = NULL, plot_cols = 2, variant_coord = FALSE, - show_hits = FALSE, + show_top_variables = FALSE, show_cos_to_uncoloc = FALSE, show_cos_to_uncoloc_idx = NULL, show_cos_to_uncoloc_outcome = NULL, @@ -39,9 +39,9 @@ colocboost_plot( \item{y}{Specifies the y-axis values, default is "log10p" for -log10 transformed marginal association p-values.} -\item{pos}{Optional plotting range of x-axis to zoom in to a specific region.} +\item{grange}{Optional plotting range of x-axis to zoom in to a specific region.} -\item{plot_target_only}{Logical, if TRUE only plots colocalization with target outcome, default is FALSE.} +\item{plot_focal_only}{Logical, if TRUE only plots colocalization with focal outcome, default is FALSE.} \item{plot_cos_idx}{Optional indices of CoS to plot} @@ -61,7 +61,7 @@ colocboost_plot( \item{variant_coord}{Logical, if TRUE uses variant coordinates on x-axis, default is FALSE. This is required the variable names including position information.} -\item{show_hits}{Logical, if TRUE shows top variables for each CoS, default is FALSE} +\item{show_top_variables}{Logical, if TRUE shows top variables for each CoS, default is FALSE} \item{show_cos_to_uncoloc}{Logical, if TRUE shows colocalization to uncolocalized outcomes to diagnose, default is FALSE} @@ -95,4 +95,4 @@ Visualization plot for each colcoalization event. \description{ \code{colocboost_plot} generates visualization plots for colocalization events from a ColocBoost analysis. } -\keyword{cb_plot} +\concept{colocboost_plot} diff --git a/man/colocboost_post_inference.Rd b/man/get_cormat.Rd similarity index 86% rename from man/colocboost_post_inference.Rd rename to man/get_cormat.Rd index 6703791..1c36951 100644 --- a/man/colocboost_post_inference.Rd +++ b/man/get_cormat.Rd @@ -17,4 +17,8 @@ A correlation matrix (LD matrix). \description{ This function calculates the correlation matrix (LD matrix) from individual level data. } -\keyword{cb_post_inference} +\seealso{ +Other colocboost_utilities: +\code{\link{get_cos}()} +} +\concept{colocboost_utilities} diff --git a/man/get_cos.Rd b/man/get_cos.Rd new file mode 100644 index 0000000..a38068f --- /dev/null +++ b/man/get_cos.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/colocboost_output.R +\name{get_cos} +\alias{get_cos} +\title{Extract CoS simply change the coverage without checking purity} +\usage{ +get_cos(cb_output, coverage = 0.95) +} +\arguments{ +\item{cb_output}{Output object from \code{colocboost} analysis} + +\item{coverage}{A number between 0 and 1 specifying the \dQuote{coverage} of the estimated colocalization confidence sets (CoS) (default is 0.95).} +} +\value{ +A list of indices of variables in each CoS. +} +\description{ +\code{get_cos} get the colocalization confidence sets (CoS) with different coverage. +} +\seealso{ +Other colocboost_utilities: +\code{\link{get_cormat}()} +} +\concept{colocboost_utilities} diff --git a/man/get_cos_summary.Rd b/man/get_cos_summary.Rd index 042efa8..bd3a193 100644 --- a/man/get_cos_summary.Rd +++ b/man/get_cos_summary.Rd @@ -8,7 +8,7 @@ get_cos_summary( cb_output, outcome_names = NULL, interest_outcome = NULL, - gene_name = NULL + region_name = NULL ) } \arguments{ @@ -18,11 +18,11 @@ get_cos_summary( \item{interest_outcome}{Optional vector specifying a subset of outcomes from \code{outcome_names} to focus on. When provided, only colocalization events that include at least one of these outcomes will be returned.} -\item{gene_name}{Optional character string. When provided, adds a column with this gene name to the output table for easier filtering in downstream analyses.} +\item{region_name}{Optional character string. When provided, adds a column with this gene name to the output table for easier filtering in downstream analyses.} } \value{ A summary table for colocalization events with the following columns: -\item{target_outcome}{The target outcome being analyzed if exists. Otherwise, it is \code{FALSE}.} +\item{focal_outcome}{The focal outcome being analyzed if exists. Otherwise, it is \code{FALSE}.} \item{colocalized_outcomes}{Colocalized outcomes for colocalization confidence set (CoS) } \item{cos_id}{Unique identifier for colocalization confidence set (CoS) } \item{purity}{Minimum absolute correlation of variables with in colocalization confidence set (CoS) } @@ -38,4 +38,8 @@ A summary table for colocalization events with the following columns: \description{ \code{get_cos_summary} get the colocalization summary table with or without the outcomes of interest. } -\keyword{cb_get_functions} +\seealso{ +Other colocboost_inference: +\code{\link{get_strong_colocalization}()} +} +\concept{colocboost_inference} diff --git a/man/get_strong_colocalization.Rd b/man/get_strong_colocalization.Rd index 3e5aff5..1b9dfa4 100644 --- a/man/get_strong_colocalization.Rd +++ b/man/get_strong_colocalization.Rd @@ -38,4 +38,8 @@ A \code{"colocboost"} object with some or all of the following elements: \description{ \code{get_strong_colocalization} get the colocalization by discarding the weaker colocalization events or colocalized outcomes } -\keyword{cb_get_functions} +\seealso{ +Other colocboost_inference: +\code{\link{get_cos_summary}()} +} +\concept{colocboost_inference} diff --git a/vignettes/installation.Rmd b/vignettes/installation.Rmd new file mode 100644 index 0000000..cd526d1 --- /dev/null +++ b/vignettes/installation.Rmd @@ -0,0 +1,51 @@ +--- +title: "Installation" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Installation} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +## Installation + +### CRAN +Install released versions from CRAN - pre-built packages are available on macOS and Windows + +```r +install.packages("colocboost") +``` + +### GitHub +Install the development version from GitHub + +```r +devtools::install_github("StatFunGen/colocboost") +``` + +### Conda +Install major releases using pre-built conda package with a conda-compatible package manager (recommended) + +Global pixi installation is the easiest way to use the conda package +```bash +pixi global install r-base # Install r-base as a global package if not already installed +pixi global install --environment r-base r-colocboost # Inject r-colocboost into r-base global environment +``` +The package can also be added to a local pixi environment +```bash +pixi workspace channel add dnachun # Add the dnachun channel to the workspace +pixi add r-colocboost # Add r-colocboost as a dependency to the environment +``` +Micromamba is recommended instead of conda or mamba for traditional conda environments +```bash +micromamba install -c dnachun r-colocboost +mamba install -c dnachun r-colocboost +conda install -c dnachun r-colocboost +``` \ No newline at end of file