_images/UnivLogo_Stack_2C_Dark.png

Counting mapped reads

To get the number of reads mapped to a reference sequences (in this case, predicted tomato cDNA sequences), we can use Samtools. Bowtie2 output is in sam format and first, we need to convert the output files into sorted bam files.

  1. Type Samtools in app finding window.
_images/samtools_1.png
  1. Select “SAM to sorted BAM”
_images/samtools_2.png
  1. Select Bowtie2 output files (SAM format).
_images/samtools_3.png

4. Above will create sorted bam file. You will need to use this as the input for the Samtools Flagstat, which will count the number of mapped reads.

_images/samtools_4.png

_images/samtools_5.png

** You can get the flagstat for all six files from following link.** | https://github.com/ajwije/2017_spring_Bioinfo_class/blob/master/Files/flagstat.txt

I have used the following bash command to count mapped reads in case you are interested in it doing programmatically.

# navigate to where your sam files are and execute the following commands.

for i in *.sam

do
#extract the file name without extension and print it to the screen


echo ${i%.sam}

#covert sam to sorted bam
samtools view -bS $i | samtools sort - -o ${i%.sam}_sorted.bam

#getting flagstat and write it an output file for each bam file.
samtools flagstat ${fname%.sam}_sorted.bam >> flagstat.txt

done