美文网首页rna_seq
SAM/BAM文件操作-samtools

SAM/BAM文件操作-samtools

作者: 梁兄_小白 | 来源:发表于2018-08-28 21:52 被阅读0次

1.several tool sets have been created to manipulate SAM/BAM files:

samtools , bamtools , picard  

2.how can I select from or filter data from BAM files?

2.1  clarify some wording:

 selecting means to keep alignments that match a condition

filter means to remove alignments that match a condition

-f   (flag) includes only alignments where the bits match the bits in the flag

-F  (flag) includes only alignments where the bits do not match the bits in the flag

2.2 recall what flag 4 means and how to use it :

samtools flags 4   #表示unmap reads

samtools view -f 4 file.bam | head   # select and view the unmapped reads

samtools view -f 4 file.bam | wc -l #count the unmapped reads

samtools view -c -f 4 file.bam  # count the unmapped reads

samtools view -c  -F 4 file.bam # count the mapped reads

samtools view -b -F 4 file.bam > file_mapped_reads # separate unmapped reads

samtools view -c -f 16 file.bam # reads that align to reverse strand

samtools view -c -F 4 -f 16 file.bam # reads that align to reverse stand and not unmapped.

samtools view -c -F 20 file.bam # reads that align to forwards strand and are not unmapped

samtools view -b -f 4 file.bam > file_mapped_reads # separate mapped reads

2.3 Get an overview of the alignments in a BAM file

samtools flagstat file.bam # produces a report on flags

samtools idxstats file.bam # produces a report on how many reads align to each chromosome

bamtools stats -in file.bam # produces a report on flags

2.4 how do I filter on mapping quality?

The mapping quality column contains a number that the aligner fillls in . This number is rarely an objection quantity , it rather reflects a subjective value designated by the tool developer.

smatools view -c -q 1 file.bam  #select uniquely mapped reads when these were a aligned with BWA

smatools view -c -q 1 -F 4 -F 16 file.bam # mapping quality over 1 and on the forward strand (file.bam by BWA)

2.5 how can I find out the depth of coverage ?

samtools depth file.bam  | head  # compute the depth of coverage, compute the number of reads that overlap each base .

samtools depth -a file.bam | head  # ask for all position and you can verify that it starts at 1

smatools depth file.bam | sort -k 3 -rn | head  # sort by depth 

相关文章

  • samtools软件的使用

    常用samtools的命令: samtools view命令:查看sam,bam文件,进行sam及bam文件的转换...

  • Samtools和Bcftools

    Samtools和Bcftools简介 SAMtools是一个用于操作sam和bam文件的工具合集,包含有许多命令...

  • samtools view 使用小结

    整理高通量测序中使用的软件。 samtools是常用的对sam/bam文件操作的工具,其中samtools vie...

  • SAM/BAM文件操作-samtools

    1.several tool sets have been created to manipulate SAM/B...

  • samtools问题

    当用samtools将bowtie2比对的sam文件转化为bam文件时遇到问题: samtools: error ...

  • GWAS走起~(4 samtools)

    Samtools的功能还是很强大的,samtools是一个用于操作sam和bam文件的工具合集。能够实现二进制查看...

  • SAMtools——bam文件排序

    bam文件在进行后续分析前,需要进行排序,samtools的安装见文章:sam文件转换为bam文件——SAMtoo...

  • Samtools使用大全

    一、简介 Samtools是一个用于操作sam和bam格式文件的应用程序集合,具有众多的功能。 它从SAM(序列比...

  • WES2Neoantigen Pipeline

    Part 3 Samtools view view命令的主要功能是:将sam文件转换成bam文件;然后对bam文件...

  • RNAseq转录组分析流程:fastp+hisat2+samto

    使用工具 fastp(质控), hisat2(比对), samtools(sam文件转bam文件), featur...

网友评论

    本文标题:SAM/BAM文件操作-samtools

    本文链接:https://www.haomeiwen.com/subject/onxcwftx.html