Skip to main content

Plot of coverage from bam file

Project description

BAM2Plot Package Documentation

The BAM2Plot package provides a comprehensive toolset for processing and visualizing coverage data from BAM files. This package simplifies the analysis process and enables the generation of coverage plots for multiple reference sequences within a single BAM file.

bam2plot generates coverage plots: plot

... and cumulative coverage plots for each reference (e.g. chromosomes) for each sample: plot

Dependencies

bam2plot depends on perbase, which you can install via:

cargo install perbase 
# or
conda install -c bioconda perbase

Installation

You can install BAM2Plot using the following pip command:

pip install bam2plot

Usage

Once installed, you can use the bam2plot command to perform coverage analysis on BAM files and generate coverage plots. Here's how to use it:

bam2plot --bam <path_to_bam_file> [--sample_name <sample_name>] [--outpath <output_path>] [--rolling_window <window_size>] [--threshold <coverage_threshold>]

Replace the placeholders with the following information:

  • <path_to_bam_file>: Path to the input BAM file (required).
  • <outpath>: Path to save the output plots (optional, default: <bam2plot>).
  • <whitelist>: List of chromosomes or reference sequences to keep. A comma separated list. Example: --whitelist=seq1,seq2
  • <window_size>: Rolling window size for calculating the depth average (optional, default: 100).
  • <coverage_threshold>: Coverage threshold for plotting (optional, default: 3).

Outputs

The BAM2Plot package generates coverage plots for each reference sequence in the BAM file. The plots are saved as SVG and PNG files in the specified output path or the default location.

API Documentation

The BAM2Plot package provides several modules and functions for performing coverage analysis. Here's an overview of the main components:

bam2plot.sorting

This module handles sorting BAM files using the pysam library.

bam2plot.mpileup

This module performs the pysam.mpileup operation and processes the output.

bam2plot.analysis

This module creates a Pandas DataFrame from the mpileup output and calculates the rolling average depth.

bam2plot.plotting

This module generates coverage plots using seaborn and matplotlib libraries.

Examples

Here's an example of how to use the BAM2Plot package:

bam2plot --bam input.bam --sample_name my_sample --outpath output_folder --rolling_window 50 --threshold 5

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bam2plot-0.1.9.tar.gz (16.8 kB view hashes)

Uploaded Source

Built Distribution

bam2plot-0.1.9-py3-none-any.whl (17.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page