1. Convert to sam from bam
samtools view -h ./tophat_out/accepted_hits.bam > ./tophat_out/accepted_hits.sam |
bamファイルは機械語で書かれていて,人間には理解できません。まずは,samtoolsでbamファイルをsamファイルに変換します。
2. Filtering
awk '$5>40{print}' ./tophat_out/accepted_hits.sam > ./tophat_out/accepted_hits_uniq.sam |
ここでは,mappingのqualityが低いreadを取り除きます。例えば,あるreadが複数個所のリファレンスにmapされるなどするとqualityが低くなります。この場合はmappingのqualityが40以上(Max:
50)のreadだけ抽出します。
3. Convert to sam from bed
perl sam2bed.pl ./tophat_out/accepted_hits_uniq.sam ./tophat_out/accepted_hits_uniq.bed |
次に使うintersecBedのために,samファイルをsam2bed.plを使ってbedファイルに変換します。
sam2bed.pl: http://bioinfo.au.tsinghua.edu.cn/member/xwang/share/sam2bed.pl
4. Count
intersectBed -a annotated_gene_regions.gff -b ./tophat_out/accepted_hits_uniq.bed
-c > ./tophat_out/accepted_hits_uniq.count |
bedetoolsの中にあるintersectBedを使って,リファレンス配列の遺伝子領域上にあるリードをカウントします。
samtoolsの詳細
bedtoolsの詳細