Package 'HiCParser'

Title: Parser for HiC data in R
Description: This package is a parser to import HiC data into R. It accepts several type of data: tabular files, Cooler `.cool` or `.mcool` files, Juicer `.hic` files or HiC-Pro `.matrix` and `.bed` files. The HiC data can be several files, for several replicates and conditions. The data is formated in an InteractionSet object.
Authors: Zytnicki Matthias [aut], Maigné Élise [aut, cre]
Maintainer: Maigné Élise <[email protected]>
License: LGPL
Version: 1.5.0
Built: 2026-05-30 08:00:36 UTC
Source: https://github.com/bioc/HiCParser

Help Index


A multiple format Hi-C data parser

Description

This package is a parser to import HiC data into R. It accepts several type of data: tabular files, Cooler '.cool' or '.mcool' files, Juicer '.hic' files or HiC-Pro '.matrix' and '.bed' files. The HiC data can be several files, for several replicates and conditions. The data is formated in an InteractionSet object.

Author(s)

Maintainer: Maigné Élise [email protected]

Authors:

See Also

Useful links:


Merge two InteractionSet objects

Description

Merge two different InteractionSet.

Usage

mergeInteractionSet(interactionSet1, interactionSet2, fill = NA)

Arguments

interactionSet1

The first InteractionSet.

interactionSet2

The second InteractionSet.

fill

Fill missing values with this.

Value

The merged InteractionSet.

Examples

path <- system.file("extdata", "hicsample_21.cool", package = "HiCParser")
object1 <- parseCool(path, conditions = 1, replicates = 1)
# Creating an object with a different condition
object2 <- parseCool(path, conditions = 2, replicates = 1)
objectMerged <- mergeInteractionSet(object1, object2)

Parser for data in cool format

Description

Parses interactions in .cool or .mcool format and returns an InteractionSet object.

Usage

parseCool(paths, binSize = NA, conditions, replicates)

Arguments

paths

A vector of paths to .cool or .mcool files.

binSize

The resolution (span of each position in number of bases). Optionally provided to select the appropriate resolution in .mcool files. Defaults to NULL.

conditions

A vector of condition names repeated along the replicates.

replicates

A vector of replicate names repeated along the conditions.

Details

To read .cool of .mcool files, the rhdf5 package is required. Please install it before running the function.

Value

An InteractionSet.

Examples

# EXAMPLE FOR .cool FORMAT
# Path to each file
pathsCool <- c(
    "path/to/condition-1.replicate-1.cool",
    "path/to/condition-1.replicate-2.cool",
    "path/to/condition-1.replicate-3.cool",
    "path/to/condition-2.replicate-1.cool",
    "path/to/condition-2.replicate-2.cool",
    "path/to/condition-2.replicate-3.cool"
)
# Condition and replicate of each file. Can be names instead of numbers.
conditions <- c(1, 1, 1, 2, 2, 2)
replicates <- c(1, 2, 3, 1, 2, 3)
if (FALSE) {
    library(rhdf5)
    object <- parseCool(
        paths,
        conditions = conditions,
        replicates = replicates
    )
}

# EXAMPLE FOR .mcool FORMAT
# Resolution
binSize <- 500000
# Path to each file
paths <- c(
    "path/to/condition-1.replicate-1.mcool",
    "path/to/condition-1.replicate-2.mcool",
    "path/to/condition-1.replicate-3.mcool",
    "path/to/condition-2.replicate-1.mcool",
    "path/to/condition-2.replicate-2.mcool",
    "path/to/condition-2.replicate-3.mcool"
)
# Condition and replicate of each file. Can be names instead of numbers.
conditions <- c(1, 1, 1, 2, 2, 2)
replicates <- c(1, 2, 3, 1, 2, 3)
if (FALSE) {
    # Instantiation of data set
    library(rhdf5)
    object <- parseCool(
        paths,
        conditions = conditions,
        replicates = replicates,
        binSize = binSize
    )
}

Parser for data in hic format

Description

Parses interactions in .hic format and returns an InteractionSet object.

Usage

parseHiC(paths, binSize, conditions, replicates)

Arguments

paths

A vector of paths to .hic files.

binSize

The resolution (span of each position in number of bases) to select within the .hic files.

conditions

A vector of condition names repeated along the replicates.

replicates

A vector of replicate names repeated along the conditions.

Value

An InteractionSet.

Examples

# Path to each file
paths <- c(
    "path/to/condition-1.replicate-1.hic",
    "path/to/condition-1.replicate-2.hic",
    "path/to/condition-1.replicate-3.hic",
    "path/to/condition-2.replicate-1.hic",
    "path/to/condition-2.replicate-2.hic",
    "path/to/condition-2.replicate-3.hic"
)
# Replicate and condition of each file. Can be names instead of numbers.
conditions <- c(1, 1, 1, 2, 2, 2)
replicates <- c(1, 2, 3, 1, 2, 3)
# Resolution to select
binSize <- 500000
if (FALSE) {
    # Instantiation of data set
    hic.experiment <- parseHiC(
        paths,
        conditions = conditions,
        replicates = replicates,
        binSize = binSize
    )
}

Parser for HiCPro data

Description

Parses interactions in pairs of .matrix and .bed files and returns an InteractionSet object.

Usage

parseHiCPro(matrixPaths, bedPaths, conditions, replicates)

Arguments

matrixPaths

A vector of paths to HiC-Pro matrix files.

bedPaths

A vector of paths to HiC-Pro bed files.

conditions

A vector of condition names repeated along the replicates.

replicates

A vector of replicate names repeated along the conditions.

Value

An InteractionSet.

Examples

# Path to each matrix file
matrixPaths <- c(
    "path/to/condition-1.replicate-1.matrix",
    "path/to/condition-1.replicate-2.matrix",
    "path/to/condition-1.replicate-3.matrix",
    "path/to/condition-2.replicate-1.matrix",
    "path/to/condition-2.replicate-2.matrix",
    "path/to/condition-2.replicate-3.matrix"
)

# Path to each bed file
bedPaths <- c(
    "path/to/condition-1.replicate-1.bed",
    "path/to/condition-1.replicate-2.bed",
    "path/to/condition-1.replicate-3.bed",
    "path/to/condition-2.replicate-1.bed",
    "path/to/condition-2.replicate-2.bed",
    "path/to/condition-2.replicate-3.bed"
)

# Condition and replicate of each file. Can be names instead of numbers.
conditions <- c(1, 1, 1, 2, 2, 2)
replicates <- c(1, 2, 3, 1, 2, 3)

if (FALSE) {
    # Instantiation of data set
    hic.experiment <- parseHiCPro(
        matrixPaths = matrixPaths,
        bedPaths = bedPaths,
        conditions = conditions,
        replicates = replicates
    )
}

Parser for tabular data

Description

Read the file, produce an InteractionSet object.

Usage

parseTabular(path, sep = '\t')

Arguments

path

A path to a tabular file.

sep

The separator of the tabular file. Default to tabulation.

Details

Accepts a tabular file with chromosome, position 1, position 2, and multiple replicate columns listing interaction counts. Null interactions do not have to be listed. Values must be separated by tabulations. The header must be chromosome position 1 position 2 x.y x.y x.y ... with x replaced by condition names and y replaced by replicate names.

Value

An InteractionSet object.

Examples

path <- system.file("extdata", "hicsample_21.tsv", package = "HiCParser")
object <- parseTabular(path, sep = "\t")