Import ..hic, .cool, .mcool or .bedpe data
Usage
ImportHiC(
file = NULL,
hicResolution = NULL,
chromSizes = NULL,
chrom_1 = NULL,
chrom_2 = NULL,
verbose = FALSE,
cores = 1,
hic_norm = "NONE",
hic_matrix = "observed",
cool_balanced = FALSE,
cool_weight_name = "weight",
cool_divisive_weights = FALSE,
h5_fill_upper = TRUE
)
Arguments
- file
<GRanges or PairsGRanges or GInteractions>: The genomic feature on which compute the extraction of HiC submatrix. Extension should be .hic, .cool, .mcool, .h5, .hdf5, .HDF5 or .bedpe" assuming .h5 and .hdf5 are only for cool (not mcool).
- hicResolution
: The HiC resolution. - chromSizes
<data.frame>: A data.frame where first colum correspond to the chromosomes names, and the second column correspond to the chromosomes lengths in base pairs.
- chrom_1
: The seqnames of first chromosmes (rows in matrix). - chrom_2
: The seqnames of second chromosmes (col in matrix). If NULL
variable will be assigned value of chrom_1 (Defalt NULL).- verbose
: Show the progression in console? (Default FALSE) - cores
: An integer to specify the number of cores. (Default 1) - hic_norm
: "norm" argument to supply to strawr::straw()
. This argument is for .hic format data only. Available norms can be obtained throughstrawr::readHicNormTypes()
. (Default "NONE").- hic_matrix
: "matrix" argument to supply to strawr::straw()
. This argument is for .hic format data only. Other options can be: "oe", "expected". (Default "observed").- cool_balanced
Import already balanced matrix? (Default: FALSE) - cool_weight_name
Name of the correcter in the cool file. (Default: weight). rhdf5::h5ls()
to see the available correctors.- cool_divisive_weights
Does the correcter vector contain divisive biases as in hicExplorer or multiplicative as in cooltools? (Default: FALSE) - h5_fill_upper
Do the matrix in h5 format need to be transposed? (Default: TRUE)
Details
ImportHiC
If you request "expected" values when importing .hic format data, you must do yourself the "oe" by importing manually the observed counts as well.
Prior to v.0.9.0 cooltools had multiplicative weight only, so make sure your correcters are divisive or multiplicative. https://cooler.readthedocs.io/en/stable/releasenotes.html#v0-9-0
When loading hic matrix in h5 format make sure you have enough momory to load the full matrix with all chromosomes regardless of values for chrom_1 and chrom_2 arguments. The function first loads the whole matrix, then extracts matrices per chromosome for the time being, it's easier ;).
Examples
# \donttest{
# Prepare Temp Directory
options(timeout = 3600)
temp.dir <- file.path(tempdir(), "HIC_DATA")
dir.create(temp.dir)
# Download .hic file
Hic.url <- paste0(
"https://4dn-open-data-public.s3.amazonaws.com/",
"fourfront-webprod/wfoutput/",
"7386f953-8da9-47b0-acb2-931cba810544/4DNFIOTPSS3L.hic"
)
HicOutput.pth <- file.path(temp.dir, "Control_HIC.hic")
HicOutput.pth <- normalizePath(HicOutput.pth)
#> Warning: path[1]="/tmp/Rtmppr5VCj/HIC_DATA/Control_HIC.hic": No such file or directory
if(.Platform$OS.type == "windows"){
download.file(Hic.url, HicOutput.pth, method = "auto",
extra = "-k",mode="wb")
}else{
download.file(Hic.url, HicOutput.pth, method = "auto", extra = "-k")
}
# Import .hic file
HiC_Ctrl.cmx_lst <- ImportHiC(
file = HicOutput.pth,
hicResolution = 100000,
chrom_1 = c("2L", "2L", "2R"),
chrom_2 = c("2L", "2R", "2R")
)
# Download .mcool file
Mcool.url <- paste0(
"https://4dn-open-data-public.s3.amazonaws.com/",
"fourfront-webprod/wfoutput/",
"4f1479a2-4226-4163-ba99-837f2c8f4ac0/4DNFI8DRD739.mcool"
)
McoolOutput.pth <- file.path(temp.dir, "HeatShock_HIC.mcool")
HicOutput.pth <- normalizePath(McoolOutput.pth)
#> Warning: path[1]="/tmp/Rtmppr5VCj/HIC_DATA/HeatShock_HIC.mcool": No such file or directory
if(.Platform$OS.type == "windows"){
download.file(Mcool.url, McoolOutput.pth, method = "auto",
extra = "-k",mode="wb")
}else{
download.file(Mcool.url, McoolOutput.pth, method = "auto",
extra = "-k")
}
# Import .mcool file
HiC_HS.cmx_lst <- ImportHiC(
file = McoolOutput.pth,
hicResolution = 100000,
chrom_1 = c("2L", "2L", "2R"),
chrom_2 = c("2L", "2R", "2R")
)
# }
# Import .h5 file
h5_path <- system.file("extdata",
"Control_HIC_10k_2L.h5",
package = "HicAggR", mustWork = TRUE
)
binSize=10000
hicLst <- ImportHiC(
file = h5_path,
hicResolution = binSize,
chromSizes = data.frame(seqnames = c("2L"),
seqlengths = c(23513712)),
chrom_1 = c("2L")
)