### Install deepTools from Repository via Pip (Development Version) Source: https://deeptools.readthedocs.io/en/develop/_sources/content/installation Installs a development version of deepTools by cloning the GitHub repository and then installing it using pip. This method is useful for users who want to test unreleased features or contribute to the project. ```bash $ git clone https://github.com/deeptools/deepTools.git $ cd DeepTools $ pip install . ``` -------------------------------- ### Install deepTools Galaxy Tool Shed Repositories via API Source: https://deeptools.readthedocs.io/en/develop/_sources/content/installation Installs deepTools and its dependencies into a local Galaxy server using a Python script and the Galaxy API. Requires an API key and specifies repository details, including optional tool and repository dependencies. The '-r' argument refers to the revision number. ```python python ./scripts/api/install_tool_shed_repositories.py \ --api YOUR_API_KEY -l http://localhost/ \ --url https://toolshed.g2.bx.psu.edu/ \ -o bgruening -r --name suite_deeptools \ --tool-deps --repository-deps --panel-section-name deepTools ``` -------------------------------- ### Import deeptools CountReadsPerBin class Source: https://deeptools.readthedocs.io/en/develop/_sources/content/example_api_tutorial Imports the necessary class from the deeptools library to count reads per bin. This is the initial setup for coverage analysis. ```python import deeptools.countReadsPerBin as crpb ``` -------------------------------- ### bamCoverage usage example Source: https://deeptools.readthedocs.io/en/develop/content/tools/bamCoverage Provides a basic usage example for the bamCoverage command-line tool, showing input BAM file and output file name. ```bash usage: bamCoverage -b reads.bam -o coverage.bw help: bamCoverage -h / bamCoverage --help ``` -------------------------------- ### Install deepTools from GitHub Repository Source: https://deeptools.readthedocs.io/en/develop/content/installation Installs an unreleased or development version of deepTools by cloning the official GitHub repository and then installing it using pip. This is useful for testing the latest features or contributing to development. ```bash $ git clone https://github.com/deeptools/deepTools.git $ cd deepTools $ pip install . ``` -------------------------------- ### Minimal Usage Example for bamCoverage - deepTools Source: https://deeptools.readthedocs.io/en/develop/content/list_of_tools Illustrates how to display a minimal usage example for the bamCoverage tool by running it without any arguments. This is a quick way to see the basic syntax and required parameters for a command. ```bash $ bamCoverage ``` -------------------------------- ### Displaying Minimal Usage Example Source: https://deeptools.readthedocs.io/en/develop/_sources/content/list_of_tools This snippet illustrates how to view a minimal usage example for a deepTools command by running it without any arguments. This is a quick way to understand the basic input requirements and expected output of a tool. ```bash $ bamCoverage ``` -------------------------------- ### multiBamSummary usage example Source: https://deeptools.readthedocs.io/en/develop/content/tools/multiBamSummary This is a general usage example for the multiBamSummary command, showing its basic structure and common subcommands like 'bins' and 'BED-file'. It indicates that the tool accepts version information and other arguments. ```bash usage: multiBamSummary [-h] [--version] ... ``` -------------------------------- ### Start IGV Genome Browser Source: https://deeptools.readthedocs.io/en/develop/content/help_faq_galaxy Commands to launch the IGV genome browser on different operating systems. Requires Java installation. IGV is used for visualizing genomic data like bigWig and BED files. ```bash igv.sh ``` ```bat igv.bat ``` ```bash igv.command ``` -------------------------------- ### Install deepTools in Galaxy via API Source: https://deeptools.readthedocs.io/en/develop/content/installation Installs the deepTools suite into a local Galaxy server using the Galaxy API. Requires an API key, Galaxy server URL, and the Tool Shed URL. It installs tool wrappers and dependencies, recommended for Galaxy integration. ```python $ python ./scripts/api/install_tool_shed_repositories.py \ --api YOUR_API_KEY -l http://localhost/ \ --url https://toolshed.g2.bx.psu.edu/ \ -o bgruening -r --name suite_deeptools \ --tool-deps --repository-deps --panel-section-name deepTools ``` -------------------------------- ### bamPEFragmentSize Usage Example Source: https://deeptools.readthedocs.io/en/develop/content/tools/bamPEFragmentSize This snippet shows an example of how to use the bamPEFragmentSize command-line tool. It specifies input BAM files, an output histogram file, a plot title, maximum fragment length, and sample labels. ```bash $ deepTools2.0/bin/bamPEFragmentSize \ -hist fragmentSize.png \ -T "Fragment size of PE RNA-seq data" \ --maxFragmentLength 1000 \ -b testFiles/RNAseq_sample1.bam testFiles/RNAseq_sample2.bam \ testFiles/RNAseq_sample3.bam testFiles/RNAseq_sample4.bam \ -samplesLabel sample1 sample2 sample3 sample4 ``` -------------------------------- ### Example Usage (plotHeatmap) Source: https://deeptools.readthedocs.io/en/develop/content/tools/plotHeatmap A basic example demonstrating how to use the plotHeatmap command with a matrix file. ```bash plotHeatmap -m matrix.gz ``` -------------------------------- ### computeMatrix scale-regions Example Source: https://deeptools.readthedocs.io/en/develop/content/tools/computeMatrix This example demonstrates how to use the 'scale-regions' sub-command of computeMatrix. It specifies input bigWig files (-S), a BED file for regions (-R), and a buffer size (-b) for analysis. ```bash computeMatrix scale-regions -S -R -b 1000 ``` -------------------------------- ### Install deepTools via Conda (Conda Forge/Bioconda) Source: https://deeptools.readthedocs.io/en/develop/_sources/content/installation Installs the latest release of deepTools and its dependencies using conda from the conda-forge and bioconda channels. This is the recommended method for command-line usage. An alternative command is provided for ARM architectures (e.g., M1 on OSX) to create a specific environment. ```bash $ conda install -c conda-forge -c bioconda deeptools ``` ```bash $ CONDA_SUBDIR=osx-64 conda create -c conda-forge -c bioconda -n deeptools deeptools ``` -------------------------------- ### Install specific deepTools version using Pip Source: https://deeptools.readthedocs.io/en/develop/content/installation Installs a specific version of deepTools (e.g., 3.5.3) from PyPI using pip. This allows users to pin to a particular version for reproducibility or to avoid issues with newer releases. ```bash $ pip install deeptools==3.5.3 ``` -------------------------------- ### Install deepTools using Pip (Latest Release) Source: https://deeptools.readthedocs.io/en/develop/content/installation Installs the latest stable release of deepTools directly from the Python Package Index (PyPI) using pip. This method is suitable for users who prefer pip for package management. ```bash $ pip install deeptools ``` -------------------------------- ### Example Usages for multiBamSummary Source: https://deeptools.readthedocs.io/en/develop/content/tools/multiBamSummary Demonstrates how to use the multiBamSummary tool with different input types, including BAM files and BED files, for computing genomic region coverages. ```bash # Summarize coverage from multiple BAM files into bins multiBamSummary bins --bamfiles file1.bam file2.bam -o results.npz # Summarize coverage using a BED file for region definitions multiBamSummary BED-file --BED selection.bed --bamfiles file1.bam file2.bam -o results.npz ``` -------------------------------- ### correctGCBias Usage Example Source: https://deeptools.readthedocs.io/en/develop/content/tools/correctGCBias This example shows the basic usage of the correctGCBias command-line tool, illustrating the required arguments and their typical values. It highlights the dependency on the output of computeGCBias and the requirement for a genome file in 2bit format. ```bash usage: correctGCBias -b file.bam --effectiveGenomeSize 2150570000 -g mm9.2bit --GCbiasFrequenciesFile freq.txt -o gc_corrected.bam help: correctGCBias -h / correctGCBias --help ``` -------------------------------- ### Install deepTools using Conda Source: https://deeptools.readthedocs.io/en/develop/content/installation Installs the latest stable version of deepTools and its requirements using conda from the conda-forge and bioconda channels. This is the recommended installation method for command-line usage. ```bash $ conda install -c conda-forge -c bioconda deeptools ``` -------------------------------- ### Usage Example for ChIP-seq Source: https://deeptools.readthedocs.io/en/develop/content/tools/bamCoverage An example demonstrating the use of bamCoverage for ChIP-seq data, including options for bin size, normalization, excluding specific chromosomes, and extending reads. ```APIDOC ## Usage example for ChIP-seq This example demonstrates using `bamCoverage` with options for higher resolution bin size, 1x genome size normalization, excluding chromosome X, and extending reads: ```bash bamCoverage --bam a.bam -o a.SeqDepthNorm.bw \ --binSize 10 \ --normalizeUsing RPGC \ --effectiveGenomeSize 2150570000 \ --ignoreForNormalization chrX \ --extendReads ``` ### Output File Format If `--outFileFormat bedgraph` is used, the output can be inspected with commands like `head`: ```bash $ head SeqDepthNorm_chr19.bedgraph 19 60150 60250 9.32 19 60250 60450 18.65 19 60450 60650 27.97 19 60650 60950 37.29 19 60950 61000 27.97 19 61000 61050 18.65 19 61050 61150 27.97 19 61150 61200 18.65 19 61200 61300 9.32 19 61300 61350 18.65 ``` Consecutive bins with the same read overlap count will be merged in the output. ``` -------------------------------- ### ComputeMatrix Reference Point Example Source: https://deeptools.readthedocs.io/en/develop/content/tools/computeMatrix An example demonstrating how to use the `computeMatrix` tool with the `reference-point` subcommand. This command calculates a matrix based on bigWig files and a BED file, specifying upstream and downstream regions relative to a reference point. ```bash computeMatrix reference-point -S -R -a 3000 -b 3000 ``` -------------------------------- ### Get alignmentSieve help Source: https://deeptools.readthedocs.io/en/develop/content/tools/alignmentSieve This snippet shows how to access the help documentation for the alignmentSieve tool. This is useful for understanding all available options and their usage. ```bash alignmentSieve -h alignmentSieve --help ``` -------------------------------- ### plotCoverage Usage Example Source: https://deeptools.readthedocs.io/en/develop/content/tools/plotCoverage This snippet shows the basic command-line usage for the plotCoverage tool, including required and optional arguments for specifying input BAM files and the output plot file. ```bash usage: plotCoverage -b sample1.bam sample2.bam -o coverage.png help: plotCoverage -h / plotCoverage --help ``` -------------------------------- ### computeMatrix Reference Point Example Source: https://deeptools.readthedocs.io/en/develop/content/tools/computeMatrix An example of using computeMatrix in reference-point mode to compute signal distribution relative to genomic regions. It takes bigwig files as signal input and bed files as region input, with a specified boundary. ```bash computeMatrix reference-point -S -R -b 1000 ``` -------------------------------- ### CountReadsPerBin - Run Example Source: https://deeptools.readthedocs.io/en/develop/source/deeptools Demonstrates how to use the CountReadsPerBin class and its run method to count reads per bin from BAM files. ```APIDOC ## POST /api/CountReadsPerBin/run ### Description Calculates the number of reads per bin for the provided BAM files and parameters. ### Method POST ### Endpoint /api/CountReadsPerBin/run ### Parameters #### Request Body - **test.bamFile1** (file) - Path to the first BAM file. - **test.bamFile2** (file) - Path to the second BAM file. - **binLength** (integer) - The size of each bin. - **numberOfBins** (integer) - The number of bins to create. ### Request Example ```json { "bamFiles": ["test.bamFile1", "test.bamFile2"], "binLength": 50, "numberOfBins": 4 } ``` ### Response #### Success Response (200) - **result** (numpy array) - A transposed numpy array representing reads per bin. #### Response Example ```json { "result": [ [0.0, 0.0, 1.0, 1.0], [0.0, 1.0, 1.0, 2.0] ] } ``` ``` -------------------------------- ### Get info from computeMatrix file Source: https://deeptools.readthedocs.io/en/develop/content/tools/computeMatrixOperations Retrieves and prints group and sample information from a computeMatrix output file. Requires the matrix file as input. ```bash computeMatrixOperations info -m input.mat.gz ``` -------------------------------- ### plotCoverage Usage Example Source: https://deeptools.readthedocs.io/en/develop/content/tools/plotCoverage Demonstrates how to use the plotCoverage tool with BAM files, specifying output files, plot titles, and various filtering options. ```bash $ plotCoverage -b H3K4Me1.bam H3K4Me3.bam H3K27Me3.bam H3K9Me3.bam --plotFile example_coverage -n 1000000 --plotTitle "example_coverage" \ --outRawCounts coverage.tab \ --ignoreDuplicates \ --minMappingQuality 10 \ --region 19 ``` -------------------------------- ### DeepTools: Version Information Source: https://deeptools.readthedocs.io/en/develop/content/tools/multiBigwigSummary A standard argument to display the program's version number and exit. This is helpful for checking the installed deepTools version and ensuring compatibility. ```bash --version ``` -------------------------------- ### Get deepTools Latest Revision Number from Tool Shed Source: https://deeptools.readthedocs.io/en/develop/_sources/content/installation Retrieves the latest revision number for the deepTools suite from the Galaxy Tool Shed. This command is used in conjunction with the Galaxy API installation script to specify the desired version. ```bash $ hg identify https://toolshed.g2.bx.psu.edu/repos/bgruening/suite_deeptools ``` -------------------------------- ### Example BED File Lines Source: https://deeptools.readthedocs.io/en/develop/content/help_glossary Shows example lines from a BED file, which describes genomic intervals. The first three columns (chromosome, start, end) are critical for deepTools. Note the 0-based start and 1-based end convention. ```text chr1 3204562 3661579 NM_001011874 Xkr4 - chr1 4481008 4486494 NM_011441 Sox17 - chr1 4763278 4775807 NM_001177658 Mrpl15 - chr1 4797973 4836816 NM_008866 Lypla1 + ``` -------------------------------- ### Get help for bamCoverage command line tool Source: https://deeptools.readthedocs.io/en/develop/_sources/content/example_step_by_step This snippet shows how to retrieve help and view all available parameters and options for the bamCoverage tool using the command line. It is useful for users who prefer the command-line interface and need to understand the tool's functionality. ```bash /deepTools/bin/bamCoverage --help ``` -------------------------------- ### Install deepTools via Pip (Latest Release or Specific Version) Source: https://deeptools.readthedocs.io/en/develop/_sources/content/installation Installs deepTools using pip. Users can install the latest release from PyPI or a specific version by appending '=='. This method is suitable for command-line usage when conda is not preferred. ```bash $ pip install deeptools ``` ```bash $ pip install deeptools==3.5.3 ``` -------------------------------- ### computeGCBias Usage Source: https://deeptools.readthedocs.io/en/develop/content/tools/computeGCBias Demonstrates the command-line usage for the computeGCBias tool, including required arguments and help options. It shows how to specify input files, genome information, and output file paths. ```bash usage: computeGCBias -b file.bam --effectiveGenomeSize 2150570000 -g mm9.2bit -l 200 --GCbiasFrequenciesFile freq.txt help: computeGCBias -h / computeGCBias --help ``` -------------------------------- ### Get Fragment Start and End from Read - Python Source: https://deeptools.readthedocs.io/en/develop/_modules/deeptools/countReadsPerBin Extracts the start and end positions of a sequencing fragment from a read object. It handles paired-end reads by extending mates to match fragment length and single-end reads with a default fragment length. It can also account for split reads indicated by the CIGAR string. ```python def get_fragment_from_read(self, read): """Get read start and end position of a read. If given, the reads are extended as follows: If reads are paired end, each read mate is extended to match the fragment length, otherwise, a default fragment length is used. If reads are split (give by the CIGAR string) then the multiple positions of the read are returned. When reads are extended the cigar information is skipped. Parameters ---------- read: pysam object. The following values are defined (for forward reads):: |-- -- read.tlen -- --| |-- read.alen --| -----|===============>------------<==============|---- | | | read.reference_start read.reference_end read.pnext and for reverse reads |-- -- read.tlen -- --| |-- read.alen --| -----|===============>-----------<===============|---- | | | read.pnext read.reference_start read.reference_end this is a sketch of a pair-end reads The function returns the fragment start and end, either using the paired end information (if available) or extending the read in the appropriate direction if this is single-end. Parameters ---------- read : pysam read object Returns ------- list of tuples [(fragment start, fragment end)] >>> test = Tester() >>> c = CountReadsPerBin([], 1, 1, 200, extendReads=True) >>> c.defaultFragmentLength=100 >>> c.get_fragment_from_read(test.getRead("paired-forward")) [(5000000, 5000100)] >>> c.get_fragment_from_read(test.getRead("paired-reverse")) [(5000000, 5000100)] >>> c.defaultFragmentLength = 200 """ if read.is_paired: if read.is_reverse: start = read.reference_start end = read.reference_end if read.tlen < 0: # reverse complement pair, the mate is to the left # read.pnext is start of the mate read, read.reference_start is end of the current read start = read.pnext end = read.reference_start else: start = read.reference_start end = read.reference_end if read.tlen < 0: # forward complement pair, the mate is to the right # read.pnext is end of the mate read, read.reference_end is start of the current read start = read.reference_end end = read.pnext # if tlen < 0, it means that the mate is on the left for reverse strand, and on the right for forward strand # But in both cases the fragment is from read.reference_start to read.pnext or read.next_reference_start if read.tlen < 0: if read.is_reverse: fragment_start = read.pnext fragment_end = read.reference_end else: fragment_start = read.reference_start fragment_end = read.pnext else: if read.is_reverse: # fragment_start = read.reference_start - (read.tlen - read.alen) fragment_start = read.reference_start - (abs(read.tlen) - read.alen) fragment_end = read.reference_end else: # fragment_end = read.reference_end + (read.tlen - read.alen) fragment_end = read.reference_end + (read.tlen - read.alen) fragment_start = read.reference_start else: if self.extendReads: if read.is_reverse: fragment_start = read.reference_start - (self.defaultFragmentLength - len(read)) fragment_end = read.reference_end else: fragment_start = read.reference_start fragment_end = read.reference_end + (self.defaultFragmentLength - len(read)) else: fragment_start = read.reference_start fragment_end = read.reference_end return [[fragment_start, fragment_end]] ``` -------------------------------- ### bamPEFragmentSize Command-line Arguments Source: https://deeptools.readthedocs.io/en/develop/content/tools/bamPEFragmentSize This snippet outlines the command-line usage for the bamPEFragmentSize tool, including the main arguments and their short forms. It indicates the expected input and output files. ```bash usage: bamPEFragmentSize -b sample1.bam sample2.bam -o hist.png help: bamPEFragmentSize -h / bamPEFragmentSize --help ``` -------------------------------- ### Get Smoothed Genomic Range (Python) Source: https://deeptools.readthedocs.io/en/develop/_modules/deeptools/countReadsPerBin Calculates a smoothed genomic range centered on a tile index. This method adjusts the start and end positions to encompass a specified `smoothRange`, ensuring the output is within the bounds of `maxPosition`. It uses `numpy` for ceiling and floor operations. The output is a tuple of adjusted start and end indices. ```python def getSmoothRange(self, tileIndex, tileSize, smoothRange, maxPosition): """ Given a tile index position and a tile size (length), return the a new indices over a larger range, called the smoothRange. This region is centered in the tileIndex an spans on both sizes to cover the smoothRange. The smoothRange is trimmed in case it is less than zero or greater than maxPosition :: ---------------|==================|------------------ tileStart |--------------------------------------| | <-- smoothRange --> | | tileStart - (smoothRange-tileSize)/2 Test for a smooth range that spans 3 tiles. Examples -------- >>> c = CountReadsPerBin([], 1, 1, 1, 0) >>> c.getSmoothRange(5, 1, 3, 10) (4, 7) Test smooth range truncated on start. >>> c.getSmoothRange(0, 10, 30, 200) (0, 2) Test smooth range truncated on start. >>> c.getSmoothRange(1, 10, 30, 4) (0, 3) Test smooth range truncated on end. >>> c.getSmoothRange(5, 1, 3, 5) (4, 5) Test smooth range not multiple of tileSize. >>> c.getSmoothRange(5, 10, 24, 10) (4, 6) """ smoothTiles = int(smoothRange / tileSize) if smoothTiles == 1: return (tileIndex, tileIndex + 1) smoothTilesSide = float(smoothTiles - 1) / 2 smoothTilesLeft = int(np.ceil(smoothTilesSide)) smoothTilesRight = int(np.floor(smoothTilesSide)) + 1 indexStart = max(tileIndex - smoothTilesLeft, 0) indexEnd = min(maxPosition, tileIndex + smoothTilesRight) return (indexStart, indexEnd) ``` -------------------------------- ### Run bamCoverage Command - deepTools Source: https://deeptools.readthedocs.io/en/develop/content/list_of_tools Demonstrates a typical command-line usage for the bamCoverage tool in deepTools. This includes specifying input BAM files, output file names and formats, fragment length, and options to ignore duplicates and set a scale factor. The example highlights standard parameters for read coverage normalization. ```bash $ bamCoverage --bam myAlignedReads.bam \ --outFileName myCoverageFile.bigWig \ --outFileFormat bigwig \ --fragmentLength 200 \ --ignoreDuplicates \ --scaleFactor 0.5 ``` -------------------------------- ### Get Regions Per Group Source: https://deeptools.readthedocs.io/en/develop/_modules/deeptools/heatmapper Retrieves a list of regions, where each element corresponds to a group and contains information about individual regions (chrom, start, end, strand, name). Dependencies: None. ```python def get_regions(self): """Returns the regions per group Returns ------- list Each element of the list is itself a list of dictionaries containing the regions info: chrom, start, end, strand, name etc. Each element of the list corresponds to each of the groups """ regions = [] for idx in range(len(self.group_labels)): start = self.group_boundaries[idx] end = self.group_boundaries[idx + 1] regions.append(self.regions[start:end]) return regions ``` -------------------------------- ### Example FASTA File Sequence Source: https://deeptools.readthedocs.io/en/develop/content/help_glossary Illustrates a single sequence entry in FASTA format, used for DNA, RNA, or protein sequences. The format begins with a header line starting with '>', followed by the sequence data. ```fasta >gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus] LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX IENY ``` -------------------------------- ### Get Help for bamCoverage - deepTools Source: https://deeptools.readthedocs.io/en/develop/content/list_of_tools Shows how to access the help documentation for the bamCoverage tool using the --help or -h flags. This is a standard way to discover all available command-line options and parameters for any deepTools command. ```bash $ bamCoverage --help $ bamCoverage -h ``` -------------------------------- ### Get fragment from paired-end and single-end reads Source: https://deeptools.readthedocs.io/en/develop/source/deeptools Demonstrates retrieving fragment start and end points from reads using the `get_fragment_from_read` method. It showcases behavior with paired-end and single-end reads, varying `defaultFragmentLength` and `extendReads` parameters. ```python >>> test = Tester() >>> c = CountReadsPerBin([], 1, 1, 200, extendReads=True) >>> c.defaultFragmentLength=100 >>> c.get_fragment_from_read(test.getRead("paired-forward")) [(5000000, 5000100)] >>> c.get_fragment_from_read(test.getRead("paired-reverse")) [(5000000, 5000100)] >>> c.defaultFragmentLength = 200 >>> c.get_fragment_from_read(test.getRead("single-forward")) [(5001491, 5001691)] >>> c.get_fragment_from_read(test.getRead("single-reverse")) [(5001536, 5001736)] >>> c.defaultFragmentLength = 'read length' >>> c.get_fragment_from_read(test.getRead("single-forward")) [(5001491, 5001527)] >>> c.defaultFragmentLength = 'read length' >>> c.extendReads = False >>> c.get_fragment_from_read(test.getRead("paired-forward")) [(5000000, 5000036)] ``` -------------------------------- ### bedGraph File Example - Genomic Intervals with Scores Source: https://deeptools.readthedocs.io/en/develop/_sources/content/help_glossary An example of lines from a bedGraph file, which is similar to BED but specifically designed to store scores associated with genomic intervals. It typically contains four columns: chromosome, start position (0-based), end position (1-based), and a score. This format is often used for representing data like read coverage or signal intensity across the genome. ```text chr1 10 20 1.5 chr1 20 30 1.7 chr1 30 40 2.0 chr1 40 50 1.8 ``` -------------------------------- ### bamCompare Command Line Usage Source: https://deeptools.readthedocs.io/en/develop/_sources/content/tools/bamCompare This snippet shows the command-line usage of the bamCompare tool, including its arguments and how to execute it. ```bash bamCompare --help ``` -------------------------------- ### Compute read coverage over a specific region Source: https://deeptools.readthedocs.io/en/develop/_sources/content/example_api_tutorial Calculates the read coverage for a specified genomic region (chromosome, start, end) using the initialized CountReadsPerBin object. Returns coverage data per bin. ```python cr.count_reads_in_region('chr2L', 0, 1000) ``` -------------------------------- ### Get Coverage of Region (Extended Reads) Source: https://deeptools.readthedocs.io/en/develop/source/deeptools Calculates the number of read fragments that overlap with specified regions in a BAM file. This example shows how reads are extended to a fragment length, and the output may contain NaNs where no reads overlap. Requires `pysam`. ```python >>> test = Tester() >>> import pysam >>> c = CountReadsPerBin([], stepSize=1, extendReads=300) >>> c.get_coverage_of_region(pysam.AlignmentFile(test.bamFile_PE), 'chr2', ... [(5000833, 5000834), (5000834, 5000835)]) array([4., 5.]) ``` ```python >>> c.zerosToNans = True >>> c.get_coverage_of_region(pysam.AlignmentFile(test.bamFile_PE), 'chr2', ... [(5000090, 5000100), (5000100, 5000110)]) array([ 1., nan]) ``` -------------------------------- ### Initialize CountReadsPerBin Source: https://deeptools.readthedocs.io/en/develop/content/example_api_tutorial Initializes the `CountReadsPerBin` object for counting read coverage. It takes a list of BAM files, bin length, and step size as primary arguments. Dependencies include the `deeptools.countReadsPerBin` module. The output is a `CountReadsPerBin` object ready for further operations. ```Python import deeptools.countReadsPerBin as crpb bam_file = "file.bam" cr = crpb.CountReadsPerBin([bam_file], binLength=50, stepSize=50) ``` -------------------------------- ### FASTA Sequence Format Example Source: https://deeptools.readthedocs.io/en/develop/_sources/content/help_glossary The FASTA format is a simple text-based format for representing nucleotide or peptide sequences. It begins with a single-line description (header line) for the sequence, followed by lines of sequence data. The header line starts with a '>' character. This format is commonly used for DNA/RNA or protein sequences, including entire genomes. ```fasta >gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus] LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX IENY ``` -------------------------------- ### Initialize CountReadsPerBin for region coverage Source: https://deeptools.readthedocs.io/en/develop/_sources/content/example_api_tutorial Initializes the CountReadsPerBin object with a BAM file, specifying bin length and step size for coverage calculation. Requires a BAM file and its index. ```python bam_file = "file.bam" cr = crpb.CountReadsPerBin([bam_file], binLength=50, stepSize=50) ``` -------------------------------- ### Get Read Fragment (Python) Source: https://deeptools.readthedocs.io/en/develop/_modules/deeptools/countReadsPerBin Retrieves fragment start and end positions for a given read. It handles different fragment length definitions ('read length', default, or centered) and considers paired-end read properties. Dependencies include the `Read` object and potentially `pysam` for `get_blocks`. Outputs a list of tuples representing fragment coordinates. ```python def get_fragment_from_read(self, read): """ Returns the start and end of a fragment, based on the read object and the parameters set in the object. Parameters ---------- read : Read a read object, with attributes like is_reverse, next_reference_start, reference_start, reference_end, query_name, template_length Returns ------- list a list of tuples, where each tuple is a start and end position of a fragment. """ # if no extension is needed, use pysam get_blocks # to identify start and end reference positions. # get_blocks return a list of start and end positions # based on the CIGAR if skipped regions are found. # E.g for a cigar of 40M260N22M # get blocks return two elements for the first 40 matches # and the for the last 22 matches. if self.defaultFragmentLength == 'read length': return read.get_blocks() else: if self.is_proper_pair(read, self.maxPairedFragmentLength): if read.is_reverse: fragmentStart = read.next_reference_start fragmentEnd = read.reference_end else: fragmentStart = read.reference_start # the end of the fragment is defined as # the start of the forward read plus the insert length fragmentEnd = read.reference_start + abs(read.template_length) # Extend using the default fragment length else: if read.is_reverse: fragmentStart = read.reference_end - self.defaultFragmentLength fragmentEnd = read.reference_end else: fragmentStart = read.reference_start fragmentEnd = read.reference_start + self.defaultFragmentLength if self.center_read: fragmentCenter = fragmentEnd - (fragmentEnd - fragmentStart) / 2 fragmentStart = int(fragmentCenter - read.infer_query_length(always=False) / 2) fragmentEnd = fragmentStart + read.infer_query_length(always=False) assert fragmentStart < fragmentEnd, "fragment start greater than fragment" \ "end for read {}".format(read.query_name) return [(fragmentStart, fragmentEnd)] ``` -------------------------------- ### Running a Typical DeepTools Command Source: https://deeptools.readthedocs.io/en/develop/_sources/content/list_of_tools This snippet demonstrates the general structure of a deepTools command, specifically using `bamCoverage`. It highlights common arguments for input files, output files, output format, fragment length, ignoring duplicates, and scale factor. This command is used for generating bigWig files from BAM files. ```bash $ bamCoverage --bam myAlignedReads.bam \ --outFileName myCoverageFile.bigWig \ --outFileFormat bigwig \ --fragmentLength 200 \ --ignoreDuplicates \ --scaleFactor 0.5 ``` -------------------------------- ### Set Start Region Label (plotHeatmap) Source: https://deeptools.readthedocs.io/en/develop/content/tools/plotHeatmap Sets the label displayed for the start of a region, primarily used in 'scale-regions' mode. The default is 'TSS' (transcription start site). ```bash plotHeatmap --startLabel