Package: hicpeaks
HiCPeakshicpeaksprovides a Python implementation for BH-FDR and HiCCUPS[1].Installationhicpeaksis developed and tested on UNIX-like operating systems, and the following packages or softwares are
required:Python requirements:Python 2.7/3.5+MultiprocessNumpyScipyMatplotlibPandasStatsmodelsScikit-LearnH5pyCoolerOther requirements:ucsc-fetchchromsizesconda, an excellent package manager, can be used to install all requirements above.Install Requirements Through CondaAll above requirements can be installed through the conda package manager.NoteIf you have the Anaconda Distribution installed, you already have it.Choose an appropriateMiniconda installerfor your system,
then in your terminal window type the following and follow the prompts on the installer screens:$ bash Miniconda3-latest-Linux-x86_64.shAfter that, update the environment variables to finish the Conda installation:$ source ~/.bashrcNext, you need to set up channels to make all packages listed above accessible (note
that the order is important to guarantee the correct priority):$ conda config --add channels defaults
$ conda config --add channels bioconda
$ conda config --add channels conda-forgeThen type and execute the commands below to satisfy the requirements:$ conda create -n HiCPeaks numpy scipy matplotlib pandas statsmodels scikit-learn h5py multiprocess cooler ucsc-fetchchromsizes
$ conda activate HiCPeaksInstall hicpeaksFinally, hicpeaks can be installed from PyPI using pip:$ pip install -U hicpeaksOverviewhicpeakscomes with 6 scripts:toCooler,pyBHFDR,pyHICCUPS,combine-resolutions,peak-plot,
andapa-analysis.toCoolerStore TXT/NPZ bin-level Hi-C data into thecoolercontainer.I have included a sample data with thehicpeakssource code to illustrate how you should prepare your
data in TXT format. It’s quite easy, just remember 3 points: 1. the file name should follow this pattern
“chrom1_chrom2.txt” (remove prefix from your chromosome labels, i.e. “chr1” should be “1”, and “chrX” should
be “X”); 2. each file should only contain 3 columns, corresponding to “bin1” of “chrom1”, “bin2” of “chrom2”,
and “contact frequency” (don’tperform any normalization processes); 3. all files at the same resolution
should be placed in the same folder.NPZ format is another bin-level Hi-C data container which can extremely speed up data loading.hicpeakssupports NPZ files generated by old versions ofrunHiC (<0.8.0)andTADLib (<0.4.0).pyBHFDRA CPU-based python implementation for the BH-FDR algorithm. Rao et al (2014) stated in their supplementary material that
this algorithm is robust enough to obtain all main results of their paper. Compared with HiCCUPS, BH-FDR doesn’t use
λ-chunk in multiple hypothesis tests, and only considers the Donut background region when calculating the
expected values.pyHICCUPSA CPU-based python implementation for the HiCCUPS algorithm. Besides the donut region, HiCCUPS also considers the
lower-left, the vertical, and the horizontal backgrounds when calculating the expected values. And λ-chunk is used
to overcome several multiple hypothesis testing challenges for Hi-C data. Finally, while BH-FDR can only detect chromatin
interactions near the diagonal (<2Mb), HiCCUPS is able to detect super long-range interactions. Here,pyHICCUPSkeeps
all main concepts of the original algorithm except for these points:pyHICCUPSexcludes vertical and horizontal backgrounds from its calculation.There are two critical parameters related to the loop definition in HiCCUPS: the peak widthpand the donut widthw.
In original implementation, they are set exclusively for each certain resolution, specifically,p=1andw=3at 25Kb,p=2andw=5at 10Kb, andp=4andw=7at 5Kb. To improve the sensitivity,pyHICCUPScan calculate and output
the union peak calls from all parameter combinations(1,3),(2,5),(4,7)in a single run.Due to computational complexity, the search space still need to be limited, for example, within 5Mb/10Mb.combine-resolutionsCombine peak calls from different resolutions in a way similar to originalHiCCUPS. Briefly, it excludes redundant lower
resolution peaks while filters out low-confidence high resolution peaks.peak-plotVisualize peaks (or chromatin loops) on a local contact matrix.apa-analysisPerform Aggregate Peak Analysis (APA).QuickStartThis tutorial will guide you through the basic usage of all scripts distributed withhicpeaks.toCoolerIf you have already created a cooler file for your Hi-C data, skip to the next sectionpyBHFDR and pyHICCUPS,
go on otherwise.First, you should store your TXT/NPZ bin-level Hi-C data into a cooler file by usingtoCooler. Let’s begin
with our sample data below. Suppose you are in thehicpeakssource code root folder: change your current
working directory to the sub-folderexample:$ cd example
$ ls -lh *

-rw-r--r-- 1 xtwang  18 May  4 18:00 datasets
-rw-r--r-- 1 xtwang 293 May  4 18:00 hg38.chromsizes

25K:
total 12M
-rw-r--r-- 1 xtwang 12M May  4 18:00 21_21.txtThere is a sub-directory called25Kand a metadata file calleddatasets. The25Kfolder contains chromatin
interactions of chromosome 21 of the K562 cell line at the 25K resolution, and thedatasetsdescribes the data
that need to be transformed:$ cd 25K
$ head -5 21_21.txt

201 703     1
201 1347    1
201 1351    1
201 1524    1
201 1691    1

$ cd ..
$ cat datasets

res:25000
  ./25KYou should construct your TXT files (no head, no tail) with 3 columns, which indicate “bin1 of the 1st chromosome”,
“bin2 of the 2nd chromosome”, and “contact frequency” respectively. SeeOverviewabove.To transform this data to thecoolerformat, just run the command below:$ toCooler -O K562-MboI-parts.cool -d datasets --assembly hg38 --nproc 1toCoolerroutinely fetch sizes of each chromosome from UCSC with the provided genome assembly name (here hg38).
However, if your reference genome is not holded in UCSC, you can also build a file like “hg38.chromsizes” in
current working directory, and pass the file path to the argument “–chromsizes-file”.TypetoCoolerwith no arguments on your terminal to print detailed help information for each parameter.For this dataset,toCoolerwill create a cooler file named “K562-MboI-parts.cool”, and your data will be stored under
the URI “K562-MboI-parts.cool::25000”.This tutorial only illustrates a very simple case, in fact the metadata file may contain list of resolutions (if you
have data at different resolutions for the same cell line) and corresponding folder paths (both relative and absolute
path are accepted, and if your data are in the NPZ format, this path should point to the NPZ file):res:10000
  /absoultepath/10K

res:25000
  ../relativepath/25K

res:40000
  /npzfile/anyprefix.npzThentoCoolerwill generate a single cooler file storing all the specified data under different cooler URI.
Suppose your cool file is named “specified_cooler_path”, the above data will be stored at
“specified_cooler_path::10000”, “specified_cooler_path::25000”, and “specified_cooler_path::40000”, respectively.pyBHFDR and pyHICCUPSAfter you have obtained a cool file, you can call peaks or chromatin loops usingpyBHFDRorpyHICCUPS:$ pyBHFDR -O K562-MboI-BHFDR-loops.txt -p K562-MboI-parts.cool::25000 -C 21 --pw 1 --ww 3Or:$ pyHICCUPS -O K562-MboI-HICCUPS-loops.txt -p K562-MboI-parts.cool::25000 --pw 1 2 4 --ww 3 5 7 --only-anchorsTypepyBHFDRorpyHICCUPSon your terminal to print detailed help information for each parameter.Before step to the next section, let’s list the contents under current working directory again:$ ls -lh

total 852K
drwxr-xr-x 4 xtwang  128 May  4 18:21 25K/
-rw-r--r-- 1 xtwang  17K May  4 18:23 K562-MboI-BHFDR-loops.txt
-rw-r--r-- 1 xtwang  15K May  4 18:23 K562-MboI-HICCUPS-loops.txt
-rw-r--r-- 1 xtwang 723K May  4 18:22 K562-MboI-parts.cool
-rw-r--r-- 1 xtwang   18 May  4 18:21 datasets
-rw-r--r-- 1 xtwang  293 May  4 18:21 hg38.chromsizes
-rw-r--r-- 1 xtwang 2.2K May  4 18:23 pyBHFDR.log
-rw-r--r-- 1 xtwang 8.5K May  4 18:23 pyHICCUPS.log
-rw-r--r-- 1 xtwang  17K May  4 18:22 tocooler.logThe detected loops are reported in a customizedbedpeformat. The first 10 columns are identical to theofficial definition,
and the additional fields are:Fold enrichment score calculated from the donut background.The p value calculated from the donut background.The q value calculated from the donut background.Fold enrichment score calculated from the lower-left background.The p value calculated from the lower-left background.The q value calculated from the lower-left background.Peak VisualizationNow, you can visualize the detected peaks/loops usingpeak-plot:$ peak-plot -O test-HICCUPS.png -p K562-MboI-parts.cool::25000 -I K562-MboI-HICCUPS-loops.txt \
  -C 21 -S 25000000 -E 29500000 --balance-type ICE --vmin 0 --vmax 0.008The output figure should look like this:Aggregate Peak AnalysisTo inspect the overall loop patterns of the detected peaks, you can use theapa-analysisscript:$ apa-analysis -O apa.png -p K562-MboI-parts.cool::25000 -I K562-MboI-HICCUPS-loops.txt -U --vmax 2The output plot should look like this:Combine different resolutionsThe inputs tocombine-resolutionsare loop annotation files (bedpe) at different resolutions. If an interaction
is detected as a peak in both resolutions, this script records the precise coordinates in finer resolutions and discards
the coarser resolution one. And a long-range (determined by the--min-disparameter) peak call at high resolutions
(any resolutions lower than the--good-rescutoff, note that lower values correspond to higher resolutions) will be
treated as a false positive if it could not be identified at lower resolutions (any resolutions equal to or greater than
the--good-rescutoff). Here’s apseudocommand with 3 loop files at 5Kb, 10Kb, and 20Kb respectively:$ combine-resolutions -O K562-MboI-pyHICCUPS-combined.bedpe -p K562-MboI-pyHICCUPS-5K.txt K562-MboI-pyHICCUPS-10K.txt K562-MboI-pyHICCUPS-20K.txt -R 5000 10000 20000 -G 20000 -M 100000PerformanceThe table below shows a performance test for thetoCooler,pyBHFDR, andpyHICCUPSscripts:Processor: 2.6 GHz Intel Core i7, Memory: 16 GB 2400 MHz DDR4Software version:hicpeaks 0.3.0At the 40Kb resolution,--pwand--wware set to 1 and 3, respectively; at the 10Kb resolution,
they are set to 2 and 5, respectively.The original Hi-C data is stored in TXTNumber of proccesses assigned: 1Valid contacts: total number of non-zero pixels in intra-chromosomal matricesRunning time format: hr: min: secDatasetsValid contactstoCoolerpyBHFDRpyHICCUPSMemory UsageRunning timeMemory UsageRunning timeMemory UsageRunning timeT47D (40K)25,216,875<600M0:07:55<600M0:01:34<600M0:04:17K562 (40K)49,088,465<1.2G0:21:37<1.0G0:01:49<1.0G0:03:21K562 (10K)139,884,876<3.0G1:00:07<2.0G0:24:53<4.0G1:57:33NoteBothpyBHFDRandpyHICCUPSsupport parallel computation (--nproc). If your computer has sufficient memory, the
calculation should end within 30 minutes even for high-resolution matrices.Release NotesVersion 0.3.5 (08/28/2022)Added parameters topeak-plotandapa-analysisso that the output figures can be more finely tunedVersion 0.3.4 (05/04/2019)Improved the efficiency of the local clustering algorithmChanged the output loop format to bedpeVersion 0.3.3 (03/08/2019)MadetoCoolersupport the float data typeRemoved ticklabels in APA plotVersion 0.3.2 (03/03/2019)Supported combination of different resolutionsImproved the local clustering algorithmAdded the APA analysis moduleDealed with the compatiblility with cooler 0.8Version 0.3.0 (09/03/2018)Removed the horizontal and vertical backgroundsSupported multiple combinations of thepwandwwparametersMigrated to Python 3Optimized the calculation efficiencyFixed bugs when external .cool files are provided.Version 0.2.0-r1 (08/26/2018)Speeded up the program by dynamically limiting the donut widthsVersion 0.2.0 (08/25/2018)Added the vertical and horizontal backgroundsAdded additional filtering procedures based on the dbscan clusters and more stringent q value cutoffsFixed bugs oftoCoolerin storing the inter-chromosomal dataVersion 0.1.1 (08/24/2018)Lower memory usage and more efficient calculationVersion 0.1.0 (08/22/2018)The first release.AddedtoCoolerandpeak-plot.Added support for multiple processing.Pre-Release (05/04/2015)Implemented core algorithms of BH-FDR and HICCUPSReference[1]Rao SS, Huntley MH, Durand NC et al. A 3D Map of the Human Genome at Kilobase Resolution
Reveals Principles of Chromatin Looping. Cell, 2014, 159(7):1665-80.