Learn R Programming

derfinder (version 1.6.4)

regionMatrix: Identify regions data by a coverage filter and get a count matrix

Description

Given a set of un-filtered coverage data (see fullCoverage), create candidate regions by applying a cutoff on the coverage values, and obtain a count matrix where the number of rows corresponds to the number of candidate regions and the number of columns corresponds to the number of samples. The values are the mean coverage for a given sample for a given region.

Usage

regionMatrix(fullCov, cutoff = 5, filter = "mean", L, runFilter = TRUE,
  returnBP = TRUE, ...)

Arguments

fullCov
A list where each element is the result from loadCoverage used with returnCoverage = TRUE. Can be generated using fullCoverage. If runFilter = FALSE, then returnMean = TRUE must have been used.
cutoff
The base-pair level cutoff to use. It's behavior is controlled by filter.
filter
Has to be either 'one' (default) or 'mean'. In the first case, at least one sample has to have coverage above cutoff. In the second case, the mean coverage has to be greater than cutoff.
L
The width of the reads used. Either a vector of length 1 or length equal to the number of samples.
runFilter
This controls whether to run filterData or not. If set to FALSE then returnMean = TRUE must have been used to create each element of fullCov.
returnBP
If TRUE, returns $bpCoverage explained below.
...
Arguments passed to other methods and/or advanced arguments.

Value

  • A list with one entry per chromosome. Then per chromosome, a list with three components. [object Object],[object Object],[object Object]

Details

This function uses several other derfinder-package functions. Inspect the code if interested.

You should use at most one core per chromosome.

Examples

Run this code
## Create some toy data
library('IRanges')
x <- Rle(round(runif(1e4, max=10)))
y <- Rle(round(runif(1e4, max=10)))
z <- Rle(round(runif(1e4, max=10)))
fullCov <- list('chr21' = DataFrame(x, y, z))

## Calculate a proxy of library size
libSize <- sapply(fullCov$chr21, sum)

## Run region matrix normalizing the coverage
regionMat <- regionMatrix(fullCov = fullCov, maxRegionGap = 10L, 
    maxClusterGap = 300L, L = 36, totalMapped = libSize, targetSize = 4e4)

## You can alternatively use filterData() on fullCov to reduce the required
## memory before using regionMatrix(). This can be useful when mc.cores > 1
filteredCov <- lapply(fullCov, filterData, returnMean=TRUE, filter='mean', 
    cutoff=5, totalMapped = libSize, targetSize = 4e4)
regionMat2 <- regionMatrix(filteredCov, maxRegionGap = 10L, 
    maxClusterGap = 300L, L = 36, runFilter=FALSE)
identical(regionMat2, regionMat)

Run the code above in your browser using DataLab