windowMaker-methods: Sliding or Tiled window maker.

windowMakerR Documentation

Sliding or Tiled window maker.

Description

Makes sliding and tiled windows from data frame

Usage

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)

Arguments

x

Can be a data.frame object containing ID and Length columns for each scaffold,
Granges or GRangesList object

stepSize

numeric
Window step size in base pairs. Default is 0, specifies a tiled window.

WindowSize

numeric
Window size in base pairs

Details

Authours: Chris Ward & Alastair Ludington
Generates tiled (no step size) and sliding (step size) ranges for analysis with other functions.

Value

A GRangesList object where each element is a genomic window.

Examples


#### 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)


CMWbio/geaR documentation built on April 22, 2023, 6:23 a.m.