Debian Codegraph @

README.md

raw
1 # abPOA: adaptive banded Partial Order Alignment
2 [![Latest Release](https://img.shields.io/github/release/yangao07/abPOA.svg?label=Release)](https://github.com/yangao07/abPOA/releases/latest)
3 [![Github All Releases](https://img.shields.io/github/downloads/yangao07/abPOA/total.svg?label=Download)](https://github.com/yangao07/abPOA/releases)
4 [![BioConda Install](https://img.shields.io/conda/dn/bioconda/abpoa.svg?style=flag&label=BioConda%20install)](https://anaconda.org/bioconda/abpoa)
5 [![PyPI](https://img.shields.io/pypi/dm/pyabpoa.svg?label=pip%20install)](https://pypi.python.org/pypi/pyabpoa)
6 [![Published in Bioinformatics](https://img.shields.io/badge/Published%20in-Bioinformatics-blue.svg)](https://dx.doi.org/10.1093/bioinformatics/btaa963)
7 [![GitHub Issues](https://img.shields.io/github/issues/yangao07/abPOA.svg?label=Issues)](https://github.com/yangao07/abPOA/issues)
8 [![C/C++ CI](https://github.com/yangao07/abPOA/actions/workflows/linux-CI.yml/badge.svg)](https://github.com/yangao07/abPOA/actions/workflows/linux-CI.yml)
9 [![C/C++ CI](https://github.com/yangao07/abPOA/actions/workflows/macos-CI.yml/badge.svg)](https://github.com/yangao07/abPOA/actions/workflows/macos-CI.yml)
10 [![License](https://img.shields.io/badge/License-MIT-black.svg)](https://github.com/yangao07/abPOA/blob/main/LICENSE)
11
12 ## Updates (v1.5.6)
13 * Allow easy incremental MSA
14 * Add pyproject.toml for pyabpoa
15
16
17 ## Getting started
18 Download the [latest release](https://github.com/yangao07/abPOA/releases):
19 ```
20 wget https://github.com/yangao07/abPOA/releases/download/v1.5.6/abPOA-v1.5.6.tar.gz
21 tar -zxvf abPOA-v1.5.6.tar.gz && cd abPOA-v1.5.6
22 ```
23 Make from source and run with test data:
24 ```
25 # Linux or MacOS with armv8
26 make; ./bin/abpoa ./test_data/seq.fa > cons.fa
27
28 # MacOS with armv7
29 make armv7=1; ./bin/abpoa ./test_data/seq.fa > cons.fa
30 ```
31 Or, install via conda and run with test data:
32 ```
33 conda install -c bioconda abpoa
34 abpoa ./test_data/seq.fa > cons.fa
35 ```
36 ## Table of Contents
37
38 - [abPOA: adaptive banded Partial Order Alignment](#abpoa-adaptive-banded-partial-order-alignment)
39 - [Updates (v1.5.6)](#updates-v156)
40 - [Getting started](#getting-started)
41 - [Table of Contents](#table-of-contents)
42 - [Introduction](#introduction)
43 - [Installation](#installation)
44 - [Installing abPOA via conda/brew](#installing-abpoa-via-condabrew)
45 - [Building abPOA from source files](#building-abpoa-from-source-files)
46 - [Pre-built binary executable file for Linux/Unix or MacOS](#pre-built-binary-executable-file-for-linuxunix-or-macos)
47 - [General usage](#general-usage)
48 - [Generate a consensus sequence](#generate-a-consensus-sequence)
49 - [Generate multiple consensus sequences](#generate-multiple-consensus-sequences)
50 - [Generate row-column multiple sequence alignment in FASTA format](#generate-row-column-multiple-sequence-alignment-in-fasta-format)
51 - [Generate graph information in GFA format](#generate-graph-information-in-gfa-format)
52 - [Align sequence to an existing graph in GFA/MSA format](#align-sequence-to-an-existing-graph-in-gfamsa-format)
53 - [Generate a consensus sequence for amino acid sequences](#generate-a-consensus-sequence-for-amino-acid-sequences)
54 - [Generate a plot of the alignment graph](#generate-a-plot-of-the-alignment-graph)
55 - [Input](#input)
56 - [Output](#output)
57 - [Consensus sequence](#consensus-sequence)
58 - [Row-column multiple sequence alignment](#row-column-multiple-sequence-alignment)
59 - [Full graph information](#full-graph-information)
60 - [Plot of alignment graph](#plot-of-alignment-graph)
61 - [Algorithm description](#algorithm-description)
62 - [Adaptive banding](#adaptive-banding)
63 - [Minimizer-based seeding mode](#minimizer-based-seeding-mode)
64 - [Minimizer-based progressive tree](#minimizer-based-progressive-tree)
65 - [Multiple consensus sequences](#multiple-consensus-sequences)
66 - [For development](#for-development)
67 - [Evaluation datasets](#evaluation-datasets)
68 - [Contact](#contact)
69
70 ## <a name="introduction"></a>Introduction
71 abPOA is an extended version of [Partial Order Alignment (POA](10.1093/bioinformatics/18.3.452))
72 that performs adaptive banded dynamic programming (DP) with an SIMD implementation.
73 abPOA can perform multiple sequence alignment (MSA) on a set of input sequences and
74 generate a consensus sequence by applying the [heaviest bundling algorithm](10.1093/bioinformatics/btg109)
75 to the final alignment graph.
76
77 abPOA can generate high-quality consensus sequences from error-prone long reads and offer
78 significant speed improvement over existing tools.
79
80 abPOA supports three alignment modes (global, local, extension) and flexible scoring schemes that allow linear, affine and convex gap penalties.
81 It right now supports SSE2/SSE4.1/AVX2 vectorization.
82 For `riscv64`, the current portability path uses the existing SIMDE-backed
83 AVX2-style generic build rather than x86 runtime dispatch or a dedicated RVV
84 backend.
85
86 For more information, please refer to our [paper](https://dx.doi.org/10.1093/bioinformatics/btaa963) published in Bioinformatics.
87
88 ## Installation
89
90 ### Installing abPOA via conda/brew
91 On Linux/Unix and macOS, abPOA can be installed:
92 ```
93 conda install -c bioconda abpoa
94 ```
95
96 On macOS:
97 ```
98 brew install abpoa
99 ```
100
101 ### Building abPOA from source files
102 You can also build abPOA from source files.
103 Make sure you have gcc (>=6.4.0) and zlib installed before compiling.
104 It is recommended to download the [latest release](https://github.com/yangao07/abPOA/releases).
105 ```
106 wget https://github.com/yangao07/abPOA/releases/download/v1.5.6/abPOA-v1.5.6.tar.gz
107 tar -zxvf abPOA-v1.5.6.tar.gz
108 cd abPOA-v1.5.6; make
109 ```
110 Or, you can use `git clone` command to download the source code.
111 This gives you the latest version of abPOA, which might be still under development.
112 ```
113 git clone --recursive https://github.com/yangao07/abPOA.git
114 cd abPOA; make
115 ```
116
117 ### Pre-built binary executable file for Linux/Unix or MacOS
118 If you meet any compiling issue, please try the pre-built binary file for linux:
119 ```
120 wget https://github.com/yangao07/abPOA/releases/download/v1.5.6/abPOA-v1.5.6_x64-linux.tar.gz
121 tar -zxvf abPOA-v1.5.6_x64-linux.tar.gz
122 ```
123 or for macos:
124 ```
125 wget https://github.com/yangao07/abPOA/releases/download/v1.5.6/abPOA-v1.5.6_arm64-macos.tar.gz
126 tar -zxvf abPOA-v1.5.6_arm64-macos.tar.gz
127 ```
128
129 ## General usage
130 ### Generate a consensus sequence
131
132 ```
133 abpoa seq.fa > cons.fa
134 ```
135
136 abPOA provides two conensus calling methods:
137 * heaviest bundlding (default): the path with largest weight along the partial order graph
138 * most frequent bases: pick the most common base at each alignment position
139
140 Sometimes these two methods will generate different consensus sequences [#67](https://github.com/yangao07/abPOA/issues/67)
141
142
143 To use `most frequent bases` method:
144 ```
145 abpoa seq.fa -a1 > cons.fa
146 ```
147
148 ### Generate multiple consensus sequences
149
150 ```
151 abpoa heter.fa -d2 > 2cons.fa
152 abpoa 3alleles.fa -d3 > 3cons.fa
153 ```
154
155 ### Generate row-column multiple sequence alignment in FASTA format
156
157 ```
158 abpoa seq.fa -r1 > out.msa
159 abpoa seq.fa -r2 > out_cons.msa
160 ```
161
162 ### Generate graph information in [GFA](https://github.com/GFA-spec/GFA-spec/blob/master/GFA1.md) format
163
164 ```
165 abpoa seq.fa -r3 > out.gfa
166 ```
167 To include the generated consensus sequence as a path in the GFA file:
168 ```
169 abpoa seq.fa -r4 > out.gfa
170 ```
171
172 ### Align sequence to an existing graph in GFA/MSA format
173 ```
174 abpoa -i in.gfa seq.fa -r3 > out.gfa
175 abpoa -i in.msa seq.fa -r1 > out.msa
176 ```
177 For GFA input file, `S` and `P` lines are required and are used to reconstruct the alignment graph.
178 For MSA input file, which is generally a FASTA format file, `-` in the sequence indicates the alignment gap.
179 ```
180 abpoa seq1.fa -r1 > seq1.msa
181 abpoa -i seq1.msa seq2.fa > cons.fa
182 ```
183
184 ### Generate a consensus sequence for amino acid sequences
185 ```
186 abpoa -c -t BLOSUM62.mtx input_aa.fa > output_aa_cons.fa
187 ```
188 abPOA provides two score matrix files for amino acid sequences: `BLOSUM62.mtx`, `HOXD70.mtx`.
189
190 You can also use any score matrix, as long as it has the same format as the above two.
191
192 ### Generate a plot of the alignment graph
193
194 ```
195 abpoa seq.fa -g poa.png > cons.fa
196 ```
197 See [Plot of alignment graph](#plot-of-alignment-graph) for more details about the plot file.
198
199 ## Input
200 abPOA works with FASTA, FASTQ, gzip'd FASTA(.fa.gz) and gzip'd FASTQ(.fq.gz) formats. The input file is
201 expected to contains multiple sequences which will be processed sequentially to perform the iterative
202 sequence-to-graph (partial order) alignment.
203
204 abPOA can also take a list of filenames as input with option `-l`, where each line is the path to one
205 file containing multiple sequences. Each sequence file is then individually aligned by abPOA to generate a
206 consensus sequence.
207
208 ## Output
209 ### Consensus sequence
210 By default, abPOA only outputs the consensus sequence generated from the final alignment graph.
211 It is in FASTA format with the name field set as "Consensus_sequence".
212 For example:
213 ```
214 >Consensus_sequence
215 ACGTGTACACGTTGAC
216 ```
217
218 For diploid input sequences, you may want to generate two or more consensus sequences, simply set `-d/--max-num-cons` as a desired value:
219 ```
220 abpoa heter.fa -d2
221 ```
222 and this gives you two consensus sequences:
223 ```
224 >Consensus_sequence_1
225 CCATTCCCACCATCCTTACCATCAACATCACCATCCCCACCATCCCCAACACCATTCCCACCATCCCTACCATCACCATCACCATCCCCACCAACATCCCCACCACCATCCTCACTACCATCCCCACCACCATTTCCACCATTCCCACCACAGTCACCATCACCCCCACCATCCCCATCATCATCCGCACCATCCCCACCATCCCCACCACCATCTCCATTACCATCCCCACCACCATCTCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATTTCCACCATTCCCACCATCATCCCCACCACCATCCTCGTTACCATCCCCACCACCTTTTCCACCATTCCCACCATCTCCAACACCTCCCCCACCATCATCCCCACCATCCCCACCACCTTCTCCACCATCATTCTCACCATCCCCACCACCATCTCCACCACCATTCTCACCATCTCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCATCATCCCCACCATCC
226 >Consensus_sequence_2
227 CCATTCCCACCATCCTTACCATCAACATCACCATCCCCACCATCCCCAACACCATTCCCACCATCCCTACCATCACCATCACCATCCCCACCAACATCCCCACCACCATCCTCACTACCATCCCCACCACCATTTCCACCATTCCCACCACAGTCACCATCACCCCCACCATCCCCATCATCATCCGCACCATCCCCACCATCCCCACCACCATCTCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATTTCCACCATTCCCACCATCATCCCCACCACCATCCTCGTTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATTTCCACCATTCCCACCATCATCCCCACCACCATCCCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATTTCCACCATTCCCACCATCATCCCCACCACCATCCTCGTTACCATCCCCACCACCTTTTCCACCATTCCCACCATCATCCCCACCGCCATCCTCGTTACCATCCCCACCACCTTTTCCACCATTCCCACCATCTCCAACACCTCCCCCACCATCATCCCCACCATCCCCACCACCTTCTCCACCATCATTCTCACCATCCCCACCACCATCTCCACCACCATTCTCACCATCTCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCATCATCCCCACCATCC
228 ```
229 ### Row-column multiple sequence alignment
230 abPOA can also output the row-column multiple sequence alignment (RC-MSA) of all the aligned sequences in FASTA format.
231 For example:
232 ```
233 >1
234 ACGTGTACA-GTTGAC
235 >2
236 A-G-GTACACGTT-AC
237 >3
238 A-GTGT-CACGTTGAC
239 >4
240 ACGTGTACA--TTGAC
241 ```
242 The `-` in the sequence stands for alignment gap.
243
244 ### Full graph information
245 abPOA can output the final alignment graph in GFA format.
246 Each segment line (`S` line) represents one node and each link line (`L` line) represents one edge between two nodes.
247 The original input sequences and the generated consensus sequence are described as paths in `P` lines.
248
249 abPOA outputs two graph-related numbers in the header line (`H` line):
250 `NS` and `NL`, which denote the total number of nodes and edges in the GFA file, respectively.
251
252 Please refer to the [GFA specification](https://github.com/GFA-spec/GFA-spec/blob/master/GFA1.md) for more details of the GFA format.
253
254 ### Plot of alignment graph
255
256 abPOA can generate a plot of the final partial order alignment graph with the help of `graphviz dot`.
257 For example:
258
259 ![pog](https://github.com/yangao07/abPOA/blob/main/pog.png)
260
261 The numbers inside the nodes are the node IDs. The numbers on the edges are the edge weights.
262 `S` and `E` are the auxiliary start and end nodes that have no sequence bases.
263
264 Make sure you have `dot` installed before using abPOA to generate the plot.
265 For Linux/Unix systems: `sudo apt-get install graphviz`.
266
267 ## Algorithm description
268 ### Adaptive banding
269 To understand how the adaptive banding working, please refer to our [Bioinformatics paper](https://dx.doi.org/10.1093/bioinformatics/btaa963).
270
271 ### Minimizer-based seeding mode
272 As abPOA always allocates quadratic size of memory, for very long input sequences (>10 kb), memory usage will be a challenge.
273
274 To solve this issue, we develop a minimizer-based seeding and partition method to split the sequence and graph with a small window.
275 The full POA DP matrix can be split into several smaller ones and adaptive banded POA can be performed within each small window separately.
276
277 In more detail, abPOA extracts all the minimizers from all the input sequences, then all the minimizer hits between each pair of two sequences can be found.
278 For each pair of sequences, the minimizer hits are first chained together using relatively stringent criteria to make sure that no big gap exists in the chain.
279 This usually leads to several separated local chains of minimizer hits.
280 A second round of chaining is then performed on all the local minimizer chains to generate a global chain going through the entire sequence.
281 With this global chain, abPOA selects a series of minimizer hits as partition anchors which has at least a distance of 500 bp (by default, -n/--min-poa-win).
282 Within each partitioned window, abPOA performs banded partial order alignment separately and combines all the alignment results at the end.
283
284 ### Minimizer-based progressive tree
285 Instead of aligning all the sequences in the original order, abPOA can alternatively build a progressive tree to guide the alignment order.
286 The generation of the progressive tree is also based on minimizers.
287 For each pair of sequences, abPOA calculates their similarity score which is the Jaccard similarity of the minimizers, i.e. the number of minimizer hits divided by the total number of all minimizers from the two sequences.
288 With all the similarity scores (minimizer-based Jaccard similarity), abPOA builds the progressive tree in the following way:
289
290 1. Pick the first two sequences that have the highest scores. The progressive tree set is initialized as these first two sequences.
291 2. For each remaining sequence, sum the scores between the remaining sequence and all the sequences from the current progressive tree set. Pick the one with the highest sum score, and push it to the progressive tree set.
292 3. Repeat step 2, until no sequence remains.
293
294 Then, abPOA performs partial order alignment following the order of sequences in this progressive tree set.
295
296 ### Multiple consensus sequences
297 abPOA supports generating multiple consensus sequences from the final alignment graph (set -d/--maxnum-cons as >1).
298 Since v1.5.5, more than 2 consensus sequences can be generated.
299
300 While -d is the maximum number of consensus sequences to generate, the actual number of consensus sequences generated can be less than -d, depending on the input sequences and the minimum allele frequency (-q/--min-freq).
301
302 The general underlying idea is to group input sequences into multiple clusters based on the heterozygous bases in the MSA.
303 Then, one consensus sequence is separately generated for each cluster of input sequences.
304 The minimum allele frequency, i.e., ratio of cluster size to the total number of sequences for each cluster, is 0.25 (by default, -q/--min-freq).
305
306 ## For development
307 abPOA is not only a stand-alone tool for MSA and consensus calling, it can also work as a programming library. [example.c](example.c) shows how to use the C APIs of abPOA to take a set of sequences as input and perform MSA and consensus calling. Basically, the library file `libabpoa.a` and two header files [abpoa.h](include/abpoa.h) and [simd_instruction.h](include/simd_instruction.h) are needed to make the abPOA library work in your program.
308
309 abPOA also provides Python bindings to all the primary C APIs. Refer to [python/README.md](python/README.md) for more details.
310
311 ## Evaluation datasets
312 The evaluation datasets and scripts used in [abPOA paper](https://dx.doi.org/10.1093/bioinformatics/btaa963) can be found in [abPOA-v1.0.5](https://github.com/yangao07/abPOA/releases/tag/v1.0.5).
313
314 ## Contact
315 Yan Gao [email protected]
316
317 Yi Xing [email protected]
318
319 Yadong Wang [email protected]
320
321 [github issues](https://github.com/yangao07/abPOA/issues)