<p>So consider this, you know how many reads map to each of your genes (1). Does that tell you anything about (2) the number of reads that mapped against non-gene regions (3) the number of reads that did not map against the genome at all? </p>

<p>If you only use the gtf files, you know the number of (1) but not of (2) and (3). To me it sounds like you would want to do something as described in <a href="https://www.biostars.org/p/138116/" rel="nofollow noreferrer">this post</a>.</p>

<p>What it boils down to is:</p>

<p>Finding out how many (unique) reads are mapped, counting pairs once</p>

<pre><code>samtools view -F 0x4 foo.sorted.bam | cut -f 1 | sort | uniq | wc -l
</code></pre>

<p>Counting how many total reads you have. Since you have paired-end data the number of forward reads suffice:</p>

<pre><code>cat forward_reads.fastq | grep '@' | wc -l
</code></pre>

<p>The percentage is then simply <code>mapped_reads/total_reads</code></p>

CC BY-SA 4.0
2019-07-26T10:56:41.543Z
@terdon sorry about that, I updated my answer
Jvstonebridge
CC BY-SA 4.0
2019-07-26T11:28:56.777Z
Perfect! Thank you and welcome aboard!
terdon
CC BY-SA 4.0
2019-07-26T09:49:49.870Z
2019-07-26T11:28:43.847Z
2019-07-26T11:28:43.847Z
Jvstonebridge
<blockquote>
  <p>I want to know how what percentage of my reads mapped to reference
  genome.</p>
</blockquote>

<p>And the Log.final.out file from STAR doesn't tell you that?</p>

CC BY-SA 4.0
2019-07-26T16:52:52.607Z
2019-07-26T16:52:52.607Z
swbarnes2
<p>I am doing paired end RNA-seq analysis. I used STAR mapper and then StringTie for getting quantification of my data. After successfully running StringTie, I got <code>.gtf</code> files which will give me information about genes, their coverage along with TPM and FPKM values. It also produced some more <code>.ctab</code> files.</p>

<p>I want to know how what percentage of my reads mapped to reference genome. I <a href="https://www.biostars.org/p/5165/" rel="nofollow noreferrer">know</a> this can be done with BAM or BED files produced after STAR alignment. However, I want to know if this can be done with output files generated by StringTie?</p>

<p>I just want to clarify my question after reading comments and answers I am getting. I want to know if this can be done with <code>.gtf</code> files of StringTie. As I mentioned before, I already know how to achieve this with BAM files. This is little bit weird situation because, I have deleted my BAM files to get more space on my hard drive. So I could just run entire analysis again, but wanted to know if it is possible without redoing whole analysis. Apologies for the confusion. </p>

<coverage><star><stringtie>
Extract mapping coverage from GTF files
# Extract mapping coverage from GTF files

(Asked by: username_0 on 2019-07-26)

I am doing paired end RNA-seq analysis. I used STAR mapper and then StringTie for getting quantification of my data. After successfully running StringTie, I got `.gtf` files which will give me information about genes, their coverage along with TPM and FPKM values. It also produced some more `.ctab` files.

I want to know how what percentage of my reads mapped to reference genome. I [know](https://www.biostars.org/p/5165/) this can be done with BAM or BED files produced after STAR alignment. However, I want to know if this can be done with output files generated by StringTie?

I just want to clarify my question after reading comments and answers I am getting. I want to know if this can be done with `.gtf` files of StringTie. As I mentioned before, I already know how to achieve this with BAM files. This is little bit weird situation because, I have deleted my BAM files to get more space on my hard drive. So I could just run entire analysis again, but wanted to know if it is possible without redoing whole analysis. Apologies for the confusion.

**Tags:** coverage, star, stringtie

---

## 2 answers

### Answer by username_1 on 2019-07-26. Score: 1

So consider this, you know how many reads map to each of your genes (1). Does that tell you anything about (2) the number of reads that mapped against non-gene regions (3) the number of reads that did not map against the genome at all? 
If you only use the gtf files, you know the number of (1) but not of (2) and (3). To me it sounds like you would want to do something as described in this post.
What it boils down to is:
Finding out how many (unique) reads are mapped, counting pairs once
samtools view -F 0x4 foo.sorted.bam | cut -f 1 | sort | uniq | wc -l

Counting how many total reads you have. Since you have paired-end data the number of forward reads suffice:
cat forward_reads.fastq | grep '@' | wc -l

The percentage is then simply mapped_reads/total_reads

> **Comments:**
> **username_1**: @terdon sorry about that, I updated my answer  
> **username_2**: Perfect! Thank you and welcome aboard!  

---

### Answer by username_3 on 2019-07-26. Score: 0

> I want to know how what percentage of my reads mapped to reference
> genome.

And the Log.final.out file from STAR doesn't tell you that?


---

