bwa、bowtie2、tophat、hisat2 比对软件学习中的笔记整理

news/2024/7/8 3:05:47 标签: bwa, bowtie2, hisat2, tophat

 对常用的比对软件学习进行用法整理记录。记录的内容相对简单,详细说明及用法还得参考软件使用说明书

bwabowtie2tophat、hisat

bwa

bwa(Burrows-Wheeler Aligner)
bwa文档说明
http://bio-bwa.sourceforge.net/bwa.shtml

BWA用于将低差异的序列映射到一个大的参考基因组,如人类基因组。由BWA-backtrack、BWA-SW和BWA-MEM三种算法组成。第一个算法设计用于Illumina序列读取100bp,其余两个用于更长序列,读取范围从70bp到1Mbp。BWA-MEM和BWA-SW具有类似的特性,比如长读支持和分割对齐,但是最新的BWA-MEM通常被推荐用于高质量查询,因为它更快、更准确。对于70-100bp的Illumina读长数据,BWA-MEM也比BWA-backtrack具有更好的性能。

bwa有多种算法,不管是哪种算法,都需要先构建参考基因组的index索引。不同比对算法调用不同的子命令:
BWA-backtrack:aln/samse/sampe;
BWA-SW:bwasw;
BWA-MEM:mem

# 软件下载
git clone https://github.com/lh3/bwa.git
cd bwa; 
make
用法:
# bwa构建索引
用法:
bwa index [options] <in.fasta>
options
    -a STR    BWT construction algorithm: bwtsw, is or rb2 [auto]
  -p STR    prefix of the index [same as fasta name] # 构建的参考基因组index带有和fasta文件同名的前缀
  -b INT    block size for the bwtsw algorithm (effective with -a bwtsw) [10000000]
  -6        index files named as <in.fasta>.64.* instead of <in.fasta>.*
# 示例
bwa index rRNA.homo_sapiens.fa

# bwa-mem  reads 测序读长大于70bp或者组装后的contigs碱基比对到相近的参考基因组
用法:
    bwa mem [options] <idxbase> <in1.fq> [in2.fq]
    bwa mem [-aCHMpP] [-t nThreads] [-k minSeedLen] [-w bandWidth] [-d zDropoff] [-r seedSplitRatio] [-c maxOcc] [-A matchScore] [-B mmPenalty] [-O gapOpenPen] [-E gapExtPen] [-L clipPen] [-U unpairPen] [-R RGline] [-v verboseLevel] db.prefix reads.fq [mates.fq]
options
Algorithm options:
       -t INT        number of threads [1]  # 指定线程数
       -k INT        minimum seed length [19]  # 最小比对长度
       -w INT        band width for banded alignment [100]  #
       -d INT        off-diagonal X-dropoff [100]
       -r FLOAT      look for internal seeds inside a seed longer than {-k} * FLOAT [1.5]
       -y INT        seed occurrence for the 3rd round seeding [20]
       -c INT        skip seeds with more than INT occurrences [500]
       -D FLOAT      drop chains shorter than FLOAT fraction of the longest overlapping chain [0.50]
       -W INT        discard a chain if seeded bases shorter than INT [0]
       -m INT        perform at most INT rounds of mate rescues for each read [50]
       -S            skip mate rescue
       -P            skip pairing; mate rescue performed unless -S also in use
Scoring options:
       -A INT        score for a sequence match, which scales options -TdBOELU unless overridden [1]
       -B INT        penalty for a mismatch [4]
       -O INT[,INT]  gap open penalties for deletions and insertions [6,6]
       -E INT[,INT]  gap extension penalty; a gap of size k cost '{-O} + {-E}*k' [1,1]
       -L INT[,INT]  penalty for 5'- and 3'-end clipping [5,5]
       -U INT        penalty for an unpaired read pair [17]
       -x STR        read type. Setting -x changes multiple parameters unless overridden [null]
                     pacbio: -k17 -W40 -r10 -A1 -B1 -O1 -E1 -L0  (PacBio reads to ref)
                     ont2d: -k14 -W20 -r10 -A1 -B1 -O1 -E1 -L0  (Oxford Nanopore 2D-reads to ref)
                     intractg: -B9 -O16 -L5  (intra-species contigs to ref)
Input/output options:
       -p            smart pairing (ignoring in2.fq)
       -R STR        read group header line such as '@RG\tID:foo\tSM:bar' [null]
       -H STR/FILE   insert STR to header if it starts with @; or insert lines in FILE [null]
       -o FILE       sam file to output results to [stdout]
       -j            treat ALT contigs as part of the primary assembly (i.e. ignore <idxbase>.alt file)
       -5            for split alignment, take the alignment with the smallest coordinate as primary
       -q            don't modify mapQ of supplementary alignments
       -K INT        process INT input bases in each batch regardless of nThreads (for reproducibility) []
       -v INT        verbosity level: 1=error, 2=warning, 3=message, 4+=debugging [3]
       -T INT        minimum score to output [30]
       -h INT[,INT]  if there are <INT hits with score >80% of the max score, output all in XA [5,200]
       -a            output all alignments for SE or unpaired PE
       -C            append FASTA/FASTQ comment to SAM output
       -V            output the reference FASTA header in the XR tag
       -Y            use soft clipping for supplementary alignments
       -M            mark shorter split hits as secondary(可用于兼容picard)
       -I FLOAT[,FLOAT[,INT[,INT]]]
                     specify the mean, standard deviation (10% of the mean if absent), max
                     (4 sigma from the mean if absent) and min of the insert size distribution.
                     FR orientation only. [inferred]

# 二代测序平台
bwa mem ref.fa reads.fq > aln-se.sam  
bwa mem ref.fa read1.fq read2.fq > aln-pe.sam
# 示例
bwa mem -t 10 -M ref.fa read1.fq read2.fq 1> aln.sam 2>>bwa.log



# pacbio/ont
bwa mem -x pacbio ref.fa reads.fq > aln.sam
bwa mem -x ont2d ref.fa reads.fq > aln.sam

# bwa-backtrack  适用于测序读长70bp左右
# 单端测序序列比对
bwa aln ref.fa short_read.fq > aln_sa.sai
bwa samse ref.fa aln_sa.sai short_read.fq > aln-se.sam   
# 双端测序序列比对
bwa aln ref.fa read1.fq > aln_sa1.sai
bwa aln ref.fa read2.fq > aln_sa2.sai
bwa sampe ref.fa aln_sa1.sai aln_sa2.sai read1.fq read2.fq > aln-pe.sam   

用法:
bwa aln [-n maxDiff] [-o maxGapO] [-e maxGapE] [-d nDelTail] [-i nIndelEnd] [-k maxSeedDiff] [-l seedLen] [-t nThrds] [-cRN] [-M misMsc] [-O gapOsc] [-E gapEsc] [-q trimQual] <in.db.fasta> <in.query.fq> > <out.sai>

bwa samse [-n maxOcc] <in.db.fasta> <in.sai> <in.fq> > <out.sam>
bwa sampe [-a maxInsSize] [-o maxOcc] [-n maxHitPaired] [-N maxHitDis] [-P] <in.db.fasta> <in1.sai> <in2.sai> <in1.fq> <in2.fq> > <out.sam>
# bwa-sw
bwa bwasw ref.fa long_read.fq > aln.sam
bwa bwasw [-a matchScore] [-b mmPen] [-q gapOpenPen] [-r gapExtPen] [-t nThreads] [-w bandWidth] [-T thres] [-s hspIntv] [-z zBest] [-N nHspRev] [-c thresCoef] <in.db.fasta> <in.fq> [mate.fq] > aln.sam
比对序列是fq文件。当双端fq文件存在时,进行双端比对。双端模式只适用于Illumina短序列文库。在双端模式下,BWA-SW仍会输出拆分比对但所有的都被标记没有正确的配对;若有多个比对位置,配对位置将不会被写入

bowtie2

# bowtie2安装
1.conda直接安装
conda install bowtie2
2.git 安装
git clone https://github.com/BenLangmead/bowtie2.git

# bowtie2文档说明
http://bowtie-bio.sourceforge.net/bowtie2/manual.shtml#bowtie2-options-solexa-quals

bowtie2参考基因组索引构建
bowtie2-build ref.fa ref
bowtie2-build可以构建各种大小参考基因组的index.基因组大小4G,bowtie2构建一个"small"的索引。当基因组比较长,bowtie2构建一个“large”的索引。小索引被保存在扩展名.bt2的文件中,大索引保存在bt2l的扩展名的文件中。

用法:
bowtie2 [options]* -x <bt2-idx> {-1 <m1> -2 <m2> | -U <r> | --interleaved <i> | --sra-acc <acc> | b <bam>} -S [<sam>]

options
-f  Reads (specified with <m1>, <m2>, <s>) are FASTA files. FASTA files usually have extension .fa, .fasta, .mfa, .fna or similar. FASTA files do not have a way of specifying quality values, so when -f is set, the result is as if --ignore-quals is also set.
--end-to-end   要求从一端到另一端的全部读对齐,而不需要从两端对字符进行任何修整

--maxins 有效双端对齐的最大片段长度


FLAG值
1    The read is one of a pair
2    The alignment is one end of a proper paired-end alignment
4    The read has no reported alignments
8    The read is one of a pair and has no reported alignments
16    The alignment is to the reverse reference strand
32    The other mate in the paired-end alignment is aligned to the reverse reference strand
64    The read is mate 1 in a pair
128    The read is mate 2 in a pair
Thus, an unpaired read that aligns to the reverse reference strand will have flag 16. A paired-end read that aligns and is the first mate in the pair will have flag 83 (= 64 + 16 + 2 + 1).

bowtie2-inspect # index文件名查找
用法 
bowtie2-inspect [options]* <bt2_base>
Options:
  --large-index      force inspection of the 'large' index, even if a
                     'small' one is present.
  -a/--across <int>  Number of characters across in FASTA output (default: 60)
  -n/--names         Print reference sequence names only
  -s/--summary       Print summary incl. ref names, lengths, index properties
  -e/--bt2-ref      Reconstruct reference from .bt2 (slow, preserves colors)
# 示例
/opt/biotools/bowtie2-2.2.9/bowtie2-inspect -a 80 rRNA.homo_sapiens.fa >> rRNA.homo_sapiens.fa

tophat

# 软件下载
# boost 下载
wget https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.gz
tar -zxvf boost_1_71_0.tar.gz
./bootstrap.sh
/bjam --prefix=<YOUR_BOOST_INSTALL_DIRECTORY> link=static runtime-link=static stage install # 自定义安装路径 默认安装路径时/usr/local
./bz  # 安装

# tophat2 下载安装
# source code
wget -c http://ccb.jhu.edu/software/tophat/downloads/tophat-2.1.1.tar.gz
# binary
wget -c http://ccb.jhu.edu/software/tophat/downloads/tophat-2.1.1.Linux_x86_64.tar.gz
tar zxvf tophat-2.1.1.Linux_x86_64.tar.gz
cd tophat-2.1.1/
./configure --prefix=<install_prefix> --with-boost=<boost_install_prefix> --with-bam=<samtools_install_prefix>
make
make install


hisat2

HISAT2是一个快速和敏感的比对程序,用于将下一代测序读序列(包括DNA和RNA)映射到人类基因组群(以及单个参考基因组)。
# hisat2 下载
# wget ftp://ftp.ccb.jhu.edu/pub/infphilo/hisat2/downloads/hisat2-2.1.0-Linux_x86_64.zip
wget -c http://ccb.jhu.edu/software/hisat2/downloads/hisat2-2.0.0-beta-source.zip
unzip hisat2-2.0.0-beta-source.zip
cd hisat2-2.0.0
make
# 添加到环境中
cp /install/path/hisat2* ~/bin/

用法:
hisat2 [options]* -x <hisat2-idx> {-1 <m1> -2 <m2> | -U <r> | --sra-acc <SRA accession number>} [-S <hit>]

 


http://www.niftyadmin.cn/n/1721986.html

相关文章

fastp使用

fastpfastp 下载及安装# fastp只依赖于zlib(如果在编译fastp过程中出现“undefined reference to gzbuffer”错误&#xff0c;可更新zlib进行处理)#安装方式一&#xff1a; 下载编译好二进制&#xff08;仅适用于linux系统&#xff09;wget http://opengene.org/fastp/fastpchm…

python进行信息匹配

最近需要根据样本编号比对信息&#xff0c;故写了脚本进行处理&#xff0c;满足日常的匹配需求&#xff0c;初步编写的脚本如下&#xff1a; # —*—coding:utf-8_*_ # date: 2020-05-04import xlrd import csv import argparse,os,io def pre_prepration(cur_path,sample_lis…

数据可视化--表格融合练习

数据可视化--表格融合练习pd.merge()函数说明代码演练参考书籍pd.merge()函数说明 使用共有列作为两个数据框数据融合的依据&#xff0c;主要使用pd.merge()函数&#xff1a; 参数说明&#xff1a; left: 传递左表数据right: 传递右表数据how: 数据融合方式 left:保留左表的数…

练习系列:Python字典:一键对应多值

需求&#xff1a; 遍历文本文件&#xff0c;生成一键对应多值的字典&#xff0c;如下所示&#xff1a; 文本文件内容("\t"分割字符串)&#xff1a; “”" A 1 A 2 A 3 B c B d C 4 C 5 C e “”" 目标生成文件格式&#xff1a; target_dict {“A”:[1,2,3…

从分析结果中根据list提取突变信息

# _*_coding:utf-8_*_ # author: 稻田工作者 # date: 2020-06-13"""根据原始样本对应的突变信息从数据分析文件中提取检出结果&#xff0c;如&#xff1a; 原始样本LC-BR3对应的突变信息如下&#xff1a; NM_000245.2:exon14_intron14:c.3028_302816del17:p.? …

bwa mem 报错处理:[mem_sam_pe] paired reads have different names

背景&#xff1a; 从samtools sort 默认排序后的bam文件中提取fastq序列并对其格式化&#xff0c;对格式化后的fastq文件重新比对到参考基因组&#xff0c;报错如下&#xff1a;”[mem_sam_pe] paired reads have different names: “A00575:297:HWHKYDMXX:1:1331:22372:31814…

python windows环境下批量修改文件的创建时间、访问时间、修改时间

引用&#xff1a;https://blog.csdn.net/dengnihuilaiwpl/article/details/86551720 常见的修改文件时间有两种方式&#xff1a; 方式一&#xff1a;修改访问和修改时间&#xff1b; 使用utime函数 方法二&#xff1a;修改创建时间 使用pywin32file库 以下代码可以实现两种…

pip更新时出错pip install --upgrade pip

pip更新时出错pip install --upgrade pip 今天在配置电脑的时候安装anaconda后&#xff0c;在用pip下载包时&#xff0c;照例pip install --upgrade pip更新pip却出现如下错误 这是一个下载解压工具结果安装包是压缩包的烦恼呀。 看论坛里大家众说纷纭&#xff0c;挨个试了试…