美文网首页
samtools软件的使用

samtools软件的使用

作者: javen_spring | 来源:发表于2020-05-29 19:05 被阅读0次

    常用samtools的命令:

    samtools常用命令
    • samtools view命令:查看sam,bam文件,进行sam及bam文件的转换
    (rna) May5 16:58:12 ~/project/airway/05.mapping
    $ samtools view *.subjunc.bam |less -S   #只显示结果部分
    (rna) May5 16:58:30 ~/project/airway/05.mapping
    $ samtools view -H  *.subjunc.bam |less -S  #只显示结果的表头部分
    (rna) May5 16:58:44 ~/project/airway/05.mapping
    $ samtools view -h  *.subjunc.bam |less -S  #结果和表头部分都显示
    (rna) May5 17:23:53 ~/project/airway/05.mapping
    $ samtools view *subjunc.bam | less -S   #查看*subjunc.bam文件(未排序,按照SRR排序)
    (rna) May5 17:24:54 ~/project/airway/05.mapping
    $ samtools view *subjunc.sort.bam | less -S  #查看*subjunc.sort.bam文件(已按照染色体文字排序,前面为匹配reads,最后为未匹配reads)
    
    • samtools sort 命令
    samtools sort -@ 1 -o SRR1039510.hisat2.sort.bam SRR1039510.hisat2.sam  #对SRR1039510.hisat2.sam文件进行排序,线程数(参数-@ )1,输出SRR1039510.hisat2.sort.bam 文件(进行排序后转换为bam文件)
    
    • samtools index 需要将bam文件排序(上一步),添加索引,才能载入IGV进行可视化
    (rna) May5 17:37:46 ~/project/airway/05.mapping
    $ for i in $(ls *.sort.bam)
    > do
    >         i=${i/.sort.bam/}
    >         samtools index ${i}.sort.bam
    > done
    (rna) May5 17:38:50 ~/project/airway/05.mapping
    $ ls
    SRR1039510_1_val_1.fq.gz    SRR1039510.hisat2.sort.bam.bai       SRR1039510.subjunc.log           SRR1039511_2_val_2.fq.gz
    SRR1039510_2_val_2.fq.gz    SRR1039510.subjunc.bam               SRR1039510.subjunc.sort.bam      SRR1039512_1_val_1.fq.gz
    SRR1039510.hisat2.sam       SRR1039510.subjunc.bam.indel.vcf     SRR1039510.subjunc.sort.bam.bai  SRR1039512_2_val_2.fq.gz
    SRR1039510.hisat2.sort.bam  SRR1039510.subjunc.bam.junction.bed  SRR1039511_1_val_1.fq.gz
    #将*sort.bam文件及*sort.bam.bai文件下载到本地,使用igv进行查看
    
    • samtools tview 简易版基因组浏览器,直接可以在命令行下查看基因位置(此命令的输入文件也是要进行排序和建立索引的)
    (rna) May5 17:45:21 ~/project/airway/05.mapping
    $ hg38=/teach/database/reference/hg38.fa   #建立索引,即目录
    (rna) May5 17:47:48 ~/project/airway/05.mapping
    $ samtools tview SRR1039510.hisat2.sort.bam ${hg38}  #samtools tview命令进入交互式的界面,输入?查看帮助,输入g可输入染色体编号及位置可查看reads比对的情况
    
    • samtools flagstat # 比对结果的统计
    (rna) May5 18:13:39 ~/project/airway/05.mapping
    $ samtools flagstat  #打开帮助文档
    Usage: samtools flagstat [options] <in.bam>
          --input-fmt-option OPT[=VAL]
                   Specify a single input file format option in the form
                   of OPTION or OPTION=VALUE
      -@, --threads INT
                   Number of additional threads to use [0]
    (rna) May5 18:15:48 ~/project/airway/05.mapping
    $ samtools flagstat -@ 1 *.hisat2.sort.bam  #根据帮助文档设置参数及输入文件
    54530 + 0 in total (QC-passed reads + QC-failed reads)  #结果
    5634 + 0 secondary
    0 + 0 supplementary
    0 + 0 duplicates
    53767 + 0 mapped (98.60% : N/A)
    48896 + 0 paired in sequencing
    24448 + 0 read1
    24448 + 0 read2
    47108 + 0 properly paired (96.34% : N/A)
    47564 + 0 with itself and mate mapped
    569 + 0 singletons (1.16% : N/A)
    200 + 0 with mate mapped to a different chr
    145 + 0 with mate mapped to a different chr (mapQ>=5)
    

    相关文章

      网友评论

          本文标题:samtools软件的使用

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