readCool: Read a .(m)cool file and return Hi-C data as a dataframe

View source: R/readCool.R

readCoolR Documentation

Read a .(m)cool file and return Hi-C data as a dataframe

Description

Read a .(m)cool file and return Hi-C data as a dataframe

Usage

readCool(
    file,
    chrom,
    chromstart = NULL,
    chromend = NULL,
    altchrom = NULL,
    altchromstart = NULL,
    altchromend = NULL,
    resolution = "auto",
    zrange = NULL,
    norm = "NONE",
    binChunkSize = 5e6,
    params = NULL,
    quiet = FALSE
)

Arguments

file

A character value specifying the path to the .(m)cool file.

chrom

Chromosome of data, as a string.

chromstart

Integer start position on chromosome.

chromend

Integer end position on chromosome.

altchrom

Alternate chromosome for interchromosomal data, as a string.

altchromstart

Alternate chromosome integer start position for interchromosomal data.

altchromend

Alternate chromosome integer end position for interchromosomal data.

resolution

A numeric specifying the width of each pixel. "auto" will attempt to choose a resolution in basepairs based on the size of the region.

zrange

A numeric vector of length 2 specifying the range of interaction scores, where extreme values will be set to the max or min.

norm

Character value specifying hic data normalization method. This value must be found in the .(m)cool file. Default value is norm = "NONE".

binChunkSize

A numeric specifying the number of bin indices to read from a file for a given region at a given resolution. If the total amount of data is larger than the binChunkSize, data will be read in multiple chunks. Default value is binChunkSize = 5e6.

params

An optional pgParams object containing relevant function parameters.

quiet

A logical indicating whether or not to print messages.

Value

Returns a 3-column dataframe in sparse upper triangular format with the following columns: chrom, altchrom, counts.

Author(s)

Sarah Parker, Nicole Kramer

See Also

readHic

Examples


## .cool file
coolFile <- file.path(tempdir(), "Rao2014-IMR90-MboI-allreps-filtered.1000kb.cool")
download.file(url = "https://usgs2.osn.mghpcc.org/cooler01/examples/hg19/Rao2014-IMR90-MboI-allreps-filtered.1000kb.cool",
    destfile = coolFile)

## Read in region `chr2:10000000-22000000` at 1000Kb cool file resolution
coolData <- readCool(file = coolFile, chrom = "chr2", chromstart = 10000000,
                     chromend = 22000000,
                     resolution = 1000000)

## .mcool file
mcoolFile <- file.path(tempdir(), "LEUK_HEK_PJA27_inter_30.mcool")
download.file(url = "https://zenodo.org/records/10906240/files/LEUK_HEK_PJA27_inter_30.mcool?download=1",
    destfile = mcoolFile)

## Read in region `chr2:1000000-5000000` at 100Kb resolution
mcoolData_100Kb <- readCool(file = mcoolFile, chrom = "2",
                            chromstart = 1000000, chromend = 5000000,
                            resolution = 100000)

## Read in data for chr2 at 2500Kb resolution 
mcoolData_2500Kb <- readCool(file = mcoolFile, chrom = "2",
                             resolution = 2500000)

PhanstielLab/plotgardener documentation built on Feb. 27, 2025, 8:22 p.m.