I hope to retain unaligned read for further circRNA identification, so I used the following code to generate unaligned reads using bowtie2.
bowtie2 -x ~/database/genome/UCSC/mm10/index/bowtie2/mm10\ -U ~/project/m6A/Mapping/bowtie2/sample1.fq.gz -p 8\ -S ~/project/m6A/Mapping/bowtie2/sample1.sam\ 2>~/project/m6A/Mapping/bowtie2/sample1.log\ && samtools view -hbuS ~/project/m6A/Mapping/bowtie2/sample1.sam | samtools view -hf 4 - | samtools view -Sb - | samtools sort -@ 6 -o ~/project/m6A/Mapping/bowtie2/sample1.unmapped.bam -
I don't know whether the sample1.unmapped.sam only contained the unaligned reads.
Thanks.
Please see: http://bowtie-bio.sourceforge.net/bowtie2/manual.shtml
...and in there the "output options" section. Explains what you need.
I used "--un ~/project/m6A/Mapping/bowtie2/Sample1.unmapped.sam"
I don't know wether this code generated the the unaligned reads