Skip to content
Martin Asser Hansen edited this page Oct 2, 2015 · 6 revisions

Biopiece: calc_density

Description

calc_density read BED entries from stream and calculate the density (count or total SCOREs of BED entries) within each sliding window.

Usage

... | calc_density [options]

Options

[-?               | --help]                               #  Print full usage description.
[-I <file!>       | --stream_in=<file!>]                  #  Read input from stream file   -  Default=STDIN
[-O <file>        | --stream_out=<file>]                  #  Write output to stream file   -  Default=STDOUT
[-v               | --verbose]                            #  Verbose output.
[-w <window_size> | --window_size=<sliding window size>]  # Set the size of sliding window -  Default=10000
[-s <increment>   | --step_size=<increment>]              # Set the size of increment      -  Default=window_size

Examples

Consider the following BED entries in the file test.bed:

Chr10	1026	1051
Chr10	10027	10051
Chr10	13032	13056
Chr10	11351	11368

To read in this BED file, use read_bed to calculate density distribution over a chromosome:

read_bed -i test.bed | calc_density -w 10000 -s 5000

(all records from the input-stream)
---
WIN_CHR: Chr10
WIN_CHR_BEG: 0
WIN_CHR_END: 10000
WIN_DENSITY: 1
---
WIN_CHR: Chr10
WIN_CHR_BEG: 5000
WIN_CHR_END: 15000
WIN_DENSITY: 3
---
WIN_CHR: Chr10
WIN_CHR_BEG: 10000
WIN_CHR_END: 20000
WIN_DENSITY: 3
---

All records piped into the calc_density are kept and emitted ahead of its actual results, so that they can be used for other biopieces.

If a BED file contains SCORE field, calc_density uses the SCORE for the density calculation.

For example, for a BED file (test2.bed) shown below:

Chr10   1026    1051	chr10_tag1	1
Chr10   10027   10051	chr10_tag2	10
Chr10   13032   13056	chr10_tag3	2
Chr10   11351   11368	chr10_tag4	3

The result of calc_density is:

read_bed -i test2.bed | calc_density -w 10000 -s 5000

(all records from the input-stream)
---
WIN_CHR: Chr10
WIN_CHR_BEG: 0
WIN_CHR_END: 10000
WIN_DENSITY: 1
---
WIN_CHR: Chr10
WIN_CHR_BEG: 5000
WIN_CHR_END: 15000
WIN_DENSITY: 15
---
WIN_CHR: Chr10
WIN_CHR_BEG: 10000
WIN_CHR_END: 20000
WIN_DENSITY: 15
---

The window slide from the beginning of a chromosome through to the last BED entry in the same chromosome.

For example, for a BED file below (test3.bed):

Chr10   37301   37325   Chr10_tag5      7

The result of calc_density is:

read_bed -i test3.bed | calc_density -w10000

(all records from the input-stream)
---
WIN_CHR: Chr10
WIN_CHR_BEG: 0
WIN_CHR_END: 10000
WIN_DENSITY: 0
---
WIN_CHR: Chr10
WIN_CHR_BEG: 10000
WIN_CHR_END: 20000
WIN_DENSITY: 0
---
WIN_CHR: Chr10
WIN_CHR_BEG: 20000
WIN_CHR_END: 30000
WIN_DENSITY: 0
---
WIN_CHR: Chr10
WIN_CHR_BEG: 30000
WIN_CHR_END: 40000
WIN_DENSITY: 7
---

See also

read_bed

Author

Chol-Hee JUNG - Copyright (C) - All rights reserved.

jung.cholhee@gmail.com

December 2010

License

GNU General Public License version 2

http://www.gnu.org/copyleft/gpl.html

Help

calc_density is part of the Biopieces framework.

http://www.biopieces.org

Clone this wiki locally