Samtools(CentOS Linux)安装及常用命令详解
序列比对(将测序reads与已知序列信息的基因或基因组进行比对)是高通量测序数据分析中最重要的一环,无论是转录组还是重测序都是基于比对结果来进行后续各项分析的,比对结果格式比较常见的是sam和bam文件,例如转录组Tophat分析软件输出的比对结果为.bam文件,而重测序中BWA、bowtie等比对软件则主要输出为.sam文件。
samtools是一个用于操作sam和bam文件的工具软件,能够对比对文件进行二进制查看、格式转换、排序及合并等,结合sam格式中的flag、tag等信息,还可以完成比对结果的统计汇总,是处理sam和bam文件不可或缺的神器!
1.下载安装包
http://www.htslib.org/download/
2. 安装依赖
yum install bzip2-devel ncurses-libs ncurses-devel xz-devel zlib-devel
3.编译安装
tar xvf samtools-1.9.tar.bz2cd samtools-1.9./configure --prefix=/opt/samtools1.9makemake install
4.配置环境变量
gedit ~/.bashrc#Samtools1.9export PATH=/opt/samtools1.9/bin:$PATHsource ~/.bashrc
5.运行:samtools

samtools常用命令详解
1. view
view命令的主要功能是:将sam文件转换成bam文件;然后对bam文件进行各种操作,比如数据的排序(不属于本命令的功能)和提取(这些操作是对bam文件进行的,因而当输入为sam文件的时候,不能进行该操作);最后将排序或提取得到的数据输出为bam或sam(默认的)格式。
bam文件优点:bam文件为二进制文件,占用的磁盘空间比sam文本文件小;利用bam二进制文件的运算速度快。
view命令中,对sam文件头部的输入(-t或-T)和输出(-h)是单独的一些参数来控制的。
Usage: samtools view [options] <in.bam>|<in.sam> [region1 [...]]默认情况下不加 region,则是输出所有的 region.Options: -b output BAM默认下输出是 SAM 格式文件,该参数设置输出 BAM 格式-h print header for the SAM output默认下输出的 sam 格式文件不带 header,该参数设定输出sam文件时带 header 信息-H print header only (no alignments)-S input is SAM默认下输入是 BAM 文件,若是输入是 SAM 文件,则最好加该参数,否则有时候会报错。-u uncompressed BAM output (force -b)该参数的使用需要有-b参数,能节约时间,但是需要更多磁盘空间。-c Instead of printing the alignments, only count them and print thetotal number. All filter options, such as ‘-f’, ‘-F’ and ‘-q’ ,are taken into account.-1 fast compression (force -b)-x output FLAG in HEX (samtools-C specific)-X output FLAG in string (samtools-C specific)-c print only the count of matching records-L FILE output alignments overlapping the input BED FILE [null]-t FILE list of reference names and lengths (force -S) [null]使用一个list文件来作为header的输入-T FILE reference sequence file (force -S) [null]使用序列fasta文件作为header的输入-o FILE output file name [stdout]-R FILE list of read groups to be outputted [null]-f INT required flag, 0 for unset [0]-F INT filtering flag, 0 for unset [0]Skip alignments with bits present in INT [0]数字4代表该序列没有比对到参考序列上数字8代表该序列的mate序列没有比对到参考序列上-q INT minimum mapping quality [0]-l STR only output reads in library STR [null]-r STR only output reads in read group STR [null]-s FLOAT fraction of templates to subsample; integer part as seed [-1]-? longer help
更多内容阅读原文~
文章来源: drugai.blog.csdn.net,作者:DrugAI,版权归原作者所有,如需转载,请联系作者。
原文链接:drugai.blog.csdn.net/article/details/105683699
- 点赞
- 收藏
- 关注作者
评论(0)