totalCounts {diffHic} | R Documentation

## Get the total counts

### Description

Get the total number of read pairs in a set of Hi-C libraries.

### Usage

    totalCounts(files, param)

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

### Details

As the name suggests, this function counts the total number of read pairs in each index file prepared by `preparePairs`. Use of `param$fragments` ensures that the chromosome names in each index file are consistent with those in the desired genome (e.g., from `cutGenome`). Counting will also consider the values of `restrict`, `discard` and `cap` in `param`.

### Value

An integer vector is returned containing the total number of read pairs in each library.

### Author(s)

Aaron Lun

### See Also

`preparePairs`, `cutGenome`, `pairParam`, `squareCounts`

### Examples

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

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

    # Counting totals, and comparing them.
    totalCounts(fout, param)
    squareCounts(fout, param, width=10)$totals

    new.param <- reform(param, restrict="chrA")
    totalCounts(fout, new.param)
    squareCounts(fout, new.param, width=10)$totals

    new.param <- reform(param, discard=GRanges("chrA", IRanges(1, 50)))
    totalCounts(fout, new.param)
    squareCounts(fout, new.param, width=10)$totals

    new.param <- reform(param, cap=1)
    totalCounts(fout, new.param)
    squareCounts(fout, new.param, width=10)$totals

[Package diffHic version 1.24.1 Index]