cs: Credible set from summary statistics

View source: R/cs.R

csR Documentation

Credible set from summary statistics

Description

Computes a Bayesian credible set from GWAS summary statistics using Wakefield-style approximate Bayes factors.

Usage

cs(tbl, b = "Effect", se = "StdErr", log_p = NULL, cutoff = 0.95)

Arguments

tbl

A data.frame containing summary statistics.

b

Name of column containing effect sizes.

se

Name of column containing standard errors.

log_p

Optional column name containing log p-values. If supplied, z-scores are derived from p-values instead of effect sizes and standard errors.

cutoff

Cumulative posterior probability threshold. Default is 0.95 (95% credible set).

Details

Credible set is often used in fine-mapping.

Posterior probabilities are computed from z-statistics using a numerically stable log-sum-exp implementation from matrixStats.

Value

A subset of tbl containing variants in the credible set, ordered by decreasing posterior probability of association.

Examples

## Not run: 
\preformatted{
  zcat ~/rds/results/private/proteomics/scallop-inf1/4E.BP1-1.tbl.gz | \
  awk 'NR==1 || ($1==4 && $2 >= 187158034 - 1e6 && $2 < 187158034 + 1e6)' > 4E.BP1.z
}
tbl <- within(read.delim("4E.BP1.z"),{logp <- logp(Effect/StdErr)})
z <- cs(tbl)
l <- cs(tbl,log_p="logp")

## End(Not run)


gap documentation built on May 28, 2026, 9:07 a.m.