Giter Club home page Giter Club logo

tinycov's Introduction

tinycov

PyPI version build codecov Codacy Badge Code style: black

Tinycov is a small standalone command line utility written in python to plot the coverage of a BAM file quickly. This software was inspired by Matt Edwards' genome coverage plotter.

Installation

To install the stable version: pip3 install --user tinycov

To install the development version:

git clone https://github.com/cmdoret/tinycov.git
cd tinycov
pip install .

Input

Only a BAM file alignment is required as input. If it is not coordinate-sorted, tinycov will make a sorted copy named input.sorted.bam if the file is named input.bam.

Output

If no output is provided, the coverage plot will be displayed interactively using matplotlib. If --out is used, the plot will be saved in a format determined by the output file's extension.

Additionally, if --text is provided, an output text file will be saved in the bedgraph format with overlapping windows (depending on the values of --res and --skip).

Usage

The tinycov commands can be invoked from the command line to list subcommands.


Usage: tinycov [OPTIONS] COMMAND [ARGS]...

  tinycov: visualisation of coverage from BAM files using rolling window
  averages.

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  covhist  Visualise the histogram of coverage in rolling windows.
  covplot  Visualise coverage in rolling windows, optionally save results
           to...

The covplot subcommand plots the coverage in sliding windows along the genome. A bedgraph file with the coverage of each window can be generated using the --text option.


Usage: tinycov covplot [OPTIONS] BAM

  Visualise coverage in rolling windows, optionally save results to a
  bedgraph file.

Options:
  -N, --no-filter          Use all reads. By default, PCR duplicates and
                           secondary alignments are excluded

  -m, --max-depth INTEGER  Maximum read depth permitted. Position with higher
                           coverage will set to this value

  -o, --out PATH           Output file where to write the plot. If not
                           provided, the plot is shown interactively

  -w, --whitelist TEXT     Only include those chromosomes in the plot. List of
                           comma-separated chromosome names.

  -b, --blacklist TEXT     Exclude those chromosomes from the plot. List of
                           comma-separated chromosome names.

  -n, --name TEXT          Name of the sample (plot title). Base name of input
                           file by default

  -B, --bins TEXT          Tab-separated file of three columns (chromosome,
                           start, end) without header containing a custom
                           binning to use. Overrides --res and --skip,
                           optional.

  -s, --skip INTEGER       Stride between windows, in basepairs.  [default:
                           1000]

  -r, --res INTEGER        Size of windows in which to compute coverage, in
                           basepairs.  [default: 10000]

  -t, --text PATH          Output file where to write the raw data table.
  -p, --ploidy INTEGER     Ploidy of input sample, used to estimate coverage
                           threshold for aneuploidies. Setting to 0 disables
                           estimations.

  --version                Show the version and exit.
  --help                   Show this message and exit.

The covhist subcommands generates a histogram of coverage values by window. To get a histogram of coverage by basepair, just set --res to 1.


Usage: tinycov covhist [OPTIONS] BAM

  Visualise the histogram of coverage in rolling windows.

Options:
  -N, --no-filter          Use all reads. By default, PCR duplicates and
                           secondary alignments are excluded

  -m, --max-depth INTEGER  Maximum read depth permitted. Position with higher
                           coverage will set to this value

  -o, --out PATH           Output file where to write the plot. If not
                           provided, the plot is shown interactively

  -w, --whitelist TEXT     Only include those chromosomes in the plot. List of
                           comma-separated chromosome names.

  -b, --blacklist TEXT     Exclude those chromosomes from the plot. List of
                           comma-separated chromosome names.

  -n, --name TEXT          Name of the sample (plot title). Base name of input
                           file by default

  -B, --bins TEXT          Tab-separated file of three columns (chromosome,
                           start, end) without header containing a custom
                           binning to use. Overrides --res and --skip,
                           optional.

  -s, --skip INTEGER       Stride between windows, in basepairs.  [default:
                           1000]

  -r, --res INTEGER        Size of windows in which to compute coverage, in
                           basepairs.  [default: 10000]

  --version                Show the version and exit.
  --help                   Show this message and exit.

tinycov's People

Contributors

abignaud avatar cmdoret avatar yfuruta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tinycov's Issues

allow more RAM for java

Hi,

Thank you very much for such great tool!

Is it possible to set more RAM for java to allow tinycov to operate on larger bam files?

I have encountered such error in case of larger bam files:

line 44: 8684 Segmentation fault (core dumped) tinycov covplot -r 1000 -s 500 -n $prefix $wdir/$out -o $wdir/$prefix"_coverage_plot"
Command line run, unsetting DISPLAY variable...
Display:
Java memory size is set to 1200M
Launching application...

Bests,
Jan

Installation with pip failed

Hello,

When trying to install tinycov using pip, I encountered the following error:

Traceback (most recent call last): File "/dss/dssfs02/lwp-dss-0001/pn69xe/pn69xe-dss-0000/di52zuy/ignite_tools_py3/bin/pip", line 7, in <module> from pip._internal.main import main ModuleNotFoundError: No module named 'pip._internal.main'

I managed to install it however by running python setup.py install --user.

TODOs

Features:

  • Accept multiple BAMs and combine plots
  • Allow to plot lines instead of points
  • Add option to disable ploidy estimation lines

Packaging:

  • Write unit tests
  • Add CI
  • Automate deployment on Pypi

feature request

Thank you for creating tinycov, I really like the concept!!

I notice some cosmetic issues with the output but I'm sure you're aware.

But one perhaps useful thing: Would it be possible allow import of cov data from another source, such as d4 or bedgraph? Then something like mosdepth could be used to get the coverage data, which might be quicker than using pysam?

Good work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.