Introduction

hicream is an R package designed to perform Hi-c data differential analysis. More specifically, it performs a pixel-level differential analysis using diffHic and, using a two-dimensional connectivity constrained clustering, renders a post hoc bound on True Discovery Proportion for each cluster. This method allows to identify differential genomic regions and quantifies signal in those regions (Jorge et al., 2026).

library("hicream", warn.conflicts = FALSE)

How to load external data?

Using hicream requires to load data that corresponds to Hi-C matrices and their index, the latter in bed format. In the following code, the paths to Hi-C matrices and the index file path are used in the loadData function alongside the chromosome number. The option normalize = TRUE allows to perform a cyclic LOESS normalization. The output is an InteractionSet object.

replicates <- 1:2
cond <- "90"
allBegins <- interaction(expand.grid(replicates, cond), sep = "-")
allBegins <- as.character(allBegins)
chromosome <- 1
nbChr <- 1
allMat <- sapply(allBegins, function(ab) {
  matFile <- paste0("Rep", ab, "-chr", chromosome, "_200000.bed")
})
index <- system.file("extdata", "index.200000.longest18chr.abs.bed",
                     package = "hicream")
format <- rep("HiC-Pro", length(replicates) * length(cond) * nbChr)
binsize <- 200000
files <- system.file("extdata", unlist(allMat), package = "hicream")
exData <- loadData(files, index, chromosome, normalize = TRUE)
##  chr(0)
## 
##  chr(0)
## 

pighic dataset

The pighic dataset has been produced using 6 Hi-C matrices (3 in each condition) obtained from two different developmental stages of pig embryos (90 and 110 days of gestation) corresponding to chromosome 1. The dataset contains two elements, the first is an output of the loadData function corresponding to normalized data. The second is the vector giving, for each matrix, the condition it belongs to.

data("pighic")
head(pighic)
## $data
## class: InteractionSet 
## dim: 21 6 
## metadata(1): width
## assays(2): counts offset
## rownames: NULL
## rowData names(2): anchor1.id anchor2.id
## colnames: NULL
## colData names(1): totals
## type: ReverseStrictGInteractions
## regions: 6
## 
## $conditions
## [1] "90"  "90"  "90"  "110" "110" "110"

Perform hicream test

Once data have been loaded, the three steps of the analysis can be performed.

Use performTest function

In this first step, the output of a loadData object is used, with a vector indicating the condition of each sample. Here, we use data stored in pighic. performTest outputs the result of the diffHic pixel-level differential analysis.

resdiff <- performTest(pighic$data, pighic$conditions)
resdiff
## Testing for differential interactions using diffHic.
## 
##   region1 region2    p.value     p.adj       logFC
## 1    1125    1125 0.71830813 0.8380262 -0.01907149
## 2    1125    1126 0.05614974 0.2457583 -0.16174866
##  [ reached 'max' / getOption("max.print") -- omitted 19 rows ]
summary(resdiff)
## Summary of diffHic results.
##     p.value              p.adj              logFC          
##  Min.   :0.0001986   Min.   :0.004171   Min.   :-0.161749  
##  1st Qu.:0.0705413   1st Qu.:0.246894   1st Qu.:-0.033784  
##  Median :0.2773831   Median :0.529549   Median : 0.002662  
##  Mean   :0.3987156   Mean   :0.583474   Mean   : 0.022316  
##  3rd Qu.:0.7163982   3rd Qu.:0.838026   3rd Qu.: 0.040938  
##  Max.   :0.9598874   Max.   :0.959887   Max.   : 0.351296

Several plotting options allow to look at the \(p\)-value map, adjusted \(p\)-value map or log-fold-change map.

plot(resdiff)

plot(resdiff, whichPlot = "p.adj")

plot(resdiff, whichPlot = "logFC")

Perform two-dimensional connectivity-constrained clustering

The AggloClust2D function uses either the output of loadData or resdiff functions. If the output of loadData is used, the clustering is performed on the counts. Using the output of resdiff amounts to performing clustering on adjusted \(p\)-values and log-fold-changes.

In both cases, a connectivity graph of pixels is built and a two-dimensional hierarchical clustering under the connectivity constraint is performed. The function renders a clustering corresponding to the optimal number of clusters found by the elbow heuristic. However, a clustering corresponding to any other number of clusters (chosen by the user) can be obtained by specifying a value for the input argument nbClust.

res2D_counts <- AggloClust2D(pighic$data)
res2D_counts
## Tree obtained from constrained 2D clustering.
## 
## Call:
## AggloClust2D(pighic$data)
## 
## Cluster method   : Constrained HC with Ward linkage from sklearn 
## Distance         : euclidean 
## Number of objects: 21 
## 
## 
## Optimal number of clusters: 7 
## 
## Clustering:
## 1 1 5 2 2 2 1 1 2 4 ...
summary(res2D_counts)
## Summary of 2D constrained clustering results.
## 
## Call:
## AggloClust2D(pighic$data)
## 
## Cluster method   : Constrained HC with Ward linkage from sklearn 
## Distance         : euclidean 
## Number of objects: 21
res2D_diff <- AggloClust2D(resdiff)
res2D_diff
## Tree obtained from constrained 2D clustering.
## 
## Call:
## AggloClust2D(resdiff)
## 
## Cluster method   : Constrained HC with Ward linkage from sklearn 
## Distance         : euclidean 
## Number of objects: 21 
## 
## 
## Optimal number of clusters: 3 
## 
## Clustering:
## 1 1 1 1 3 1 1 1 1 1 ...
summary(res2D_diff)
## Summary of 2D constrained clustering results.
## 
## Call:
## AggloClust2D(resdiff)
## 
## Cluster method   : Constrained HC with Ward linkage from sklearn 
## Distance         : euclidean 
## Number of objects: 21

Plotting the output shows the tree that corresponds to the hierarchy of clusters.

plot(res2D_diff)

Perform post hoc inference

Post hoc inference is performed by the postHoc function, using the output of performTest, and a clustering (the latter can be obtained with AggloClust2D). The user sets a level of test confidence \(\alpha\), typically equal to \(0.05\).

clusters <- res2D_diff$clustering
alpha <- 0.05
resposthoc <- postHoc(resdiff, clusters, alpha)
resposthoc
## Posthoc results.
## 
## # A tibble: 21 × 12
## # Groups:   clust [3]
##    region1 region2 clust   TDP p.value p.adj    logFC meanlogFC varlogFC
##      <int>   <int> <int> <dbl>   <dbl> <dbl>    <dbl>     <dbl>    <dbl>
##  1    1125    1125     1     0  0.718  0.838 -0.0191   -0.00822  0.00454
##  2    1125    1126     1     0  0.0561 0.246 -0.162    -0.00822  0.00454
##  3    1125    1127     1     0  0.800  0.885 -0.00888  -0.00822  0.00454
##  4    1125    1128     1     0  0.865  0.909 -0.00885  -0.00822  0.00454
##  5    1125    1129     3     0  0.0309 0.246  0.273     0.273   NA      
##  6    1125    1130     1     0  0.277  0.530 -0.0644   -0.00822  0.00454
##  7    1126    1126     1     0  0.716  0.838  0.0250   -0.00822  0.00454
##  8    1126    1127     1     0  0.194  0.510 -0.0628   -0.00822  0.00454
##  9    1126    1128     1     0  0.423  0.740  0.0353   -0.00822  0.00454
## 10    1126    1129     1     0  0.254  0.530  0.0483   -0.00822  0.00454
## # ℹ 11 more rows
## # ℹ 3 more variables: propPoslogFC <dbl>, triangleScore <dbl>,
## #   stripeScore <dbl>
summary(resposthoc)
## Summary of post hoc results.
##       TDP             p.value              p.adj              logFC          
##  Min.   :0.00000   Min.   :0.0001986   Min.   :0.004171   Min.   :-0.161749  
##  1st Qu.:0.00000   1st Qu.:0.0705413   1st Qu.:0.246894   1st Qu.:-0.033784  
##  Median :0.00000   Median :0.2773831   Median :0.529549   Median : 0.002662  
##  Mean   :0.04762   Mean   :0.3987156   Mean   :0.583474   Mean   : 0.022316  
##  3rd Qu.:0.00000   3rd Qu.:0.7163982   3rd Qu.:0.838026   3rd Qu.: 0.040938  
##  Max.   :1.00000   Max.   :0.9598874   Max.   :0.959887   Max.   : 0.351296  
##   propPoslogFC    triangleScore    stripeScore
##  Min.   :0.4737   Min.   :0.500   Min.   :0   
##  1st Qu.:0.4737   1st Qu.:1.056   1st Qu.:0   
##  Median :0.4737   Median :1.056   Median :0   
##  Mean   :0.5238   Mean   :1.003   Mean   :0   
##  3rd Qu.:0.4737   3rd Qu.:1.056   3rd Qu.:0   
##  Max.   :1.0000   Max.   :1.056   Max.   :0

Plotting the output of postHoc function shows the minimal proportion of True Discoveries in each cluster.

plot(resposthoc)

The clusterPCA function can be used to plot the variable loadings for the first two principal components of the PCA performed on cluster characteristics.

p <- clusterPCA(resposthoc)
p

References

Jorge E., Hocking T.D., Neuvial P., Vialaneix N. and Foissac S. (2026) hicream: a flexible framework to identify significantly different regions in Hi-C data. Bioinformatics, 42(9), btag631. DOI: 10.1093/bioinformatics/btag631.

Session Information

sessionInfo()
## R version 4.6.2 (2026-10-29)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.04.1 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=C              
##  [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Europe/Paris
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] hicream_0.1.0     reticulate_1.47.0
## 
## loaded via a namespace (and not attached):
##   [1] tidyselect_1.2.1            viridisLite_0.4.3          
##   [3] dplyr_1.2.1                 farver_2.1.2               
##   [5] viridis_0.6.5               Biostrings_2.80.2          
##   [7] S7_1.0.0                    bitops_1.1-0               
##   [9] RCurl_1.98-1.20             fastmap_1.2.0              
##  [11] GenomicAlignments_1.48.0    XML_3.99-0.25              
##  [13] digest_0.6.39               lifecycle_1.0.5            
##  [15] capushe_1.1.3               statmod_1.5.2              
##  [17] magrittr_2.0.5              compiler_4.6.2             
##  [19] rlang_1.3.0                 sass_0.4.10                
##  [21] tools_4.6.2                 yaml_2.3.12                
##  [23] rtracklayer_1.72.0          knitr_1.52                 
##  [25] Rhtslib_3.8.0               labeling_0.4.3             
##  [27] S4Arrays_1.12.1             curl_8.1.0                 
##  [29] here_1.0.2                  DelayedArray_0.38.2        
##  [31] plyr_1.8.9                  RColorBrewer_1.1-3         
##  [33] abind_1.4-8                 BiocParallel_1.46.0        
##  [35] withr_3.0.3                 BiocGenerics_0.58.1        
##  [37] grid_4.6.2                  stats4_4.6.2               
##  [39] Rhdf5lib_2.0.0              edgeR_4.10.7               
##  [41] ggplot2_4.0.4               scales_1.4.0               
##  [43] MASS_7.3-66                 SummarizedExperiment_1.42.0
##  [45] cli_3.6.6                   rmarkdown_2.32             
##  [47] crayon_1.5.3                auk_0.10.0                 
##  [49] generics_0.1.4              otel_0.3.0                 
##  [51] metapod_1.20.0              reshape2_1.4.5             
##  [53] rjson_0.2.23                httr_1.4.9                 
##  [55] rhdf5_2.56.1                cachem_1.1.0               
##  [57] stringr_1.6.0               splines_4.6.2              
##  [59] parallel_4.6.2              restfulr_0.0.17            
##  [61] XVector_0.52.0              matrixStats_1.5.0          
##  [63] vctrs_0.7.3                 Matrix_1.7-6               
##  [65] jsonlite_2.0.0              IRanges_2.46.0             
##  [67] S4Vectors_0.50.3            dendextend_1.19.1          
##  [69] adjclust_0.6.11             locfit_1.5-9.12            
##  [71] limma_3.68.5                jquerylib_0.1.4            
##  [73] glue_1.8.1                  codetools_0.2-20           
##  [75] stringi_1.8.9               gtable_0.3.6               
##  [77] GenomeInfoDb_1.48.0         GenomicRanges_1.64.0       
##  [79] BiocIO_1.22.0               UCSC.utils_1.8.0           
##  [81] tibble_3.3.1                pillar_1.11.1              
##  [83] rappdirs_0.3.4              rhdf5filters_1.24.1        
##  [85] csaw_1.46.0                 htmltools_0.5.9            
##  [87] Seqinfo_1.2.0               BSgenome_1.80.0            
##  [89] R6_2.6.1                    sparseMatrixStats_1.24.0   
##  [91] diffHic_1.44.0              rprojroot_2.1.1            
##  [93] evaluate_1.0.5              lattice_0.23-1             
##  [95] Biobase_2.72.0              cigarillo_1.2.1            
##  [97] png_0.1-9                   Rsamtools_2.28.0           
##  [99] bslib_0.12.0                Rcpp_1.1.2                 
## [101] InteractionSet_1.40.0       gridExtra_2.3.1            
## [103] SparseArray_1.12.3          xfun_0.58                  
## [105] MatrixGenerics_1.24.0       pkgconfig_2.0.3