Learn R Programming

diffHic (version 1.4.2)

neighborCounts: Load Hi-C interaction counts

Description

Collate count combinations for interactions between pairs of bins across multiple Hi-C libraries.

Usage

neighborCounts(files, param, width=50000, filter=1L, flank=NULL, exclude=NULL, prior.count=NULL)

Arguments

files
a character vector containing paths to the index files generated from each Hi-C library
param
a pairParam object containing read extraction parameters
width
an integer scalar specifying the width of each square in base pairs
filter
an integer scalar specifying the minimum count for each square
flank
an integer scalar, specifying the number of bins to consider as the local neighborhood
exclude
an integer scalar, specifying the number of bins to exclude from the neighborhood
prior.count
a numeric scalar indicating the prior count to use in computing the log-fold increase

Value

An InteractionSet object is returned with the number of read pairs for each bin pair across all libraries. In the mcols, the enrichment field contains a numeric vector of enrichment statistics for each bin pair.

Details

This function combines the functionality of squareCounts and enrichedPairs. The idea is to allow calculation of local enrichment values when there is insufficient memory to load all bin pairs with filter=1L in squareCounts. Here, the interaction space around each bin pair is examined as the counts are loaded for that bin pair, avoiding the need to hold the entire interaction space at once. Only the counts and local enrichment values for those bin pairs with row sums above filter are reported to save memory. The returned enrichment values are equivalent to that computed with enrichedPairs with the default settings.

References

Rao S et al. (2014). A 3D map of the human genome at kilobase resolution reveals principles of chromatin looping. Cell. 159, 1665-1690.

See Also

squareCounts, enrichedPairs

Examples

Run this code
hic.file <- system.file("exdata", "hic_sort.bam", package="diffHic")
cuts <- readRDS(system.file("exdata", "cuts.rds", package="diffHic"))
param <- pairParam(fragments=cuts)

# Setting up the parameters
fout <- "output.h5"
invisible(preparePairs(hic.file, param, file=fout))

# Collating to count combinations.
y <- neighborCounts(fout, param, width=50, filter=2, 
    flank=5, prior.count=2)
y
mcols(y)$enrichment

# Practically identical to a more memory-intensive call.
ref <- squareCounts(fout, param, width=50, filter=1)
keep <- rowSums(assay(ref)) >= 2
enriched <- enrichedPairs(ref, flank=5, prior.count=2)

stopifnot(identical(anchors(ref[keep,]), anchors(y)))
stopifnot(all(abs(enriched[keep] - mcols(y)$enrichment) < 1e-6))


Run the code above in your browser using DataLab