segments {BGData} | R Documentation |
Find non-overlapping segments based on a summary statistic
Description
Given a summary statistic and a threshold, this function computes the
number of non-overlapping segments, each defined as a discovery (i.e.,
statistic[i] <= threshold)
+/- a gap, in the same units as bp
(often base-pair position).
Usage
segments(statistic, chr, bp, threshold, gap, trim = FALSE, verbose = FALSE)
Arguments
statistic |
A statistic (e.g., BFDR or p-values). |
chr |
A vector containing the chromosome for each value of |
bp |
A vector containing the base-pair positions for each value of
|
threshold |
The threshold to determine 'significance' (e.g., |
gap |
1/2 of the length of the desired segments. |
trim |
Whether to collapse segments that were artifically inflated by
|
verbose |
Whether progress updates will be posted. Defaults to |
Value
A data frame containing the following information:
chr |
Chromosome |
start |
Index where segment starts within |
end |
Index where segment ends within |
length |
Length of segment. |
bpStart |
Base-pair position where segment starts. |
bpEnd |
Base-pair position where segment ends. |
bpLength |
Length of segment in base-pair positions. |
minValue |
Smallest value of |
minValuePos |
Position of variant with the smallest value of |
Examples
library(BGData)
# Load example data
bg <- BGData:::loadExample()
# Perform GWAS
pValues <- GWAS(
formula = FT10 ~ 1,
data = bg,
method = "rayOLS"
)
# Determine segments within +/- 1MB from a significant variant
segments <- segments(
statistic = pValues[, 4],
chr = map(bg)$chromosome,
bp = map(bg)$base_pair_position,
threshold = 1e-5,
gap = 1e6,
trim = FALSE,
verbose = FALSE
)