get_cos_purity: Calculate purity within and in-between CoS

View source: R/colocboost_output.R

get_cos_purityR Documentation

Calculate purity within and in-between CoS

Description

Calculate purity statistics between all pairs of colocalization confidence sets (CoS)

Usage

get_cos_purity(cos, X = NULL, Xcorr = NULL, n_purity = 100)

Arguments

cos

List of variables in CoS

X

Genotype matrix of values of the p variables. Used to compute correlations if Xcorr is not provided.

Xcorr

Correlation matrix of correlations between variables. Alternative to X.

n_purity

The maximum number of CoS variables used in calculating the correlation (“purity”) statistics. When the number of variables included in the CoS is greater than this number, the CoS variables are randomly subsampled.

Value

A list containing three matrices (min_abs_cor, max_abs_cor, median_abs_cor) with purity statistics for all pairs of CoS. Diagonal elements represent within-CoS purity.

See Also

Other colocboost_utilities: get_cormat(), get_cos(), get_cos_summary(), get_hierarchical_clusters(), get_ucos_summary()

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[10, 1] <- 0.5 
true_beta[10, 2] <- 0.4 
true_beta[50, 2] <- 0.3 
true_beta[80, 3] <- 0.6 
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)
cos_res <- get_cos(res, coverage = 0.8)
get_cos_purity(cos_res$cos, X = X)


colocboost documentation built on June 8, 2025, 11:07 a.m.