Skip to contents

This function extracts and processes information for each Credible Set (CS) from finemapping results, typically obtained from a finemapping RDS file.

Usage

extractCsInfo(fmRow, csNames, topLociTable, ldSource)

Arguments

fmRow

A fineMappingRow carrying the SuSiE fit and variant ids (e.g. from getFineMappingResult).

csNames

Character vector. Names of the Credible Sets, usually in the format "L_<number>".

topLociTable

Data frame. The top-loci table (e.g. from getTopLoci) carrying variant_id, pip, and z columns.

ldSource

The LD source from which the between-credible-set correlation is derived on demand: a QtlDataset (individual-level) or a QtlSumStats / GwasSumStats (summary statistics). See computeCsCorrelation.

Value

A data frame with one row per CS, containing the following columns:

cs_name

Name of the Credible Set

variants_per_cs

Number of variants in the CS

top_variant

ID of the variant with the highest PIP in the CS

top_variant_index

Global index of the top variant

top_pip

Highest Posterior Inclusion Probability (PIP) in the CS

top_z

Z-score of the top variant

p_value

P-value calculated from the top Z-score

cs_corr_1, cs_corr_2, ...

Each CS's pairwise correlation with every CS (its row of the between-CS matrix, self-correlation on the diagonal), computed on demand from ldSource. Absent when there are fewer than two credible sets.

cs_corr_max

Maximum absolute between-CS correlation (excluding the self == 1); NA for a single CS.

cs_corr_min

Minimum absolute between-CS correlation; NA for a single CS.

Details

This function is designed to be used only when there is at least one Credible Set in the finemapping results usually for a given study and block. It processes each CS, extracting key information such as the top variant, its statistics, and correlation information between multiple CS if available.

Examples

data(qtlSumStatsExample)
vids <- c("chr1:100:A:G", "chr1:200:C:T", "chr1:300:G:A")
fit <- list(pip = c(0.1, 0.7, 0.2), sets = list(cs = list(L_1 = c(1, 2))))
tl <- data.frame(variant_id = vids, pip = c(0.1, 0.7, 0.2),
  z = c(1.0, 3.5, -0.5))
fe <- fineMappingRow(variantIds = vids, susieFit = fit, topLoci = tl)
# A single credible set has no between-CS correlation (cs_corr_* are NA), so
# the ldSource is not consulted here.
extractCsInfo(fe, csNames = "L_1", topLociTable = tl,
  ldSource = qtlSumStatsExample)
#> # A tibble: 1 × 9
#>   cs_name variants_per_cs top_variant  top_variant_index top_pip top_z  p_value
#>   <chr>             <int> <chr>                    <int>   <dbl> <dbl>    <dbl>
#> 1 L_1                   2 chr1:200:C:T                 2     0.7   3.5 0.000465
#> # ℹ 2 more variables: cs_corr_max <dbl>, cs_corr_min <dbl>