Illustration of the limitations of SuSiE for molecular phenotype data
William R.P. Denault and Gao Wang
2024-03-07
Source:vignettes/Limitation_SuSiE.Rmd
Limitation_SuSiE.RmdWe use two simulated methylation profiles to compare approaches to fine-mapping genetic effects across CpGs. In the first example, a single SNP has a smooth effect. We compare per-CpG SuSiE, multivariate SuSiE (mvSuSiE) under several prior and residual covariance settings, and fSuSiE. In the second example, three SNPs have step-shaped effects. We compare fSuSiE with mvSuSiE under three effect priors, each with the residual covariance estimated or fixed.
library(fsusieR)
library(susieR)
library(ggplot2)
library(cowplot)
method_colors <- c(fSuSiE = "firebrick", mvSuSiE = "steelblue4")Example 1. A smooth effect
Let’s simulate a simple effect of a SNP on a set of CpGs. The effect of the SNP is a cosine function that spans over 40 CpGs.
set.seed(1)
data(N3finemapping, package = "susieR")
X_full <- N3finemapping$X[seq_len(100), ]
T_m <- 128L
effect <- 1.2 * cos(seq_len(T_m) / T_m * 3 * pi)
effect[effect < 0] <- 0
effect[seq_len(40)] <- 0
true_pos <- 700L
y <- matrix(0, nrow = 100L, ncol = T_m)
for (i in seq_len(100L)) {
y[i, ] <- X_full[i, true_pos] * effect + rnorm(T_m)
}
col_var <- apply(X_full, 2, var)
keep <- which(col_var > 0)
X <- X_full[, keep]
true_pos_filt <- which(keep == true_pos)
affected_pos <- which(effect > 0)
plot(effect, pch = 19, xlab = "CpG", ylab = "effect")
We simulate 100 observations of the effect of the SNP on the CpG. The original causal SNP index is 700. The genotype matrix has a few constant columns in these 100 samples, so these columns are removed before fitting the models. This matters for interpreting SNP indices: the original causal SNP 700 is index 691 in the filtered design matrix.
data.frame(
N = nrow(X),
J = ncol(X),
T = ncol(y),
true_snp_original = true_pos,
true_snp_filtered = true_pos_filt,
affected_start = min(affected_pos),
affected_end = max(affected_pos),
affected_positions = length(affected_pos)
)
#> N J T true_snp_original true_snp_filtered affected_start affected_end
#> 1 100 991 128 700 691 65 106
#> affected_positions
#> 1 42Method 1. Per-CpG SuSiE
Once the data is simulated, we can run SuSiE on each CpG. For the sake of simplicity, we only run SuSiE with L = 1 as we are aware that there is only one effect in this simulation. Also for simplicity, we assume that the association analysis has been performed with 100% accuracy—that is, we know exactly which CpGs are the affected CpGs, and therefore we can ignore the others.
susie_est <- vector("list", length(affected_pos))
for (k in seq_along(affected_pos)) {
susie_est[[k]] <- susie(X, y[, affected_pos[k]], L = 1L)$sets
}
n_cs_per_pos <- vapply(susie_est, function(s) length(s$cs), integer(1L))
knitr::kable(
data.frame(
n_credible_sets = as.integer(names(table(n_cs_per_pos))),
n_positions = as.integer(table(n_cs_per_pos))
)
)| n_credible_sets | n_positions |
|---|---|
| 0 | 36 |
| 1 | 6 |
One issue is that SuSiE fails to detect a causal SNP at most of the affected CpGs:
df_effect <- data.frame(position = seq_along(effect), effect = effect)
plot_effect_position <- function(pos) {
ggplot(df_effect, aes(x = position, y = effect)) +
geom_point(color = "grey55", size = 1.2) +
geom_hline(yintercept = 0, linetype = "dotted", color = "grey50") +
geom_point(data = df_effect[pos, , drop = FALSE],
color = "firebrick", size = 2.4) +
labs(x = "CpG position", y = "true effect",
title = paste("Position", pos)) +
theme_classic()
}
plot_susie_position <- function(pos) {
fit <- susie(X, y[, pos], L = 1L)
df_pip <- data.frame(snp = keep, pip = fit$pip)
p <- ggplot(df_pip, aes(x = snp, y = pip)) +
geom_point(color = "grey55", size = 0.8) +
geom_vline(xintercept = true_pos, linetype = "dashed",
color = "firebrick", alpha = 0.7) +
geom_point(data = df_pip[df_pip$snp == true_pos, , drop = FALSE],
color = "firebrick", shape = 21, size = 2.3, stroke = 1.1) +
coord_cartesian(ylim = c(0, 1)) +
labs(x = "SNP original index", y = "PIP",
title = paste("SuSiE PIP at position", pos)) +
theme_classic()
cs <- fit$sets$cs$L1
if (!is.null(cs)) {
p <- p + geom_point(data = df_pip[cs, , drop = FALSE],
color = "dodgerblue", size = 1.8)
}
p
}
plot_grid(
plot_effect_position(88L), plot_effect_position(91L),
plot_susie_position(88L), plot_susie_position(91L),
nrow = 2L, ncol = 2L
)
A second issue is that the SuSiE produces multiple fine-mapping signals (and therefore multiple sets of CSs), so it is unclear how to reason about uncertainty in the causal SNP(s). For example, compare the SuSiE results for CpGs 88 and 91. At CpG 88, the credible set misses the true SNP. At CpG 91, the true SNP is present, but it is not the lead variant.
Method 2. mvSuSiE
mvSuSiE treats Y as a multivariate response. Its
behavior depends strongly on the prior and residual-variance
initialization. The “oracle” residual variance is the identity matrix
used to simulate the data, and the “oracle” prior is the outer product
of the true effect curve with itself. The PIP-zero failure mode of the
default mvSuSiE on this simulation is the subject of mvsusieR issue
61.
library(mvsusieR)
U_true <- outer(effect, effect)
prior_true <- create_mixture_prior(
mixture_prior = list(matrices = list(U_true), weights = 1)
)
prior_canon <- create_mixture_prior(R = T_m)
V_true <- diag(T_m)
run_mvsusie <- function(...) {
suppressWarnings(mvsusie(..., verbose = FALSE))
}
get_mvsusie_curve <- function(fit) {
as.numeric(coef(fit)[true_pos_filt + 1L, ])
}
curve_cor <- function(curve) {
if (sd(curve) == 0) {
NA_real_
} else {
cor(curve, effect)
}
}
summarize_mvsusie <- function(fit, label, prior, residual, init) {
curve <- get_mvsusie_curve(fit)
data.frame(
test = label,
prior = prior,
residual_variance = residual,
initialization = init,
pip_at_true_snp = fit$pip[true_pos_filt],
max_pip = max(fit$pip),
lead_snp_original = keep[which.max(fit$pip)],
n_cs = length(fit$sets$cs),
effect_cor = curve_cor(curve),
max_abs_effect = max(abs(curve)),
converged = isTRUE(fit$converged)
)
}
fit_mv1 <- run_mvsusie(
X, y, L = 1L,
prior_variance = prior_true,
residual_variance = V_true,
estimate_residual_variance = FALSE,
estimate_prior_variance = TRUE,
max_iter = 100L
)
fit_mv2 <- run_mvsusie(
X, y, L = 1L,
prior_variance = prior_true,
residual_variance = V_true,
estimate_residual_variance = TRUE,
estimate_prior_variance = TRUE,
max_iter = 100L
)
fit_mv3 <- run_mvsusie(
X, y, L = 1L,
prior_variance = prior_canon,
residual_variance = V_true,
estimate_residual_variance = FALSE,
estimate_prior_variance = TRUE,
max_iter = 100L
)
fit_mv4 <- run_mvsusie(
X, y, L = 1L,
prior_variance = prior_true,
estimate_residual_variance = TRUE,
estimate_prior_variance = TRUE,
max_iter = 100L
)
fit_mv5 <- run_mvsusie(
X, y, L = 1L,
prior_variance = prior_true,
estimate_residual_variance = FALSE,
estimate_prior_variance = TRUE,
max_iter = 100L
)
fit_mv6 <- run_mvsusie(
X, y, L = 1L,
prior_variance = prior_canon,
estimate_residual_variance = TRUE,
estimate_prior_variance = TRUE,
max_iter = 100L
)
fit_mv7 <- run_mvsusie(
X, y, L = 1L,
prior_variance = prior_canon,
estimate_residual_variance = FALSE,
estimate_prior_variance = TRUE,
max_iter = 100L
)
mv_table <- rbind(
summarize_mvsusie(fit_mv1, "1", "oracle", "oracle fixed",
"oracle residual"),
summarize_mvsusie(fit_mv2, "2", "oracle", "estimated",
"oracle residual"),
summarize_mvsusie(fit_mv3, "3", "canonical", "oracle fixed",
"oracle residual"),
summarize_mvsusie(fit_mv4, "4", "oracle", "estimated", "default"),
summarize_mvsusie(fit_mv5, "5", "oracle", "default fixed", "default"),
summarize_mvsusie(fit_mv6, "6", "canonical", "estimated", "default"),
summarize_mvsusie(fit_mv7, "7", "canonical", "default fixed", "default")
)The tuned configuration recovers the effect shape closely. The default configuration’s recovered curve is essentially flat at zero: with no truth-informed residual-variance initialization, the PIPs collapse and the fitted effect carries no information.
curve_mv_oracle <- get_mvsusie_curve(fit_mv1)
curve_mv_default <- get_mvsusie_curve(fit_mv6)
yrng <- range(c(effect, curve_mv_oracle, curve_mv_default))
plot_mv_curve <- function(curve, main) {
plot(effect, pch = 20L, col = "grey30", cex = 0.7, ylim = yrng,
xlab = "position", ylab = "effect", main = main)
abline(h = 0, lty = 3, col = "grey50")
lines(curve, col = method_colors[["mvSuSiE"]], lwd = 2)
}
par(mfrow = c(1L, 2L), mar = c(4, 4, 2.5, 1))
plot_mv_curve(curve_mv_oracle,
"mvSuSiE, oracle initialized")
plot_mv_curve(curve_mv_default,
"mvSuSiE, default")
The table repeats the same simulation under several configurations:
knitr::kable(mv_table, digits = 4)| test | prior | residual_variance | initialization | pip_at_true_snp | max_pip | lead_snp_original | n_cs | effect_cor | max_abs_effect | converged | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| var691 | 1 | oracle | oracle fixed | oracle residual | 1 | 1 | 700 | 1 | 0.9972 | 1.3637 | TRUE |
| var6911 | 2 | oracle | estimated | oracle residual | 1 | 1 | 700 | 1 | 0.9972 | 1.3636 | FALSE |
| var6912 | 3 | canonical | oracle fixed | oracle residual | 1 | 1 | 700 | 1 | 0.8909 | 1.1128 | TRUE |
| var6913 | 4 | oracle | estimated | default | 0 | 0 | 1 | 0 | NA | 0.0000 | TRUE |
| var6914 | 5 | oracle | default fixed | default | 0 | 0 | 1 | 0 | NA | 0.0000 | TRUE |
| var6915 | 6 | canonical | estimated | default | 0 | 0 | 1 | 0 | NA | 0.0000 | TRUE |
| var6916 | 7 | canonical | default fixed | default | 0 | 0 | 1 | 0 | NA | 0.0000 | TRUE |
The first three configurations recover the true SNP. All three use the correct residual-variance initialization. The default initializations fail: the PIPs collapse to zero and no credible set is returned.
Method 3. fSuSiE
Now compare to an analysis of these data using fSuSiE, which involves a single call to the “susiF” function. Here we use trend-filtering post-processing.
fit_f <- susiF(y, X, L = 1L, post_processing = "TI", verbose = FALSE)
fit_f$cs
fit_f$pip[true_pos_filt]
#> [[1]]
#> [1] 691
#>
#> [1] 1Notice that fSuSiE returned a single CS containing 1 SNP, which is the true causal SNP.
df_f_pip <- data.frame(snp = keep, pip = fit_f$pip)
P_pip <- ggplot(df_f_pip, aes(x = snp, y = pip)) +
geom_point(color = method_colors[["fSuSiE"]], size = 0.8) +
geom_vline(xintercept = true_pos, linetype = "dashed",
color = "grey60") +
geom_point(data = df_f_pip[df_f_pip$snp == true_pos, , drop = FALSE],
color = method_colors[["fSuSiE"]], size = 2.3) +
coord_cartesian(ylim = c(0, 1)) +
labs(x = "SNP original index", y = "PIP", title = "fSuSiE PIPs") +
theme_classic()
df_f_curve <- data.frame(
position = seq_along(fit_f$fitted_func[[1]]),
estimate = fit_f$fitted_func[[1]],
upper = fit_f$cred_band[[1]][1, ],
lower = fit_f$cred_band[[1]][2, ],
truth = effect
)
P_effect <- ggplot(df_f_curve, aes(x = position)) +
geom_ribbon(aes(ymin = lower, ymax = upper), fill = method_colors[["fSuSiE"]],
alpha = 0.2) +
geom_point(aes(y = truth), color = "grey30", size = 1.1) +
geom_line(aes(y = estimate), color = method_colors[["fSuSiE"]], linewidth = 1) +
geom_hline(yintercept = 0, linetype = "dotted", color = "grey50") +
labs(x = "CpG position", y = "effect",
title = "fSuSiE recovered effect curve") +
theme_classic()
plot_grid(P_pip, P_effect, nrow = 1L, rel_widths = c(1, 1.25))
The left panel shows fSuSiE PIPs. The right panel shows the estimated effect in red, its credible band in pale red, and the simulated effect as gray points.
Example 2. Step-shaped effects
We use the simulation from the methylation vignette, with 100 individuals, 32 ordered CpGs, and 12 candidate SNPs. SNP-1 and SNP-9 have opposite effects at CpGs 9 through 16. SNP-3 affects CpGs 25 through 32. SNP-4 is a perturbed copy of SNP-3 and has zero effect.
set.seed(1)
n_step <- 100L
n_cpg_step <- 32L
n_snp_step <- 12L
snp_step <- paste0("SNP-", seq_len(n_snp_step))
causal_step <- c(1L, 3L, 9L)
maf_step <- 0.05 + 0.45 * runif(n_snp_step)
X_step <- (runif(n_step * n_snp_step) < maf_step) +
(runif(n_step * n_snp_step) < maf_step)
X_step <- matrix(X_step, n_step, n_snp_step, byrow = TRUE)
storage.mode(X_step) <- "double"
X_step[, 4] <- X_step[, 3] + 0.03 * rnorm(n_step)
colnames(X_step) <- snp_step
effect_step <- matrix(0, n_snp_step, n_cpg_step)
effect_step[1, 9:16] <- 2.3
effect_step[9, 9:16] <- -2.3
effect_step[3, 25:32] <- 2
colnames(effect_step) <- paste0("CpG-", seq_len(n_cpg_step))
Y_step <- X_step %*% effect_step +
matrix(3 * rnorm(n_step * n_cpg_step), n_step, n_cpg_step)
Y_step <- Y_step - min(Y_step)fSuSiE effect profiles
We fit fSuSiE with up to ten single effects and disable its optional credible-set filter. The plot shows the fitted effect and 95% pointwise credible intervals for each credible set. The dashed line marks zero.
L_step <- 10L
fit_step_f <- susiF(Y_step, X_step, L = L_step, filter_cs = FALSE,
standardize_Y = TRUE, post_processing = "TI",
verbose = FALSE)
fit_step_f$cs
#> [[1]]
#> SNP-9
#> 9
#>
#> [[2]]
#> SNP-3 SNP-4
#> 3 4
#>
#> [[3]]
#> SNP-1
#> 1Each of the three credible sets contains a causal SNP. One set contains both SNP-3 and SNP-4, reflecting the uncertainty between these highly correlated candidates.
cs_label <- vapply(fit_step_f$cs, function(cs) {
paste(snp_step[cs], collapse = ", ")
}, character(1))
step_profiles <- do.call(rbind, lapply(seq_along(cs_label), function(i) {
profile <- get_fitted_effect(fit_step_f, l = i, cred_band = TRUE,
alpha = 0.05)
data.frame(CpG = seq_len(n_cpg_step), estimate = profile$effect,
lower = profile$cred_band["low", ],
upper = profile$cred_band["up", ],
credible_set = cs_label[i])
}))
step_profiles$credible_set <- factor(step_profiles$credible_set,
levels = cs_label)
ggplot(step_profiles, aes(CpG, estimate, ymin = lower, ymax = upper)) +
geom_hline(yintercept = 0, linetype = "dashed", color = "grey50") +
geom_pointrange(color = method_colors[["fSuSiE"]], linewidth = 0.35) +
facet_wrap(~credible_set, nrow = 1) +
scale_x_continuous(breaks = c(1, 8, 16, 24, 32)) +
labs(x = "CpG index", y = "Estimated effect") +
theme_classic()
Comparing mvSuSiE priors and residual covariance settings
A diagonal covariance gives independent effects across CpGs a priori. A canonical mixture includes CpG-specific and shared effect patterns. The mashr mixture estimates weights over scaled canonical covariances from the 12 marginal association profiles at this locus. These covariances do not encode CpG order. fSuSiE uses that order in its wavelet representation.
For each prior, we start from the sample covariance of the CpG
profiles. With estimate_residual_variance = TRUE, mvSuSiE
updates this matrix during fitting. With FALSE, it holds
the initial matrix fixed. All six fits allow up to ten single effects
and use the default credible-set filtering. fSuSiE uses its own response
standardization and residual model.
prior_step_diag <- mvsusieR::create_mixture_prior(
mixture_prior = list(matrices = list(0.2 * diag(apply(Y_step, 2, var))),
weights = 1)
)
prior_step_canon <- mvsusieR::create_mixture_prior(R = n_cpg_step)
Z_step <- susieR::calc_z(X_step, Y_step, center = TRUE, scale = TRUE)
mash_data_step <- mashr::mash_set_data(
Bhat = Z_step, Shat = matrix(1, n_snp_step, n_cpg_step)
)
mash_fit_step <- mashr::mash(mash_data_step,
Ulist = mashr::cov_canonical(mash_data_step),
outputlevel = 0)
prior_step_mash <- mvsusieR::create_mixture_prior(fitted_g = mash_fit_step$fitted_g)
step_priors <- list(Diagonal = prior_step_diag, Canonical = prior_step_canon,
"mashr mixture" = prior_step_mash)
step_settings <- expand.grid(
prior = names(step_priors), estimate_residual = c(TRUE, FALSE),
KEEP.OUT.ATTRS = FALSE, stringsAsFactors = FALSE
)
fit_step_mv <- Map(function(prior, estimate_residual) {
mvsusieR::mvsusie(
X_step, Y_step, L = L_step, prior_variance = step_priors[[prior]],
estimate_residual_variance = estimate_residual,
estimate_prior_variance = TRUE, standardize = TRUE, verbose = FALSE
)
}, step_settings$prior, step_settings$estimate_residual)
step_settings$residual <- factor(
ifelse(step_settings$estimate_residual, "Estimated", "Fixed"),
levels = c("Estimated", "Fixed")
)
#> - Computing 12 x 556 likelihood matrix.
#> - Likelihood calculations took 0.01 seconds.
#> - Fitting model with 556 mixture components.
#> - Model fitting took 0.02 seconds.The table summarizes all six mvSuSiE fits and the fSuSiE reference. Each panel shows one mvSuSiE fit in blue alongside the same fSuSiE posterior inclusion probabilities (PIPs) in red. Gray dashed lines mark the three SNPs that affect the simulated profiles.
step_cs <- c(list(fit_step_f$cs),
lapply(fit_step_mv, function(fit) fit$sets$cs))
step_mv_pips <- lapply(fit_step_mv, function(fit) fit$pip)
format_step_cs <- function(sets) {
if (length(sets) == 0L) return("None")
paste(vapply(sets, function(cs) {
paste0("{", paste(snp_step[cs], collapse = ", "), "}")
}, character(1)), collapse = "; ")
}
step_table <- data.frame(
Method = c("fSuSiE", rep("mvSuSiE", nrow(step_settings))),
Prior = c("Wavelet", step_settings$prior),
"Residual covariance" = c("fSuSiE model", as.character(step_settings$residual)),
"Number of CSs" = lengths(step_cs),
"Credible sets" = vapply(step_cs, format_step_cs, character(1)),
"Maximum PIP" = c(max(fit_step_f$pip), vapply(step_mv_pips, max, numeric(1))),
Converged = c("N/A", vapply(fit_step_mv, function(fit) {
if (isTRUE(fit$converged)) "Yes" else "No"
}, character(1))),
row.names = NULL, check.names = FALSE
)
knitr::kable(step_table, digits = 4)| Method | Prior | Residual covariance | Number of CSs | Credible sets | Maximum PIP | Converged |
|---|---|---|---|---|---|---|
| fSuSiE | Wavelet | fSuSiE model | 3 | {SNP-9}; {SNP-3, SNP-4}; {SNP-1} | 1.0000 | N/A |
| mvSuSiE | Diagonal | Estimated | 0 | None | 0.0000 | Yes |
| mvSuSiE | Canonical | Estimated | 0 | None | 0.7907 | Yes |
| mvSuSiE | mashr mixture | Estimated | 1 | {SNP-8} | 1.0000 | Yes |
| mvSuSiE | Diagonal | Fixed | 0 | None | 0.0000 | Yes |
| mvSuSiE | Canonical | Fixed | 0 | None | 0.7029 | Yes |
| mvSuSiE | mashr mixture | Fixed | 0 | None | 0.9164 | Yes |
step_pip_data <- data.frame(
SNP = rep(seq_len(n_snp_step), times = nrow(step_settings)),
PIP = unlist(step_mv_pips, use.names = FALSE),
Prior = factor(rep(step_settings$prior, each = n_snp_step),
levels = names(step_priors)),
Residual = rep(step_settings$residual, each = n_snp_step)
)
step_reference <- data.frame(SNP = seq_len(n_snp_step), PIP = fit_step_f$pip)
ggplot(step_pip_data, aes(SNP, PIP)) +
geom_vline(xintercept = causal_step, linetype = "dashed",
color = "grey65", alpha = 0.7) +
geom_point(data = step_reference, aes(color = "fSuSiE"),
shape = 16, size = 1.35) +
geom_point(aes(color = "mvSuSiE"), shape = 16, size = 1) +
facet_grid(Residual ~ Prior) +
scale_color_manual(NULL, values = method_colors) +
scale_x_continuous(breaks = c(1, 3, 6, 9, 12)) +
scale_y_continuous(breaks = c(0, 0.5, 1)) +
labs(x = "SNP index", y = "PIP") +
theme_classic(base_size = 10) +
theme(legend.position = "bottom")
Conclusion
fSuSiE gave the best recovery of causal signals in the step-shaped simulation. It returned three credible sets, each containing a different causal SNP. The only credible set among the six mvSuSiE fits came from the mashr prior with estimated residual covariance. It contained SNP-8, whose simulated effect was zero.
In the smooth-effect simulation, fSuSiE recovered the causal SNP using its default residual model. mvSuSiE also recovered that SNP when initialized with the true residual covariance.