Package: pairtools
pairtoolsProcess Hi-C pairs with pairtoolspairtoolsis a simple and fast command-line framework to process sequencing
data from a Hi-C experiment.pairtoolsprocess pair-end sequence alignments and perform the following
operations:detect ligation junctions (a.k.a. Hi-C pairs) in aligned paired-end sequences of Hi-C DNA moleculessort .pairs files for downstream analysesdetect, tag and remove PCR/optical duplicatesgenerate extensive statistics of Hi-C datasetsselect Hi-C pairs given flexibly defined criteriarestore .sam alignments from Hi-C pairsannotate restriction digestion sitesget the mutated positions in Hi-C pairsTo get started:Visitpairtools tutorials,Take a look at aquick example,Check out the detaileddocumentation.Data formatspairtoolsproduce and operate on tab-separated files compliant with the.pairsformat defined by the4D Nucleome Consortium. All
pairtools properly manage file headers and keep track of the data
processing history.Additionally,pairtoolsdefine the.pairsam format, an extension of .pairs that includes the SAM alignments
of a sequenced Hi-C molecule. .pairsam complies with the .pairs format, and can be processed by any tool that
operates on .pairs files.pairtoolsproduces a set of additional extra columns, which describe properties of alignments, phase, mutations, restriction and complex walks.
The full list of possible extra columns is provided in thepairtoolsformat specification.InstallationRequirements:Python 3.xPython packagescython,pysam,bioframe,pyyaml,numpy,scipy,pandasandclick.Command-line utilitiessort(the Unix version),bgzip(shipped withsamtools)  andsamtools. If available,pairtoolscan compress outputs withpbgzipandlz4.For the full list of recommended versions, seerequirements in the the GitHub repo.We highly recommend using thecondapackage manager to installpairtoolstogether with all its dependencies. To get it, you can either install the fullAnacondaPython distribution or just the standalonecondapackage manager.Withconda, you can installpairtoolsand all of its dependencies from thebiocondachannel.$condainstall-cconda-forge-cbiocondapairtoolsAlternatively, install non-Python dependencies andpairtoolswith Python-only dependencies from PyPI using pip:$pipinstallnumpypysamcython
$pipinstallpairtoolsQuick exampleSetup a new test folder and download a small Hi-C dataset mapped to sacCer3 genome:$mkdir/tmp/test-pairtools
$cd/tmp/test-pairtools
$wgethttps://github.com/open2c/distiller-test-data/raw/master/bam/MATalpha_R1.bamAdditionally, we will need a .chromsizes file, a TAB-separated plain text table describing the names, sizes and the order of chromosomes in the genome assembly used during mapping:$wgethttps://raw.githubusercontent.com/open2c/distiller-test-data/master/genome/sacCer3.reduced.chrom.sizesWithpairtools parse, we can convert paired-end sequence alignments stored in .sam/.bam format into .pairs, a TAB-separated table of Hi-C ligation junctions:$pairtoolsparse-csacCer3.reduced.chrom.sizes-oMATalpha_R1.pairs.gz--drop-samMATalpha_R1.bamInspect the resulting table:$lessMATalpha_R1.pairs.gzPipelinesWe provide a simple working example of a mapping bash pipeline in /examples/.distilleris a powerful
Hi-C data analysis workflow, based onpairtoolsandnextflow.Toolsparse: read .sam/.bam files produced by bwa and form Hi-C pairsform Hi-C pairs by reporting the outer-most mapped positions and the strand
on the either side of each molecule;report unmapped/multimapped (ambiguous alignments)/chimeric alignments as
chromosome "!", position 0, strand "-";perform upper-triangular flipping of the sides of Hi-C molecules
such that the first side has a lower sorting index than the second side;form hybrid pairsam output, where each line contains all available data
for one Hi-C molecule (outer-most mapped positions on the either side,
read ID, pair type, and .sam entries for each alignment);report .sam tags or mutations of the alignments;print the .sam header as #-comment lines at the start of the file.parse2: read .sam/.bam files with long paired-and or single-end reads and form Hi-C pairs from complex walksidentify and rescue chrimeric alignments produced by singly-ligated Hi-C
molecules with a sequenced ligation junction on one of the sides;annotate chimeric alignments by restriction fragments and report true junctions and hops (One-Read-Based Interactions Annotation, ORBITA);perform intra-molecule deduplication of paired-end data when one side reads through the DNA on the other side of the read;report index of the pair in the complex walk;make combinatorial expansion of pairs produced from the same walk;sort: sort pairs files (the lexicographic order for chromosomes,
the numeric order for the positions, the lexicographic order for pair types).merge: merge sorted .pairs filesmerge sort .pairs;combine the .pairs headers from all input files;check that each .pairs file was mapped to the same reference genome index
(by checking the identity of the @SQ sam header lines).select: select pairs according to specified criteriaselect pairs entries according to the provided condition. A programmable
interface allows for arbitrarily complex queries on specific pair types,
chromosomes, positions, strands, read IDs (including matches to a
wildcard/regexp/list).optionally print the non-matching entries into a separate file.dedup: remove PCR duplicates from a sorted triu-flipped .pairs fileremove PCR duplicates by finding pairs of entries with both sides mapped
to similar genomic locations (+/- N bp);optionally output the PCR duplicate entries into a separate file;detect optical duplicates from the original Illumina read ids;apply filtering by various properties of pairs (MAPQ; orientation; distance) together with deduplication;output yaml or convenient tsv deduplication stats into text file.NOTE: in order to remove all PCR duplicates, the input must contain *all*
mapped read pairs from a single experimental replicate;maskasdup: mark all pairs in a pairsam as Hi-C duplicateschange the field pair_type to DD;change the pair_type tag (Yt:Z:) for all sam alignments;set the PCR duplicate binary flag for all sam alignments (0x400).split: split a .pairsam file into .pairs and .sam.flip: flip pairs to get an upper-triangular matrixheader: manipulate the .pairs/.pairsam headergenerate new header for headerless .pairs filetransfer header from one .pairs file to anotherset column names for the .pairs filevalidate that the header corresponds to the information stored in .pairs filestats: calculate various statistics of .pairs filesrestrict: identify the span of the restriction fragment forming a Hi-C junctionphase: phase pairs mapped to a diploid genomeContributingPull requestsare welcome.For development, clone and install in "editable" (i.e. development) mode with the-eoption. This way you can also pull changes on the fly.$gitclonehttps://github.com/open2c/pairtools.git
$cdpairtools
$pipinstall-e.CitingpairtoolsOpen2C*, Nezar Abdennur, Geoffrey Fudenberg, Ilya M. Flyamer, Aleksandra A. Galitsyna*, Anton Goloborodko*, Maxim Imakaev, Sergey V. Venev. "Pairtools: from sequencing data to chromosome contacts" bioRxiv, February 13, 2023. ; doi:https://doi.org/10.1101/2023.02.13.528389LicenseMIT