segments {BGData}  R Documentation 
Given a summary statistic and a threshold, this function computes the
number of nonoverlapping segments, each defined as a discovery (i.e.,
statistic[i] <= threshold)
+/ a gap, in the same units as bp
(often basepair position).
segments(statistic, chr, bp, threshold, gap, trim = FALSE, verbose = FALSE)
statistic 
A statistic (e.g., BFDR or pvalues). 
chr 
A vector containing the chromosome for each value of 
bp 
A vector containing the basepair 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 
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 
Basepair position where segment starts. 
bpEnd 
Basepair position where segment ends. 
bpLength 
Length of segment in basepair positions. 
minValue 
Smallest value of 
minValuePos 
Position of variant with the smallest value of 
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 = 1e5,
gap = 1e6,
trim = FALSE,
verbose = FALSE
)