Answers.Body: <p>If you want to remove rRNA, use tools that are made for this. We usually go for <a href="https://github.com/biocore/sortmerna/wiki/2.-User-manual-(todo)#Filtering_pairedend_reads" rel="nofollow noreferrer">SortMeRNA</a>, which can do exactly what you describe your goal is, <em>i.e.</em> go from FASTQ to FASTQ, splitting your reads into rRNA and non-rRNA.</p>
  <p>In our experience, it is very accurate, if a bit slow at times.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-08T19:24:01.217Z
Answers.LastActivityDate: 2020-11-08T19:24:01.217Z
Answers.UserDisplayName: Bastian Schiffthaler
Answers.Body: <ol>
  <li><p>Bam flags will indicate which reads have both pairs not mapping.</p>
  </li>
  <li><p>Nothing mapped.  You need to figure out why, and you can look at just about anything out figure that out.</p>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T18:31:43.720Z
Answers.Text: Yes, thanks for mentioning SAM/BAM flags. I thought I mentioned them, but it looks like I only implied them. (Now updated to mention them)
Answers.UserDisplayName: Christopher Bottoms
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T18:34:04.797Z
Answers.Text: I'm trying to filter out rRNA reads. So about 2/3 of the read pairs had at least one read align to my rRNA reference. However, I want the remaining 1/3 of the read pairs for which neither read aligned at all.
Answers.UserDisplayName: Christopher Bottoms
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T21:15:00.580Z
Answers.Text: You are trying to filter out rRNA read by aligning them to a reference of rRNAs?  This seems ill-advised.  Filter out rRNA after aligning to your whole genome.
Answers.UserDisplayName: swbarnes2
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T17:42:58.597Z
Answers.LastActivityDate: 2020-10-09T17:42:58.597Z
Answers.UserDisplayName: swbarnes2
Body: <p>As I understand it, bowtie2 can easily be used to split reads into one of two groups:</p>
  <ul>
  <li>reads for which both of a pair align well to a reference (using e.g. <code>--al-conc-gz</code>)</li>
  <li>reads for which one or both of a pair do not align a reference (using e.g <code>--un-conc-gz</code>)</li>
  </ul>
  <p>But I really want to split this second group into reads for which neither of a pair align to the reference.</p>
  <p>bowtie2's report give a nice breakdown, but it's not clear to me how to extract specific members of these groups:</p>
  <pre><code>1000000 reads; of these:
    1000000 (100.00%) were paired; of these:
      958118 (95.81%) aligned concordantly 0 times
      1329 (0.13%) aligned concordantly exactly 1 time
      40553 (4.06%) aligned concordantly &gt;1 times
      ----
      958118 pairs aligned concordantly 0 times; of these:
        179 (0.02%) aligned discordantly 1 time
      ----
      957939 pairs aligned 0 times concordantly or discordantly; of these:
        1915878 mates make up the pairs; of these:
          711518 (37.14%) aligned 0 times
          32134 (1.68%) aligned exactly 1 time
          1172226 (61.18%) aligned &gt;1 times
  64.42% overall alignment rate
  </code></pre>
  <p>In this case, I really want those that didn't align at all (i.e. the 35.58% not included in the <code>64.42% overall alignment rate</code> which is the same as the <code>37.14%</code> of the pairs that did not align concordantly).</p>
  <p>Since in my case the reference is rRNA and many of those sequences are shorter than my reads, I'm not surprised that so there are so few concordant reads. I'm really interested in reads that aren't concordant and aren't discordant discordant either.</p>
  <p>So, if I'm sticking to bowtie2, it looks like my only option is to take the resulting SAM/BAM file and filter what I want based on flags and then convert that back into FASTQ files.</p>
  <p>Is there another option that I'm missing? It seems that the remaining output options relate to unpaired reads or SAM files.</p>
  <p>I'm looking into other aligners now...</p>
  <p>My goal is to go from FASTQ files to FASTQ files without extra steps, but I can go through a SAM/BAM file stage if I need to and even build a solution around that if needed.</p>
  
Tags: <phylogenetics><bowtie2>
Title: Filtering out reads from a reference (e.g. rRNA) using bowtie2
ThreadText: # Filtering out reads from a reference (e.g. rRNA) using bowtie2
  
  (Asked by: username_0 on 2020-10-09)
  
  As I understand it, bowtie2 can easily be used to split reads into one of two groups:
  
  * reads for which both of a pair align well to a reference (using e.g. `--al-conc-gz`)
  * reads for which one or both of a pair do not align a reference (using e.g `--un-conc-gz`)
  
  But I really want to split this second group into reads for which neither of a pair align to the reference.
  
  bowtie2's report give a nice breakdown, but it's not clear to me how to extract specific members of these groups:
  
  ```
  1000000 reads; of these:
    1000000 (100.00%) were paired; of these:
      958118 (95.81%) aligned concordantly 0 times
      1329 (0.13%) aligned concordantly exactly 1 time
      40553 (4.06%) aligned concordantly >1 times
      ----
      958118 pairs aligned concordantly 0 times; of these:
        179 (0.02%) aligned discordantly 1 time
      ----
      957939 pairs aligned 0 times concordantly or discordantly; of these:
        1915878 mates make up the pairs; of these:
          711518 (37.14%) aligned 0 times
          32134 (1.68%) aligned exactly 1 time
          1172226 (61.18%) aligned >1 times
  64.42% overall alignment rate
  
  ```
  
  In this case, I really want those that didn't align at all (i.e. the 35.58% not included in the `64.42% overall alignment rate` which is the same as the `37.14%` of the pairs that did not align concordantly).
  
  Since in my case the reference is rRNA and many of those sequences are shorter than my reads, I'm not surprised that so there are so few concordant reads. I'm really interested in reads that aren't concordant and aren't discordant discordant either.
  
  So, if I'm sticking to bowtie2, it looks like my only option is to take the resulting SAM/BAM file and filter what I want based on flags and then convert that back into FASTQ files.
  
  Is there another option that I'm missing? It seems that the remaining output options relate to unpaired reads or SAM files.
  
  I'm looking into other aligners now...
  
  My goal is to go from FASTQ files to FASTQ files without extra steps, but I can go through a SAM/BAM file stage if I need to and even build a solution around that if needed.
  
  **Tags:** phylogenetics, bowtie2
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-11-08. Score: 2
  
  If you want to remove rRNA, use tools that are made for this. We usually go for [SortMeRNA](https://github.com/biocore/sortmerna/wiki/2.-User-manual-(todo)#Filtering_pairedend_reads), which can do exactly what you describe your goal is, *i.e.* go from FASTQ to FASTQ, splitting your reads into rRNA and non-rRNA.
  
  In our experience, it is very accurate, if a bit slow at times.
  
  
  ---
  
  ### Answer by username_2 on 2020-10-09. Score: 0
  
  1. Bam flags will indicate which reads have both pairs not mapping.
  2. Nothing mapped. You need to figure out why, and you can look at just about anything out figure that out.
  
  > **Comments:**
  > **username_0**: Yes, thanks for mentioning SAM/BAM flags. I thought I mentioned them, but it looks like I only implied them. (Now updated to mention them)  
  > **username_0**: I'm trying to filter out rRNA reads. So about 2/3 of the read pairs had at least one read align to my rRNA reference. However, I want the remaining 1/3 of the read pairs for which neither read aligned at all.  
  > **username_2**: You are trying to filter out rRNA read by aligning them to a reference of rRNAs?  This seems ill-advised.  Filter out rRNA after aligning to your whole genome.  
  
  ---
  
  