windower: Windower

Description Usage Arguments Value Author(s) Examples

View source: R/windower.R

Description

averages over running windows

Usage

1
2
3
windower(data, length=20000, step=length/2, start=0, n.min=0, na.rm=TRUE,
                     what=c("mean", "var", "sd", "min", "max", "median",
                            "sum"))

Arguments

data

data frame from a ‘.bed’ file. The first column indicates the chromosome. The second and the third row give starting and end point [in base pairs]. The 4th column gives the values. All the other columns will be ignored

length

length in base pairs of the window

step

positive integer. shift of the window by step base pairs

start

the base pair position where the very first window starts.

n.min

the required minimal number of SNPs in the window. If there are less SNPs inside, this window is not reported.

na.rm

logical. if TRUE then na.rm are just ignored.

what

string. Name of the function that should be 'windowed'; "mean" is standard.

Value

It returns a matrix with 4 columns: the first and the second column contain the starting and end point of the window in ‘.bed’ coding. The third column gives the mean (or variance etc). The 4th column gives the number of values the mean is based on.

Author(s)

Martin Schlather, schlather@math.uni-mannheim.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
loci <- 10000
pos <- sort(sample(10^4:10^6, loci))
pos2 <- pos + 1
freq <- runif(loci)^5
data <- data.frame(V1=rep(1, loci), V2=pos, V3=pos2,  V4=freq)


win.mean <- windower(data, n.min=25)
head(win.mean)

win.var <- windower(data, n.min=25, what="var")
head(win.var)

win.sd <- windower(data, n.min=25, what="sd")
head(win.sd)

win.min <- windower(data, n.min=0, what="min")
head(win.min)

win.max <- windower(data, n.min=0, what="max")
head(win.max)

win.median <- windower(data, n.min=0, what="median")
head(win.median)

miraculix documentation built on Sept. 22, 2021, 5:07 p.m.