### Install chromap Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Creates a conda environment and installs the chromap tool. ```bash conda create -y --prefix soft/chromap conda activate soft/chromap conda install -y -c bioconda -c conda-forge chromap ``` -------------------------------- ### Install Pairtools Development Version Source: https://pairtools.readthedocs.io/en/latest/installation.html Installs pairtools in development mode after cloning the repository. Requires cython, pysam, and numpy to be installed first. Installs the package without moving it to a system folder for live testing. ```bash pip install cython pysam numpy ``` ```bash cd pairtools ``` ```bash pip install -e ./ --no-build-isolation ``` -------------------------------- ### Install MultiQC Source: https://pairtools.readthedocs.io/en/latest/stats.html Install the MultiQC tool, which is required for interactive visualization of statistics. Ensure you are using the open2C fork for pairtools compatibility. ```bash pip install --upgrade --force-reinstall git+https://github.com/open2c/MultiQC.git ``` -------------------------------- ### Install Juicer Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Installs Juicer by creating a conda environment, downloading and unzipping the software, and placing the necessary JAR files and scripts. ```bash conda create -y --prefix soft/juicer conda activate soft/juicer conda install -y -c bioconda bwa java-jdk conda install -y -c conda-forge coreutils # Download the recommended stable version: wget https://github.com/aidenlab/juicer/archive/refs/tags/1.6.zip unzip 1.6.zip rm 1.6.zip mv juicer-1.6 soft/juicer-1.6 # Download compile jar files of the stable version: wget http://hicfiles.tc4ga.com.s3.amazonaws.com/public/juicer/juicer_tools.1.6.2_jcuda.0.7.5.jar mv juicer_tools.1.6.2_jcuda.0.7.5.jar soft/juicer-1.6/CPU/scripts/common/juicer_tools.jar # Copy the scripts to some accessible location: mkdir -p soft/juicer-1.6/CPU/scripts/ cp -r soft/juicer-1.6/CPU/[^s]* soft/juicer-1.6/CPU/scripts/ ``` -------------------------------- ### Example of Output Compression Command Source: https://pairtools.readthedocs.io/en/latest/cli_tools.html Example of how to specify a custom command for compressing output files. This overrides the auto-guessed command. ```bash pbgzip -c -n 8 ``` -------------------------------- ### Setup Test Folder and Download Data Source: https://pairtools.readthedocs.io/en/latest/_sources/quickstart.rst.txt Creates a directory for testing, changes into it, and downloads a sample BAM file. ```bash $ mkdir /tmp/test-pairtools $ cd /tmp/test-pairtools $ wget https://github.com/open2c/distiller-test-data/raw/master/bam/MATalpha_R1.bam ``` -------------------------------- ### Install FAN-C Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Sets up a conda environment for FAN-C, installing Python, pip, hdf5, and the FAN-C package itself, along with samtools. ```bash conda create -y --prefix soft/fanc python=3.9 pip hdf5 conda activate soft/fanc pip install fanc conda install -y -c bioconda samtools ``` -------------------------------- ### Install MultiQC for Pairtools Source: https://pairtools.readthedocs.io/en/latest/_sources/stats.rst.txt Install the MultiQC tool, which includes pairtools support from the open2C fork. This is used for visualizing statistics generated by pairtools. ```bash pip install --upgrade --force-reinstall git+https://github.com/open2c/MultiQC.git ``` -------------------------------- ### Phasing Example with Simulated Data Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt This example demonstrates phasing using simulated data. It involves generating data, phasing it, and then comparing the results. ```bash pairtools sim_phased_data --ref /path/to/reference.fa --haplotypes /path/to/haplotypes.tsv --output phased_data.pairs.gz --nreads 1000000 pairtools phase --input phased_data.pairs.gz --output phased.pairs.gz --genome /path/to/genome.chrom.sizes --haplotypes /path/to/haplotypes.tsv pairtools compare_phasing --input phased.pairs.gz --output comparison.tsv --haplotypes /path/to/haplotypes.tsv ``` -------------------------------- ### Install Pairtools using Pip Source: https://pairtools.readthedocs.io/en/latest/_sources/installation.rst.txt Alternative method to install pairtools and its Python dependencies from PyPI. ```bash pip install pairtools ``` -------------------------------- ### Install TADbit Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Creates a conda environment for TADbit, installs required mappers (gem3-mapper, bowtie2), and then installs TADbit itself. ```bash conda create -y --prefix soft/tadbit conda activate soft/tadbit # # Install mappers: conda install -y -q -c bioconda gem3-mapper bowtie2 # install tadbit conda install -y -q -c bioconda tadbit ``` -------------------------------- ### Example of Input Compression Command Source: https://pairtools.readthedocs.io/en/latest/cli_tools.html Example of how to specify a custom command for decompressing input files. This overrides the auto-guessed command. ```bash pbgzip -dc -n 3 ``` -------------------------------- ### Build Pairtools on macOS (Tentative) Source: https://pairtools.readthedocs.io/en/latest/installation.html A tentative solution for building pairtools on macOS, involving installing build tools, building a wheel, and then installing the wheel. Requires manual installation of build dependencies and delocate. ```bash $ pip install build cython pysam numpy delocate ``` ```bash $ cd pairtools ``` ```bash $ python -m build -n ``` ```bash $ DYLD_LIBRARY_PATH=$(python -c 'import pysam, os; print(os.path.dirname(pysam.get_libraries()[0]))') delocate-wheel -v dist/{wheel_name}.whl ``` ```bash $ pip install dist/{wheel_name}.whl ``` -------------------------------- ### Install HiCExplorer Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Sets up a conda environment for HiCExplorer, installing Python and the HiCExplorer package along with bwa. ```bash conda create -y --prefix soft/hicexplorer python=3.9 conda activate soft/hicexplorer conda install -y -c bioconda hicexplorer bwa ``` -------------------------------- ### Setup Test Folder and Download Data Source: https://pairtools.readthedocs.io/en/latest/quickstart.html Create a directory for testing and download a small Hi-C dataset mapped to the sacCer3 genome. ```bash $ mkdir /tmp/test-pairtools $ cd /tmp/test-pairtools $ wget https://github.com/open2c/distiller-test-data/raw/master/bam/MATalpha_R1.bam ``` -------------------------------- ### Phasing with Real Data Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt This example shows how to phase real Hi-C data. It assumes you have BAM files and phasing information. ```bash pairtools bam2pairs --input input.bam --output input.pairs.gz pairtools sort --input input.pairs.gz --output sorted.pairs.gz pairtools phase --input sorted.pairs.gz --output phased.pairs.gz --genome /path/to/genome.chrom.sizes --haplotypes /path/to/haplotypes.tsv ``` -------------------------------- ### Install Development Version of Pairtools Source: https://pairtools.readthedocs.io/en/latest/_sources/installation.rst.txt Installs pairtools in development mode after cloning the repository. Requires cython, pysam, and numpy to be pre-installed. Uses --no-build-isolation due to Cython re-compilation of pysam. ```bash pip install cython pysam numpy cd pairtools pip install -e ./ --no-build-isolation ``` -------------------------------- ### Example of pairtools stats command for matrix statistics Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Shows how to calculate and output statistics for a Hi-C contact matrix file. ```bash pairtools stats --input:cool matrix.cool --output:txt stats.txt ``` -------------------------------- ### Basic Pairtools Usage Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Demonstrates fundamental pairtools commands for processing .pairs files. Ensure pairtools is installed and a .pairs file is available. ```bash pairtools --version ``` ```bash pairtools parse "pairs://*" --input-pairs input.pairs --output-pairs output.pairs ``` ```bash pairtools select "(chrom1 == \"chr1\")" --input-pairs input.pairs --output-pairs output.pairs ``` ```bash pairtools restrict --input-pairs input.pairs --output-pairs output.pairs --chromsizes hg19.chrom.sizes --regions chr1:1000000-2000000 ``` ```bash pairtools dumpbins --input-pairs input.pairs --output-bins output.bins --binsize 1000000 ``` ```bash pairtools split --input-pairs input.pairs --output-pairs output.pairs --output-pairs-unmapped output.unmapped.pairs --map-to-bedpe input.bedpe ``` ```bash pairtools shuffle --input-pairs input.pairs --output-pairs output.pairs ``` ```bash pairtools dedup --input-pairs input.pairs --output-pairs output.pairs ``` ```bash pairtools isolates --input-pairs input.pairs --output-pairs output.pairs ``` ```bash pairtools merge --input-pairs input1.pairs input2.pairs --output-pairs output.pairs ``` ```bash pairtools stats --input-pairs input.pairs ``` ```bash pairtools assign --input-pairs input.pairs --output-pairs output.pairs --mapq 30 ``` ```bash pairtools filter --input-pairs input.pairs --output-pairs output.pairs --min-dist 10000 --max-dist 1000000 ``` ```bash pairtools clip --input-pairs input.pairs --output-pairs output.pairs --clip-length 50 ``` ```bash pairtools mark --input-pairs input.pairs --output-pairs output.pairs --mark-type "M" ``` ```bash pairtools label --input-pairs input.pairs --output-pairs output.pairs --label-col "read_group" --label-value "RG1" ``` ```bash pairtools normalize --input-pairs input.pairs --output-pairs output.pairs --genome-size hg19.chrom.sizes ``` ```bash pairtools revmap --input-pairs input.pairs --output-pairs output.pairs --genome-size hg19.chrom.sizes ``` ```bash pairtools validate --input-pairs input.pairs ``` ```bash pairtools count --input-pairs input.pairs --output-counts counts.txt ``` ```bash pairtools plot --input-pairs input.pairs --output-png output.png ``` ```bash pairtools --help ``` -------------------------------- ### Install HG38 Genome with Genomepy Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Installs the HG38 reference genome and its associated indexes into the specified data directory. ```bash # Install hg38 genome by genomepy: ! genomepy install hg38 -g data/ ``` -------------------------------- ### Compile bwa-mem2 from Source Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Clones, compiles, and installs bwa-mem2 from its source repository. This method is not recommended for general users. ```bash conda activate soft/pairtools1.0.2 # bwa-mem2: compile from source (not recommended for general users) # Get the source git clone --recursive https://github.com/bwa-mem2/bwa-mem2 soft/bwa-mem2 cd soft/bwa-mem2 # Compile make # Exit compilation folder cd ../../ ``` -------------------------------- ### Create a dummy pair file Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Generate a small, dummy pair file for demonstration purposes. This file will be used in subsequent examples. ```bash echo -e '1\t1\t1000\t1100\t+\t-\t1\t1\t1000\t1100\t+\t-' > dummy.pairs ``` -------------------------------- ### Install Pairtools Source: https://pairtools.readthedocs.io/en/latest/_sources/quickstart.rst.txt Installs pairtools and its dependencies using conda from the conda-forge and bioconda channels. ```bash $ conda install -c conda-forge -c bioconda pairtools ``` -------------------------------- ### Phasing Variants with Pairtools Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Phase variants using pairtools. This example demonstrates a typical phasing workflow. ```bash pairtools phase --input merged.pairs.gz --variants variants.vcf.gz --output phased.pairs.gz ``` -------------------------------- ### Example of pairtools pairs conversion from BEDPE Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Illustrates converting a BEDPE file back into the pairtools pairs format for further processing. ```bash pairtools pairs --input:bedpe input.bedpe --output:pairs output.pairs.gz ``` -------------------------------- ### Downstream Analysis Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt An example of a downstream analysis step, such as calculating contact frequency decay. This demonstrates how pairtools output can be used. ```bash pairtools plot-dist --input-pairs /path/to/parsed.pairs.gz --output-png /path/to/distance_decay.png ``` -------------------------------- ### Getting Help Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Displays the help message for the pairtools command-line interface, providing an overview of available subcommands and options. ```bash pairtools --help ``` -------------------------------- ### Install pairtools v1.0.2 Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Installs pairtools version 1.0.2 using a dedicated conda environment. Includes necessary Python packages and bwa. ```bash conda create -y --prefix soft/pairtools1.0.2 python=3.9 pip conda activate soft/pairtools1.0.2 pip install cython numpy pysam pip install git+https://github.com/open2c/pairtools.git@v1.0.2 conda install -c conda-forge lz4-c # conda install -c anaconda lz4 conda install -y -c bioconda "bwa>=0.7.17" ``` -------------------------------- ### Check CPU Properties Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Imports the psutil library to display the number of CPUs and their current frequency. Ensure psutil is installed. ```python import psutil print(f"{psutil.cpu_count()} CPUs at {psutil.cpu_freq().current:.0f} GHz") ``` -------------------------------- ### Install HG38 Genome with GenomePy Source: https://pairtools.readthedocs.io/en/latest/examples/pairtools_walkthrough.html Installs the HG38 genome using genomepy. This process may take time as it compiles the BWA index. ```python genomepy install hg38 ``` -------------------------------- ### Configure HiC-Pro Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Copies configuration files for HiC-Pro installation. Ensure these configurations are adjusted for your specific system. ```bash # Note that the configs should be adjusted for your system: cp configs/config-hicpro_install.txt soft/HiC-Pro_env/HiC-Pro/config-install.txt cp configs/config-hicpro.txt soft/HiC-Pro_env/HiC-Pro/config-hicpro.txt ``` -------------------------------- ### Install Reference Genome with BWA Index Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Installs the human hg38 reference genome using genomepy. This process may take a significant amount of time as it also compiles the BWA index. ```python # Install hg38 genome by genomepy, it might take some time to compile the bwa index for hg38: ! genomepy install hg38 ``` -------------------------------- ### Build and Install Development Version on macOS Source: https://pairtools.readthedocs.io/en/latest/_sources/installation.rst.txt Tentative solution for building and installing the development version of pairtools on macOS. Requires specific build tools and uses delocate-wheel for wheel manipulation. Replace {wheel_name} with the actual wheel file name. ```bash pip install build cython pysam numpy delocate cd pairtools python -m build -n DYLD_LIBRARY_PATH=$(python -c 'import pysam, os; print(os.path.dirname(pysam.get_libraries()[0]))') delocate-wheel -v dist/{wheel_name}.whl pip install dist/{wheel_name}.whl ``` -------------------------------- ### Example of pairtools merge command from a directory Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates merging multiple pairs files located in a directory into a single output pairs file. ```bash pairtools merge --input-dir split_pairs/ --output:pairs merged.pairs.gz ``` -------------------------------- ### Compare Phasing with Output Format Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Specify the output format for phasing comparison results. This example outputs in CSV format. ```bash pairtools compare_phasing --input phased.pairs.gz --output comparison.csv --haplotypes /path/to/haplotypes.tsv --output_fmt csv ``` -------------------------------- ### Example of pairtools normalize command with ICE method Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates normalizing a Hi-C contact matrix using the ICE method to correct for biases. ```bash pairtools normalize --input:cool matrix.cool --output:cool normalized.cool --method ICE ``` -------------------------------- ### Get Pairtools Version Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Check the installed version of pairtools. This is useful for ensuring compatibility and reporting issues. ```bash pairtools --version ``` -------------------------------- ### Restrict to Multiple Regions Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example shows how to filter for multiple specific regions. The input file must be sorted. ```bash pairtools restrict --input pairs_sorted.pairs --output pairs_multi_region.pairs --regions chr1:1000000-2000000 chr2:500000-1500000 ``` -------------------------------- ### Restrict to a Specific Region Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example demonstrates how to restrict the output to a specific genomic region (chromosome, start, end). The input file must be sorted. ```bash pairtools restrict --input pairs_sorted.pairs --output pairs_region.pairs --region chr1:1000000-2000000 ``` -------------------------------- ### Pairtools `pairtools_plot` Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Shows how to use `pairtools_plot` to generate various visualizations from pairs data, such as distance-frequency plots or interaction matrices. ```bash # Example command to plot distance-frequency distribution # pairtools plot --input output_dir/merged.pairs --output output_dir/distance_freq.png --plot distance_freq --genome_file chrom.sizes ``` -------------------------------- ### Restrict to a Specific Region on a Chromosome Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example demonstrates how to filter interactions within a defined genomic region on a single chromosome. Adjust start and end positions as needed. ```bash pairtools restrict input.pairs.gz --output output.pairs.gz --chrom1 chr1 --start1 1000000 --end1 2000000 ``` -------------------------------- ### Create Directory for Software Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Creates a directory to store downloaded software and their environments. ```bash mkdir ./soft ``` -------------------------------- ### Select pairs matching chromosome regex Source: https://pairtools.readthedocs.io/en/latest/cli_tools.html Filter pairs where both chromosomes match a specified regular expression, for example, 'chrd+' for chromosomes starting with 'chr' followed by digits. ```bash pairtools select ‘regex_match(chrom1, “chrd+”) and regex_match(chrom2, “chrd+”)’ ``` -------------------------------- ### Initialize Pairtools Environment Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt This snippet demonstrates how to set up the pairtools environment by importing necessary libraries and defining variables for input and output files. Ensure these paths are correctly set for your project. ```python import pairtools import pandas as pd import numpy as np input_pairs = "input.pairs" output_pairs = "output.pairs" output_dir = "output_dir" # Create output directory if it doesn't exist import os os.makedirs(output_dir, exist_ok=True) ``` -------------------------------- ### Example of pairtools BEDPE conversion Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates converting a pairs file into BEDPE format, which is commonly used by other genomic analysis tools. ```bash pairtools BEDPE --input:pairs input.pairs.gz --output:bedpe output.bedpe ``` -------------------------------- ### Python Example: Reading Pairs Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates how to read and process pairs files using the pairtools Python API. This allows for programmatic manipulation and analysis. ```python from pairtools import parse_pairs for pair in parse_pairs('input.pairs.gz'): print(pair) ``` -------------------------------- ### Basic pairtools restrict command Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This is a fundamental example of using pairtools restrict to filter pairs within a specified genomic region. Ensure pairtools is installed and accessible in your PATH. ```bash pairtools restrict --input pairs.pairs.gz --output pairs_filtered.pairs.gz --region chr1:1000000-2000000 ``` -------------------------------- ### Initialize Cooler for Visualization Source: https://pairtools.readthedocs.io/en/latest/examples/pairtools_walkthrough.html Import necessary libraries for cooler visualization and load a specific resolution of a multi-resolution cooler file. ```python import cooler import matplotlib as mpl import matplotlib.pyplot as plt %matplotlib inline import cooltools.lib.plotting from matplotlib.colors import LogNorm import seaborn as sns import bioframe import numpy as np ``` ```python file = "test.hg38.1000000.mcool::/resolutions/1000000" clr = cooler.Cooler(file) ``` -------------------------------- ### Filtering using a BED file Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example shows how to use a BED file to define the regions for filtering. The BED file should contain three columns: chromosome, start, and end. This is a powerful way to filter based on predefined genomic annotations. ```bash pairtools restrict --input pairs.pairs.gz --output pairs_filtered_bed.pairs.gz --regions-bed regions.bed ``` -------------------------------- ### Get Specific Command Help Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Displays the help message for a specific pairtools command, such as 'convert'. Useful for detailed command usage. ```bash pairtools convert --help ``` -------------------------------- ### Pairtools `pairtools_split` Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates the `pairtools_split` command-line tool, which splits a pairs file into multiple files based on chromosome. This can be useful for parallel processing. ```bash # Example command to split pairs file by chromosome # pairtools split --input output_dir/filtered.pairs --output_dir output_dir/split_files/ ``` -------------------------------- ### Handling Assembly Differences Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Explains how to specify the assembly for input and default assemblies. ```bash pairtools parse \ --input pairs.gz \ --output-pairs stdout \ --input-assembly hg19 \ --assembly-default hg38 ``` -------------------------------- ### Combining multiple filtering criteria Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example demonstrates how to combine multiple filtering options in a single command. The input file must be sorted. ```bash pairtools restrict --input pairs_sorted.pairs --output pairs_combined_filtered.pairs --chroms chr1 --region chr1:1000000-2000000 --min_dist 5000 --pair_type valid ``` -------------------------------- ### Example of Pairtools Count with Specific Output Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Count phased pairs and output the result to a file. This allows for easy comparison. ```bash pairtools count \ --input pairs_phased.gz \ --output counts.txt ``` -------------------------------- ### Example of Pairtools Parse with Different Input Type Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Demonstrates parsing data from a BAM file. Ensure the BAM file is properly indexed. ```bash pairtools parse \ --input-type bam \ --output-pairs pairs.gz \ --assembly hg19 \ input.bam ``` -------------------------------- ### Python Example: Reading and Filtering Pairs Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates reading pairs data in Python and applying a simple filter based on chromosome. ```python import pairtools filtered_pairs = [] with open('pairs.pairs.gz', 'rb') as f: for pair in pairtools.parse_pairs(f): if pair.chrom1 == 'chr1' and pair.chrom2 == 'chr1': filtered_pairs.append(pair) print(f"Found {len(filtered_pairs)} cis-pairs on chr1.") ``` -------------------------------- ### Example of Pairtools Select with Different Filtering Criteria Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Select pairs based on mapping quality and distance between fragments. Adjust thresholds as needed. ```bash pairtools select \ --input pairs.gz \ --output pairs_filtered.gz \ 'mapq1 > 20 and mapq2 > 20' \ 'abs(chrom1 - chrom2) < 500000' ``` -------------------------------- ### Check Genome Location Source: https://pairtools.readthedocs.io/en/latest/examples/pairtools_walkthrough.html Lists the contents of the installed HG38 genome directory to verify the installation. ```bash ls ~/.local/share/genomes/hg38/ ``` -------------------------------- ### Pairtools `pairtools_sort` Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Shows how to use the `pairtools_sort` command-line tool to sort pairs data. Sorting is essential for many downstream analyses and for creating valid pair files. ```bash # Example command to sort pairs # pairtools sort --input output_dir/deduplicated.pairs --output output_dir/sorted.pairs ``` -------------------------------- ### Pairtools `pairtools_tag` Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates the `pairtools_tag` command-line tool for adding custom tags to pairs based on specific criteria. This can be used for annotating interactions. ```bash # Example command to tag pairs based on distance # pairtools tag --input output_dir/merged.pairs --output output_dir/tagged.pairs --tag short_range --min_dist 0 --max_dist 50000 ``` -------------------------------- ### Pairtools `pairtools_annotate` Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Illustrates the `pairtools_annotate` command-line tool for annotating pairs with information from external files, such as gene annotations or genomic features. ```bash # Example command to annotate pairs with gene information # pairtools annotate --input output_dir/merged.pairs --output output_dir/annotated.pairs --genes genes.bed --columns chrom1,start1,end1,gene_id --columns chrom2,start2,end2,gene_id ``` -------------------------------- ### Basic Pairtools Usage Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Demonstrates the fundamental command structure of pairtools, showing how to pipe output from one subcommand to another. ```bash pairtools --version ``` ```bash pairtools parse --input-pairs input.pairs.gz --output-pairs output.pairs.gz ``` ```bash pairtools parse --input-pairs input.pairs.gz \ --output-pairs output.pairs.gz \ --chroms chr1 chr2 \ --min-mapq 20 \ --min-dist 10000 \ --max-dist 1000000 ``` -------------------------------- ### Generate MultiQC Report Source: https://pairtools.readthedocs.io/en/latest/examples/pairtools_walkthrough.html Run MultiQC to generate an HTML report summarizing statistics from test.stats. Ensure Open2C version of MultiQC is installed. ```bash multiqc test.stats ``` -------------------------------- ### Create a dummy Hi-C file Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Generate a small, dummy Hi-C file in .pairs format for demonstration purposes. This file will be used in subsequent examples. ```bash mkdir -p tmp seq 1 1000 | awk '{print "chr1\t" $1 "\tchr1\t" ($1+100) "\t+\t-"}' > tmp/dummy.pairs seq 1 1000 | awk '{print "chr2\t" $1 "\tchr2\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr3\t" $1 "\tchr3\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr4\t" $1 "\tchr4\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr5\t" $1 "\tchr5\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr6\t" $1 "\tchr6\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr7\t" $1 "\tchr7\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr8\t" $1 "\tchr8\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr9\t" $1 "\tchr9\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr10\t" $1 "\tchr10\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr11\t" $1 "\tchr11\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr12\t" $1 "\tchr12\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr13\t" $1 "\tchr13\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr14\t" $1 "\tchr14\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr15\t" $1 "\tchr15\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr16\t" $1 "\tchr16\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr17\t" $1 "\tchr17\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr18\t" $1 "\tchr18\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr19\t" $1 "\tchr19\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr20\t" $1 "\tchr20\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr21\t" $1 "\tchr21\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chr22\t" $1 "\tchr22\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chrX\t" $1 "\tchrX\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chrY\t" $1 "\tchrY\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs seq 1 1000 | awk '{print "chrM\t" $1 "\tchrM\t" ($1+100) "\t+\t-"}' >> tmp/dummy.pairs pairtools_sort tmp/dummy.pairs | pairtools_dedup --output-pairs tmp/dummy.dedup.pairs rm tmp/dummy.pairs ``` -------------------------------- ### Restrict using a BED file Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example uses a BED file to specify the regions for filtering. The input .pairs file must be sorted. ```bash pairtools restrict --input pairs_sorted.pairs --output pairs_bed.pairs --regions_from_bed regions.bed ``` -------------------------------- ### Example of pairtools convert command with specific options Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates the use of pairtools convert with options to specify input BAM file, output pairs file, and reference genome assembly. ```bash pairtools convert --input:bam input.bam --output:pairs output.pairs.gz --assembly:genome hg19 ``` -------------------------------- ### Define Chromosome Starts Source: https://pairtools.readthedocs.io/en/latest/examples/pairtools_walkthrough.html Calculate the starting positions for each chromosome within the cooler object. This is useful for fetching specific genomic regions. ```python # Define chromosome starts chromstarts = [] for i in clr.chromnames: chromstarts.append(clr.extent(i)[0]) ``` -------------------------------- ### Python Example: Creating a Matrix Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Illustrates how to create a Hi-C contact matrix from a pairs file using the pairtools Python API. This enables custom matrix generation and analysis. ```python from pairtools import parse_pairs, dump matrix = dump(parse_pairs('input.pairs.gz'), bin_size=10000) print(matrix) ``` -------------------------------- ### Filtering based on pair orientation Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example demonstrates filtering pairs based on their orientation (e.g., cis-trans, forward-reverse). The input file must be sorted. ```bash pairtools restrict --input pairs_sorted.pairs --output pairs_cis.pairs --cis ``` ```bash pairtools restrict --input pairs_sorted.pairs --output pairs_trans.pairs --trans ``` ```bash pairtools restrict --input pairs_sorted.pairs --output pairs_fr.pairs --orientation FR ``` -------------------------------- ### Example of pairtools dump command to view file content Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Shows how to dump the content of a pairs file to standard output and display the first few lines using the head command. ```bash pairtools dump --input:pairs input.pairs.gz --output - | head ``` -------------------------------- ### Basic Restriction Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example shows a basic restriction of a .pairs file. It filters contacts to include only those within a specified genomic region. ```bash pairtools restrict input.pairs.gz --region chr1:10,000,000-20,000,000 -o output.pairs.gz ``` -------------------------------- ### Pairtools `pairtools_qc` Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates the `pairtools_qc` command-line tool for generating quality control metrics for Hi-C data. This helps assess the quality and identify potential issues in the data. ```bash # Example command to generate QC report # pairtools qc --input output_dir/merged.pairs --output output_dir/qc_report.txt --genome_file chrom.sizes ``` -------------------------------- ### Example of pairtools coolify command for matrix generation Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates generating a Hi-C contact matrix in the cooler format with a specified bin size and genome assembly. ```bash pairtools coolify --input:pairs parsed.pairs.gz --output:cool matrix.cool \ --bin-size 10000 \ --assembly:genome hg19 ``` -------------------------------- ### Install HiC-Pro Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Installs HiC-Pro using a conda environment, including dependencies and configuration. It also patches the Makefile to retain specific processing steps. ```bash git clone https://github.com/nservant/HiC-Pro.git soft/HiC-Pro_env/HiC-Pro conda env create -f soft/HiC-Pro_env/HiC-Pro/environment.yml -p soft/HiC-Pro_env ### Working environment will be soft/HiC-Pro_env conda activate soft/HiC-Pro_env # Install dependencies conda install -y -c bioconda bowtie2 samtools pysam numpy scipy bx-python conda install -y -c r r r-rcolorbrewer r-ggplot2 # Copy prepared config: cp configs/config-hicpro_install.txt soft/HiC-Pro_env/HiC-Pro/config-install.txt cp configs/config-hicpro.txt soft/HiC-Pro_env/HiC-Pro/config-hicpro.txt # Configure and install: cd soft/HiC-Pro_env/HiC-Pro make configure make install cd ../../../ # Patch the code to retain only data processing steps with no creating of maps: sed -i "s/all : init mapping proc_hic merge_persample hic_qc build_raw_maps ice_norm/all : init mapping proc_hic merge_persample #hic_qc build_raw_maps ice_norm/" soft/HiC-Pro_env/HiC-Pro/scripts/Makefile ``` -------------------------------- ### List Downloaded FASTQ Files Source: https://pairtools.readthedocs.io/en/latest/examples/pairtools_walkthrough.html Lists the FASTQ files that were downloaded. This command helps verify that the data download was successful. ```bash ! ls SRR13849430*.fastq.gz ``` -------------------------------- ### Get statistics of Hi-C pairs Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Uses pairtools stats to get the total number of contacts in the downloaded Hi-C pairs file. Useful for understanding data size. ```bash %%bash # Get total number of contacts to assess how many reads you can read in the future: pairtools stats 4DNFIW2BKSNF.pairs.gz | head -n 1 # This will produce around 173 M pairs ``` -------------------------------- ### Clone Pairtools Repository Source: https://pairtools.readthedocs.io/en/latest/_sources/installation.rst.txt Clones the pairtools repository from GitHub to install the development version. ```bash git clone https://github.com/open2c/pairtools ``` -------------------------------- ### Example of Pairtools Phase with Different VCF and MAPQ Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Phase pairs using a different VCF file and mapping quality threshold. Ensure VCF is compatible. ```bash pairtools phase \ --input pairs_grouped.gz \ --output pairs_phased.gz \ --vcf other_variants.vcf.gz \ --mapq 40 ``` -------------------------------- ### Restriction by Genomic Interval Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example illustrates restricting contacts to a specific genomic interval on both chromosomes. ```bash pairtools restrict input.pairs.gz --region chr1:10M-20M --region chr2:5M-15M -o output_interval.pairs.gz ``` -------------------------------- ### Read Mapping Only Examples Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Perform read mapping using different tools: bwa mem, bwa-mem2, and bowtie2. These commands generate SAM files and are useful for assessing mapping performance. ```bash # bwa mem soft/pairtools0.3.0/bin/bwa mem -t 4 -SP data/hg38/index/bwa/hg38.fa data/SRR6107789_1.fastq.gz data/SRR6107789_2.fastq.gz > bwa-mem.sam # bwa mem2 soft/bwa-mem2/bwa-mem2 mem -t 4 -SP data/hg38/index/bwa-mem2/hg38 data/SRR6107789_1.fastq.gz data/SRR6107789_2.fastq.gz > bwa-mem2.sam # bowtie2 only soft/tadbit/bin/bowtie2 -p 4 -x data/hg38/index/bowtie2/hg38 -1 data/SRR6107789_1.fastq.gz -2 data/SRR6107789_2.fastq.gz -S bowtie2.sam ``` -------------------------------- ### Filter Pairs Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Filter pairs based on various criteria. This example filters for intra-chromosomal pairs. ```bash pairtools filter --input input.pairs.gz --output filtered.pairs.gz --minlen 1000 --maxlen 1000000 --mapq 30 --min_insert_size 0 --max_insert_size 1000 ``` -------------------------------- ### Pairtools `pairtools_merge` Example Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Shows how to use `pairtools_merge` to combine multiple pairs files back into a single file. This is typically used after parallel processing steps like splitting. ```bash # Example command to merge pairs files # pairtools merge --input_dir output_dir/split_files/ --output output_dir/merged.pairs ``` -------------------------------- ### Phasing with Output Format Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Specify the output format for phased data. This example outputs in BEDPE format. ```bash pairtools phase --input input.pairs.gz --output phased.bedpe --genome /path/to/genome.chrom.sizes --haplotypes /path/to/haplotypes.tsv --output_fmt bedpe ``` -------------------------------- ### Basic Pairtools Commands Overview Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt This section provides a high-level overview of common pairtools commands, illustrating their typical usage in a Hi-C analysis pipeline. ```bash # Convert BAM to pairs pairtools convert --input reads.bam --output reads.pairs.gz # Filter pairs pairtools filter --input reads.pairs.gz --output filtered.pairs.gz --min-mapq 30 # Deduplicate pairs pairtools dedup --input filtered.pairs.gz --output deduped.pairs.gz # Create bins pairtools makebins --input deduped.pairs.gz --output bins.bed # Create cooler file pairtools coolify --input deduped.pairs.gz --bins bins.bed --output matrix.cool # Validate pairs file pairtools validate --input deduped.pairs.gz ``` -------------------------------- ### Manual HiCExplorer Matrix Building Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Build Hi-C matrices using HiCExplorer, processing paired-end FASTQ files through BWA and samtools. This example generates binned coolers, not raw pairs. ```bash hicBuildMatrix --samFiles \ <(bwa mem -t 4 -A1 -B4 -E50 -L0 data/hg38/index/bwa/hg38.fa data/SRR6107789_1.fastq.gz | samtools view -Shb -) \ <(bwa mem -t 4 -A1 -B4 -E50 -L0 data/hg38/index/bwa/hg38.fa data/SRR6107789_2.fastq.gz | samtools view -Shb -) \ --restrictionSequence GATC \ --danglingSequence GATC \ --restrictionCutFile data/hg38/hg38.DpnII.bed \ --threads 4 \ --inputBufferSize 100000 \ --QCfolder hicexplorer_tmp \ -o hicexplorer_output.cool ``` -------------------------------- ### Get Pairs Header Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Prints only the header of a pairs file. Useful for understanding the file structure and metadata. ```bash pairtools header --input-pairs pairs.pairs.gz ``` -------------------------------- ### Create Data Directory Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Creates a directory named 'data' to store downloaded files. ```bash mkdir data ``` -------------------------------- ### Get Pairs Statistics Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Calculates various statistics for a pairs file, such as the distribution of distances and chromosome usage. ```bash pairtools stats --input-pairs pairs.pairs.gz --output-stats stats.json ``` -------------------------------- ### Restriction by Chromosome Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Example of restricting Hi-C data to an entire chromosome. This is a common operation for analyzing chromosome-specific interactions. ```bash pairtools restrict --input pairs.pairs.gz --output pairs.chr1.pairs.gz --region chr1 ``` -------------------------------- ### Get Pairs Columns Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Prints the column names of a pairs file. Helps in understanding the data fields available. ```bash pairtools columns --input-pairs pairs.pairs.gz ``` -------------------------------- ### Get Chromosome Lengths Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Retrieves the lengths of chromosomes from a genome annotation file. Useful for setting up genomic analyses. ```bash pairtools get_chrom_lengths --input genome.gtf --output genome.chrom.lengths ``` -------------------------------- ### Restricting using a BED file Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example shows how to use a BED file to define the regions for restriction. This is a convenient way to manage a large number of regions. ```bash pairtools restrict --input pairs.pairs.gz --output pairs.restricted.bed.pairs.gz --regions regions.bed ``` -------------------------------- ### Open pairs file and extract header Source: https://pairtools.readthedocs.io/en/latest/examples/pairtools_restrict_walkthrough.html Opens a pairtools file, extracts its header, and gets the column names. ```python pairs_stream = fileio.auto_open(pairs_file, 'r') header, pairs_stream = headerops.get_header(pairs_stream) columns = headerops.get_colnames(header) ``` -------------------------------- ### Manual FAN-C Mapping and Sorting Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Process FASTQ files using FAN-C for mapping and samtools for sorting. This is a multi-step process to prepare BAM files for pair generation. ```bash fanc map -t 5 data/SRR6107789_1.fastq.gz data/hg38/index/bwa/hg38.fa output/fanc-output_1.bam fanc map -t 5 data/SRR6107789_2.fastq.gz data/hg38/index/bwa/hg38.fa output/fanc-output_2.bam samtools sort -@ 5 -n output/fanc-output_1.bam -o output/fanc-output_1.sorted.bam samtools sort -@ 5 -n output/fanc-output_2.bam -o output/fanc-output_2.sorted.bam fanc pairs output/fanc-output_1.sorted.bam output/fanc-output_2.sorted.bam output/fanc-output.pairs -g data/hg38/hg38.DpnII.bed ``` -------------------------------- ### Convert Pairs to BEDPE (CLI Example) Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Demonstrates the command-line interface for converting pairs data to BEDPE format. This is useful for interoperability with other genomic analysis tools. ```bash # Example command to convert pairs to BEDPE format # pairtools convert --input output.pairs --output output_dir/output.bedpe --format bedpe ``` -------------------------------- ### Organize Data for HiC-Pro Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Copies downloaded FASTQ files into the raw data directory for HiC-Pro. ```bash # Put the data in accessible folder for HiC-Pro: mkdir -p soft/HiC-Pro_env/HiC-Pro/rawdata/sample1 cp data/S*fastq.gz soft/HiC-Pro_env/HiC-Pro/rawdata/sample1/ ``` -------------------------------- ### Combining Multiple Restriction Criteria Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt This example shows how to combine multiple restriction criteria to perform a more specific filtering of contacts. ```bash pairtools restrict input.pairs.gz --region chr1:10M-20M --max-dist 50000 --pair-type intra -o output_combined.pairs.gz ``` -------------------------------- ### Restrict to pairs with specific flags Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Filter pairs based on their flags, such as 'mapped' or 'unmapped'. This example keeps only mapped pairs. ```python pairtools restrict --output pairs_mapped.pairs.gz --mapq 1 --mapq-op ge pairs.pairs.gz ``` -------------------------------- ### Help for Pairtools Commands Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_phase_walkthrough.ipynb.txt Display help information for any pairtools command. Replace 'command' with the specific command you need help with. ```bash pairtools command --help ``` -------------------------------- ### Example of pairtools split command for directory output Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Illustrates splitting a pairs file into multiple files, each containing reads for a specific chromosome, and saving them into a designated output directory. ```bash pairtools split --input:pairs input.pairs.gz --output-dir split_pairs/ ``` -------------------------------- ### Restriction by Sequence Identity Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Filter pairs based on sequence identity. This example removes pairs with less than 90% identity. ```bash pairtools restrict --min-seq-id 0.9 input.pairs.gz > output.pairs.gz ``` -------------------------------- ### Setup Plotting Environment Source: https://pairtools.readthedocs.io/en/latest/examples/benchmark/benchmark.html Imports necessary libraries for data manipulation and plotting, including pandas, seaborn, numpy, and matplotlib. Sets matplotlib parameters for figure size and font. ```python import pandas as pd import seaborn as sns import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt %matplotlib inline mpl.rcParams['font.family'] = "sans-serif" figsize_A4 = np.array([11.69, 8.27]) plt.rcParams["figure.figsize"] = figsize_A4.T plt.rcParams['figure.facecolor']='white' plt.rcParams['font.size']=16 import glob ``` -------------------------------- ### Restriction by Fragment Type Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Filter pairs based on the type of fragments (e.g., cis, trans). This example keeps only cis-interactions. ```bash pairtools restrict --fragment-type cis input.pairs.gz > output.pairs.gz ``` -------------------------------- ### Restriction by Orientation Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Filter pairs based on their orientation (e.g., forward-reverse, reverse-forward). This example keeps only pairs with a forward-reverse orientation. ```bash pairtools restrict --orientation FR input.pairs.gz > output.pairs.gz ``` -------------------------------- ### Restriction by Pair Type Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_restrict_walkthrough.ipynb.txt Filter pairs based on their type (e.g., intra-chromosomal, inter-chromosomal). This example keeps only intra-chromosomal pairs. ```bash pairtools restrict --pair-type intra input.pairs.gz > output.pairs.gz ``` -------------------------------- ### Convert Pairs to Hi-C Matrix (CLI Example) Source: https://pairtools.readthedocs.io/en/latest/_sources/examples/pairtools_walkthrough.ipynb.txt Illustrates the command-line interface usage of pairtools to convert pairs data into a Hi-C contact matrix. This is often more efficient for large datasets. ```bash # Example command to generate a Hi-C matrix # pairtools make_matrix --input output.pairs --output output_dir/hic_matrix.txt --resolution 10000 --genome_file chrom.sizes ```