| name | bio-causal-genomics-fine-mapping |
| description | Identify likely causal variants within GWAS loci using SuSiE for sum of single effects regression and FINEMAP for shotgun stochastic search. Computes posterior inclusion probabilities and credible sets to prioritize variants for functional follow-up. Use when narrowing GWAS association signals to candidate causal variants or building credible sets for functional validation. |
| tool_type | r |
| primary_tool | susieR |
Version Compatibility
Reference examples tested with: ggplot2 3.5+
Before using code patterns, verify installed versions match. If versions differ:
- R:
packageVersion('<pkg>') then ?function_name to verify parameters
- CLI:
<tool> --version then <tool> --help to confirm flags
If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.
Fine-Mapping
"Narrow my GWAS locus to the likely causal variant" → Compute posterior inclusion probabilities (PIPs) for each variant and construct credible sets containing the causal variant at a specified confidence level, accounting for LD and multiple causal signals.
- R:
susieR::susie_rss() for SuSiE fine-mapping from summary statistics
- CLI:
finemap --sss for shotgun stochastic search
Overview
Fine-mapping narrows GWAS association signals to identify likely causal variants. Key outputs:
- PIP (Posterior Inclusion Probability) - Probability each variant is causal (0-1)
- Credible set - Minimal set of variants containing the causal variant at a given confidence level (e.g., 95%)
- L - Number of independent causal signals at the locus
SuSiE (Sum of Single Effects)
Goal: Fine-map a GWAS locus to identify likely causal variants and credible sets from individual-level data.
Approach: Fit SuSiE's sum-of-single-effects model on the genotype matrix, then extract 95% credible sets (each containing the causal variant) and per-variant posterior inclusion probabilities.
library(susieR)
fit <- susie(X, Y, L = 10)
cs <- fit$sets$cs
cat('Number of credible sets:', length(cs), '\n')
purity <- fit$sets$purity
print(purity)
pip <- fit$pip
top_variants <- order(-pip)[1:10
cat
i top_variants
catsprintf i pipi
SuSiE with Summary Statistics (susie_rss)
Goal: Fine-map a GWAS locus using summary statistics and an LD reference matrix (no individual-level data needed).
Approach: Compute Z-scores from beta/SE, provide a matched-ancestry LD correlation matrix, and run susie_rss to identify credible sets and PIPs.
library(susieR)
z_scores <- gwas_df$BETA / gwas_df$SE
ld_matrix <- as.matrix(read.table('ld_matrix.ld'))
stopifnot(nrow(ld_matrix) == length(z_scores))
fit <- susie_rss(z = z_scores, R = ld_matrix, n = 50000, L = 10)
cs <- fit$sets$cs
for (i in seq_along(cs)) {
cat(sprintf(
i csi fitsetspurityi
cat pastegwas_dfSNPcsi collapse
gwas_dfPIP fitpip
top_pip gwas_dfordergwas_dfPIP
printtop_pip
Choosing L (Number of Causal Variants)
fit_l5 <- susie_rss(z = z_scores, R = ld_matrix, n = 50000, L = 5)
fit_l10 <- susie_rss(z = z_scores, R = ld_matrix, n = 50000, L = 10)
cat('L=5 credible sets:', length(fit_l5$sets$cs), '\n')
cat('L=10 credible sets:', length(fit_l10$sets$cs
LD Reference Panel
plink --bfile 1000G_EUR \
--chr 6 --from-bp 30000000 --to-bp 31000000 \
--make-bed --out locus_ref
plink --bfile locus_ref \
--r square --out ld_matrix
plink --bfile locus_ref \
--extract gwas_snps.txt \
--r square --out ld_matrix_filtered
ld <- as.matrix(read.table('ld_matrix.ld'))
eigenvalues <- eigen(ld, only.values = TRUE)$values
if (any(eigenvalues < 0)) {
ld <- ld + diag(abs(min(eigenvalues)) + 1e-6, nrow(ld))
}
FINEMAP
Goal: Fine-map a locus using an alternative shotgun stochastic search algorithm.
Approach: Prepare .z (summary stats), .ld (LD matrix), and .master (config) files, then run FINEMAP to compute per-variant PIPs and causal configurations.
cat > master.txt << 'EOF'
z;ld;snp;config;cred;log;n_samples
locus.z;locus.ld;locus.snp;locus.config;locus.cred;locus.log;50000
EOF
finemap --sss --in-files master.txt --n-causal-snps 5
finemap_snp <- read.table('locus.snp', header = TRUE)
finemap_snp <- finemap_snp[order(-finemap_snp$prob), ]
cat('Top variants by PIP (FINEMAP):\n')
print(head(finemap_snp[, c('rsid', 'prob', 'log10bf')], 10))
finemap_cred <- read.table('locus.cred', header = TRUE)
Functional Annotation with PolyFun
polyfun_priors <- read.table('polyfun_output.txt', header = TRUE)
fit_informed <- susie_rss(
z = z_scores, R = ld_matrix, n = 50000, L = 10,
prior_variance = polyfun_priors$prior_var
)
Visualization
library(ggplot2)
plot_pip <- function(gwas_df, credible_sets = NULL) {
p <- ggplot(gwas_df, aes(x = POS / 1e6, y = PIP)) +
geom_point(alpha = 0.5, size = 1.5) +
geom_hline(yintercept = 0.5, linetype = 'dashed', color = 'orange', alpha = 0.5) +
geom_hline(yintercept = 0.95, linetype = 'dashed', color = 'red', alpha = 0.5)
labsx y
title
theme_minimal
credible_sets
cs_snps unlistcredible_sets
gwas_dfin_cs nrowgwas_df cs_snps
p ggplotgwas_df aesx POS y PIP color in_cs
geom_pointalpha size
scale_color_manualvalues labels name
geom_hlineyintercept linetype alpha
labsx y title
theme_minimal
p
plot_gwas_pip gwas_df
librarypatchwork
p_gwas ggplotgwas_df aesx POS y log10P
geom_pointalpha size
geom_hlineyintercept log10 linetype color alpha
labsx y title
theme_minimal themeaxis.text.x element_blank
p_pip ggplotgwas_df aesx POS y PIP
geom_pointalpha size color
labsx y title
theme_minimal
p_gwas p_pip
Related Skills
- colocalization-analysis - SuSiE-coloc uses fine-mapping credible sets
- mendelian-randomization - Fine-map instrument loci for causal variants
- population-genetics/linkage-disequilibrium - LD matrices for fine-mapping
- variant-calling/variant-annotation - Annotate fine-mapped variants