<p>Devon gives a practical answer using the great deepTools package. These should be the theoretical, lower level steps behind the plots:  </p>

<ul>
<li><p>Compute read depth at each genomic position, using for example <code>samtools mpileup</code> with appropriate flags to accept/reject reads. You get a table like:</p>

<pre><code>Pos       Depth
chr1:1    0
chr1:2    10
chr1:3    11
...
chrX:100  10
</code></pre></li>
<li><p>For each unique value <em>x</em> in the <em>Depth</em> column count how many genomic positions have depth >= <em>x</em>. You can use Unix tools like <code>sort ... | uniq -c | awk ...</code> for this. You get a table like:</p>

<pre><code>Depth   N bases with depth &gt;= x   % bases with depth &gt;= x
0       (all genomic positions)   100 %
1       1000                      90 %
2       995                       85 %
.
.
.
N       2                         0.1 %                         
</code></pre></li>
<li><p>Now just plot column <code>Depth</code> (x) vs <code>% bases with depth &gt;= x</code> (y) with R or you favourite plotting tool.</p></li>
</ul>

<p>Did I get it right?</p>

CC BY-SA 3.0
2018-01-11T13:13:32.280Z
yes, not sure bust does picar collectwgsmetrics do something similar?
novicebioinforesearcher
CC BY-SA 3.0
2018-01-11T09:01:50.710Z
2018-01-11T10:12:32.983Z
2018-01-11T10:12:32.983Z
dariober
<p>The general steps are:</p>

<ol>
<li>Install <a href="http://deeptools.readthedocs.io/en/latest/content/installation.html" rel="noreferrer">deepTools</a></li>
<li>Run <a href="http://deeptools.readthedocs.io/en/latest/content/tools/plotCoverage.html" rel="noreferrer">plotCoverage</a> on your BAM files</li>
<li>Remove the left-most plot in photoshop/gimp/imagemagick</li>
</ol>

CC BY-SA 3.0
2018-01-11T00:36:35.663Z
updated my question
novicebioinforesearcher
CC BY-SA 3.0
2018-01-11T01:07:16.393Z
Yes, I mean the left plot in the example, since it looks like you want % >= the coverage value on the X axis.
Devon Ryan
CC BY-SA 3.0
2018-01-11T00:24:27.057Z
2018-01-11T00:24:27.057Z
Devon Ryan
<p>Given a aligned bam file (wgs/bwa-mem) what steps do i need to perform to generate a plot as seen below (from this <a href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0066621" rel="nofollow noreferrer">paper</a>):</p>

<p><a href="https://i.sstatic.net/DQS8b.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/DQS8b.png" alt="enter image description here"></a></p>

<p>We are trying to see how much of genome was covered using pacbio and illumina for cow.</p>

<hr>

<p>You mean remove this left plot?
<a href="https://i.sstatic.net/JlgrX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JlgrX.png" alt="enter image description here"></a></p>

<wgs>
Plot percentage of genome covered
# Plot percentage of genome covered

(Asked by: username_0 on 2018-01-11)

Given a aligned bam file (wgs/bwa-mem) what steps do i need to perform to generate a plot as seen below (from this [paper](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0066621)):

[![enter image description here](https://i.sstatic.net/DQS8b.png)](https://i.sstatic.net/DQS8b.png)

We are trying to see how much of genome was covered using pacbio and illumina for cow.

---

You mean remove this left plot?
[![enter image description here](https://i.sstatic.net/JlgrX.png)](https://i.sstatic.net/JlgrX.png)

**Tags:** wgs

---

## 2 answers

### Answer by username_2 on 2018-01-11. Score: 5 | Accepted answer

The general steps are:

1. Install [deepTools](http://deeptools.readthedocs.io/en/latest/content/installation.html)
2. Run [plotCoverage](http://deeptools.readthedocs.io/en/latest/content/tools/plotCoverage.html) on your BAM files
3. Remove the left-most plot in photoshop/gimp/imagemagick

> **Comments:**
> **username_0**: updated my question  
> **username_2**: Yes, I mean the left plot in the example, since it looks like you want % >= the coverage value on the X axis.  

---

### Answer by username_1 on 2018-01-11. Score: 1

Devon gives a practical answer using the great deepTools package. These should be the theoretical, lower level steps behind the plots:  

Compute read depth at each genomic position, using for example samtools mpileup with appropriate flags to accept/reject reads. You get a table like:
Pos       Depth
chr1:1    0
chr1:2    10
chr1:3    11
...
chrX:100  10

For each unique value x in the Depth column count how many genomic positions have depth >= x. You can use Unix tools like sort ... | uniq -c | awk ... for this. You get a table like:
Depth   N bases with depth >= x   % bases with depth >= x
0       (all genomic positions)   100 %
1       1000                      90 %
2       995                       85 %
.
.
.
N       2                         0.1 %                         

Now just plot column Depth (x) vs % bases with depth >= x (y) with R or you favourite plotting tool.

Did I get it right?

> **Comments:**
> **username_0**: yes, not sure bust does picar collectwgsmetrics do something similar?  

---

