HiContacts
Workflows
Standard Workflow
library(HiCExperiment)
library(HiContacts)
library(HiContactsData)
# Import Hi-C matrix
cool_file <- HiContactsData('yeast_wt', format = 'cool')
hic <- import(cool_file, format = 'cool')
# Perform matrix arithmetic
hic_detrended <- detrend(hic)
hic_smooth <- despeckle(hic)
# Plot contact map
plotMatrix(hic_smooth, use.scores = 'balanced.despeckled')
Input: A HiCExperiment object.
Output: Detrended, smoothed, or merged contact maps and their corresponding plots.
Contact Map Analysis
library(HiCExperiment)
library(HiContacts)
library(HiContactsData)
mcool_file <- HiContactsData('yeast_wt', format = 'mcool')
hic <- import(mcool_file, format = 'mcool', resolution = 1000)
# Calculate cis-trans ratios
ratios <- cisTransRatio(hic)
# Compute distance decay P(s) curves
ps <- distanceLaw(hic)
Input: A HiCExperiment object, optionally with an associated pairs file.
Output: A tibble of cis-trans ratios and distance decay P(s) curves.
Topological Feature Mapping
library(HiCExperiment)
library(HiContacts)
library(HiContactsData)
mcool_file <- HiContactsData('yeast_wt', format = 'mcool')
hic <- import(mcool_file, format = 'mcool', resolution = 16000)
# Map chromosome compartments
hic <- getCompartments(hic, chromosomes = c('XV', 'XVI'))
# Compute insulation scores and borders
hic <- refocus(hic, 'II:1-300000') |>
zoom(resolution = 1000) |>
getDiamondInsulation(window_size = 8000) |>
getBorders()
Input: A HiCExperiment object.
Output: A HiCExperiment object updated with compartments, insulation scores, and domain borders.
When to Use
- Visualizing Hi-C contact matrices as heatmaps (square or horizontal) using
plotMatrix().
- Performing matrix arithmetic such as detrending (
detrend()), autocorrelating (autocorrelate()), merging (merge()), dividing (divide()), and smoothing (despeckle()).
- Mapping chromosome compartments (
getCompartments()), insulation scores (getDiamondInsulation()), and domain borders (getBorders()).
- Analyzing distance decay curves using
distanceLaw() and plotting them with plotPs() or plotPsSlope().
When NOT to Use
- For initial raw sequence alignment or filtering of fastq files, use pipelines like HiC-Pro, distiller, or Juicer instead of
HiContacts.
- For general genomic interval manipulation without interaction data, use
GenomicRanges or IRanges directly.
Data Requirements
- A
HiCExperiment object imported from .cool, .mcool, .hic, or HiC-Pro files.
- For accurate distance decay P(s) curves, an associated pairs file (e.g.,
.pairs.gz) should be linked using pairsFile(hic) <- ....
Key Parameters
- use.scores ('balanced'): Specifies which interaction score type to plot or analyze (e.g.,
'balanced', 'detrended', 'autocorrelated').
- limits (NULL): A numeric vector of length 2 specifying the color scale limits in
plotMatrix().
- maxDistance (NULL): Maximum distance from the diagonal to plot in horizontal matrices.
- focal.size (5): Size of the focal window used for smoothing in
despeckle().
- window_size (8000): Window size in base pairs for computing diamond insulation scores in
getDiamondInsulation().
- chromosomes (NULL): Vector of chromosome names to restrict compartment calling in
getCompartments().
Best Practices
- Always use normalized scores (like
'balanced') rather than raw counts for comparative analyses.
- Link a physical pairs file using
pairsFile() before running distanceLaw() to avoid approximations in the P(s) curve.
- Export computed topological features (e.g., compartments or insulation scores) to standard formats like BigWig or BED using
rtracklayer::export().
Common Pitfalls
- Running
distanceLaw() without a pairs file: This results in an approximation warning. Fix by assigning a pairs file to the HiCExperiment object first.
- Plotting matrices with extreme dynamic ranges without log transformation: Use
scale = 'log10' in plotMatrix() to improve visualization.
Alternatives
diffHic: For differential analysis of Hi-C data using biological replicates.
Citations
- Serizay J, Matthey-Doret C, Bignaud A, Baudry L, Koszul R (2024). "Orchestrating chromosome conformation capture analysis with Bioconductor." Nature Communications, 15, 1-9. doi:10.1038/s41467-024-44761-x.
References
1---2name: hicontacts3description: HiContacts4---56# HiContacts78## Workflows910### Standard Workflow1112```r13library(HiCExperiment)14library(HiContacts)15library(HiContactsData)1617# Import Hi-C matrix18cool_file <- HiContactsData('yeast_wt', format = 'cool')19hic <- import(cool_file, format = 'cool')2021# Perform matrix arithmetic22hic_detrended <- detrend(hic)23hic_smooth <- despeckle(hic)2425# Plot contact map26plotMatrix(hic_smooth, use.scores = 'balanced.despeckled')27```28Input: A `HiCExperiment` object.29Output: Detrended, smoothed, or merged contact maps and their corresponding plots.3031### Contact Map Analysis3233```r34library(HiCExperiment)35library(HiContacts)36library(HiContactsData)3738mcool_file <- HiContactsData('yeast_wt', format = 'mcool')39hic <- import(mcool_file, format = 'mcool', resolution = 1000)4041# Calculate cis-trans ratios42ratios <- cisTransRatio(hic)4344# Compute distance decay P(s) curves45ps <- distanceLaw(hic)46```47Input: A `HiCExperiment` object, optionally with an associated pairs file.48Output: A tibble of cis-trans ratios and distance decay P(s) curves.4950### Topological Feature Mapping5152```r53library(HiCExperiment)54library(HiContacts)55library(HiContactsData)5657mcool_file <- HiContactsData('yeast_wt', format = 'mcool')58hic <- import(mcool_file, format = 'mcool', resolution = 16000)5960# Map chromosome compartments61hic <- getCompartments(hic, chromosomes = c('XV', 'XVI'))6263# Compute insulation scores and borders64hic <- refocus(hic, 'II:1-300000') |> 65 zoom(resolution = 1000) |> 66 getDiamondInsulation(window_size = 8000) |> 67 getBorders()68```69Input: A `HiCExperiment` object.70Output: A `HiCExperiment` object updated with compartments, insulation scores, and domain borders.7172## When to Use73- Visualizing Hi-C contact matrices as heatmaps (square or horizontal) using `plotMatrix()`.74- Performing matrix arithmetic such as detrending (`detrend()`), autocorrelating (`autocorrelate()`), merging (`merge()`), dividing (`divide()`), and smoothing (`despeckle()`).75- Mapping chromosome compartments (`getCompartments()`), insulation scores (`getDiamondInsulation()`), and domain borders (`getBorders()`).76- Analyzing distance decay curves using `distanceLaw()` and plotting them with `plotPs()` or `plotPsSlope()`.7778## When NOT to Use79- For initial raw sequence alignment or filtering of fastq files, use pipelines like HiC-Pro, distiller, or Juicer instead of `HiContacts`.80- For general genomic interval manipulation without interaction data, use `GenomicRanges` or `IRanges` directly.8182## Data Requirements83- A `HiCExperiment` object imported from `.cool`, `.mcool`, `.hic`, or HiC-Pro files.84- For accurate distance decay P(s) curves, an associated pairs file (e.g., `.pairs.gz`) should be linked using `pairsFile(hic) <- ...`.8586## Key Parameters87- **use.scores** ('balanced'): Specifies which interaction score type to plot or analyze (e.g., `'balanced'`, `'detrended'`, `'autocorrelated'`).88- **limits** (NULL): A numeric vector of length 2 specifying the color scale limits in `plotMatrix()`.89- **maxDistance** (NULL): Maximum distance from the diagonal to plot in horizontal matrices.90- **focal.size** (5): Size of the focal window used for smoothing in `despeckle()`.91- **window_size** (8000): Window size in base pairs for computing diamond insulation scores in `getDiamondInsulation()`.92- **chromosomes** (NULL): Vector of chromosome names to restrict compartment calling in `getCompartments()`.9394## Best Practices95- Always use normalized scores (like `'balanced'`) rather than raw counts for comparative analyses.96- Link a physical pairs file using `pairsFile()` before running `distanceLaw()` to avoid approximations in the P(s) curve.97- Export computed topological features (e.g., compartments or insulation scores) to standard formats like BigWig or BED using `rtracklayer::export()`.9899## Common Pitfalls100- Running `distanceLaw()` without a pairs file: This results in an approximation warning. Fix by assigning a pairs file to the `HiCExperiment` object first.101- Plotting matrices with extreme dynamic ranges without log transformation: Use `scale = 'log10'` in `plotMatrix()` to improve visualization.102103## Alternatives104- `diffHic`: For differential analysis of Hi-C data using biological replicates.105106## Citations107- Serizay J, Matthey-Doret C, Bignaud A, Baudry L, Koszul R (2024). "Orchestrating chromosome conformation capture analysis with Bioconductor." Nature Communications, 15, 1-9. doi:10.1038/s41467-024-44761-x.108109## References110- Homepage: bioconductor.org/packages/HiContacts111- Vignette: https://bioconductor.org/packages/release/bioc/vignettes/HiContacts/inst/doc/HiContacts.html