Read a .(m)cool file and return Hi-C data as a dataframe
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
)A character value specifying the path to the .(m)cool file.
Chromosome of data, as a string.
Integer start position on chromosome.
Integer end position on chromosome.
Alternate chromosome for interchromosomal data, as a string.
Alternate chromosome integer start position for interchromosomal data.
Alternate chromosome integer end position for interchromosomal data.
A numeric specifying the width of each pixel. "auto" will attempt to choose a resolution in basepairs based on the size of the region.
A numeric vector of length 2 specifying the range of interaction scores, where extreme values will be set to the max or min.
Character value specifying hic data normalization method.
This value must be found in the .(m)cool file.
Default value is norm = "NONE".
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.
An optional pgParams object containing relevant function parameters.
A logical indicating whether or not to print messages.
Returns a 3-column dataframe in sparse upper triangular
format with the following columns: chrom, altchrom,
counts.
## .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, mode = "wb")
## Read in region `chr2:10000000-22000000` at 1000Kb cool file resolution
coolData <- readCool(file = coolFile, chrom = "chr2", chromstart = 10000000,
chromend = 22000000,
resolution = 1000000)
#> Read in .cool file with NONE normalization at 1e+06 BP resolution.
## .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, mode = "wb")
## Read in region `chr2:1000000-5000000` at 100Kb resolution
mcoolData_100Kb <- readCool(file = mcoolFile, chrom = "2",
chromstart = 1000000, chromend = 5000000,
resolution = 100000)
#> Read in .mcool file with NONE normalization at 1e+05 BP resolution.
## Read in data for chr2 at 2500Kb resolution
mcoolData_2500Kb <- readCool(file = mcoolFile, chrom = "2",
resolution = 2500000)
#> Read in .mcool file with NONE normalization at 2500000 BP resolution.