windowMaker | R Documentation |
Makes sliding and tiled windows from data frame
windowMaker(x, windowSize, stepSize, nCores = 1, ...)
## S4 method for signature 'data.frame'
windowMaker(x, windowSize, stepSize, nCores)
## S4 method for signature 'GRanges'
windowMaker(x, windowSize, stepSize = 0)
## S4 method for signature 'GRangesList'
windowMaker(x, windowSize, stepSize = 0, nCores = 1)
x |
Can be a |
stepSize |
|
WindowSize |
|
Authours: Chris Ward & Alastair Ludington
Generates tiled (no step size) and sliding (step size) ranges for analysis with other functions.
A GRangesList
object where each element is a genomic window.
#### tiled windows ####
# make tiled windows of width 10,000 bp using 4 cores
windowSize <- 10000
stepSize <- 0
nCores <- 4
#### sliding windows ####
# make sliding windows of width 10,000 bp with 1000 bp step size, using 4 cores
windowSize <- 10000
stepSize <- 1000
nCores <- 4
#### Using data.frame ####
# get contig metadata from fasta index
df <- readr::read_tsv("referene.fna.fai", col_names = FALSE)
x <- tibble::tibble(ID = df[[1]], length = df[[2]])
# subset by desired contigs
x <- x[x$ID %in% c("chr1", "chr2"),]
# construct windows
windows <- windowMaker(x, windowSize, stepSize, nCores)
#### Using GRanges ####
# make GRange object of width 1 Mbp on chr1
x <- GRanges(seqnames = "chr1", ranges = IRanges(start = 1, end = 1000000))
windows <- windowMaker(x, windowSize, stepSize)
#### Using GRangesList ####
# make GRange object of width 1 Mbp on chr1 and chr2
x <-GRangesList(GRanges(seqnames = "chr1", ranges = IRanges(start = 1, end = 1000000)), GRanges(seqnames = "chr2", ranges = IRanges(start = 1, end = 1000000)))
windows <- windowMaker(x, windowSize, stepSize, nCores)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.