I have a bam file that is paired ended.
I'm told our pipeline only uses single-end (R1 only). How could I pull only the R1 reads from the bam?
I have a bam file that is paired ended.
I'm told our pipeline only uses single-end (R1 only). How could I pull only the R1 reads from the bam?
You seem unsure on which processing was applied to your original data. You know, you can view the commands used by looking at the BAM [SAM] header:
samtools view -H myalignment.bam ;
The last command used will appear at the bottom of the header (or should appear, at least). Please share here, if you wish.
Otherwise, there are many commands available to convert a BAM to FASTQ. Please see:
With these commands, one can control output of R1 and R2. In your case, we seem to not have 100% certainty about which was aligned, though. This will be revealed by observing the header, as mentioned above.
Kevin
For the sake of completeness, with my Genozip software you could:
genozip mydata.bam
genocat mydata.bam.genozip --FLAG +0x40 --output mydata-R1.bam
As a side benefit, since Genozip is a highly compressed format, your .bam.genozip files will be be 2x-5x times smaller that .bam.
Documentation: https://genozip.com
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Hi Kevin,
The last command is below:
Could I use the following to separate into R1 and R2? I need to stay in bam format if possible.
It looks like the reads that were aligned are:
I trust that you know to what these relate? Are these paired or just 2 single-end files? Based on the STAR command, it can inferred that they are paired:
[source: https://github.com/alexdobin/STAR/blob/master/doc/STARmanual.pdf]
Why not get 100% clarification from the group that did the work? - if they cannot tell you with 100% clarity what they did, then, perhaps, they should not be doing this type of work.
SAM flags 64 and 128? - sure, if that's what you need, but there are other flags that can indicate read pairing, and other commands, like those to whose web-pages I linked (above).