Bioinformatics I, WS 16/17, D. Huson, January 30,

Similar documents
EECS730: Introduction to Bioinformatics

Sequence Database Search Techniques I: Blast and PatternHunter tools

Grundlagen der Bioinformatik, SS 08, D. Huson, May 2,

Basic Local Alignment Search Tool

Algorithms in Bioinformatics FOUR Pairwise Sequence Alignment. Pairwise Sequence Alignment. Convention: DNA Sequences 5. Sequence Alignment

Introduction to Sequence Alignment. Manpreet S. Katari

BLAST: Basic Local Alignment Search Tool

Bioinformatics and BLAST

Bioinformatics (GLOBEX, Summer 2015) Pairwise sequence alignment

3. SEQUENCE ANALYSIS BIOINFORMATICS COURSE MTAT

In-Depth Assessment of Local Sequence Alignment

Sara C. Madeira. Universidade da Beira Interior. (Thanks to Ana Teresa Freitas, IST for useful resources on this subject)

Heuristic Alignment and Searching

THEORY. Based on sequence Length According to the length of sequence being compared it is of following two types

BLAST. Varieties of BLAST

Computational Biology

Dynamic programming in less time and space

Lecture 4: Evolutionary Models and Substitution Matrices (PAM and BLOSUM)

Tools and Algorithms in Bioinformatics

Bioinformatics for Biologists

Bloom Filters, Minhashes, and Other Random Stuff

Chapter 5. Proteomics and the analysis of protein sequence Ⅱ

Algorithms in Bioinformatics

String Matching Problem

Whole Genome Alignments and Synteny Maps

Large-Scale Genomic Surveys

Alignment principles and homology searching using (PSI-)BLAST. Jaap Heringa Centre for Integrative Bioinformatics VU (IBIVU)

08/21/2017 BLAST. Multiple Sequence Alignments: Clustal Omega

20 Grundlagen der Bioinformatik, SS 08, D. Huson, May 27, Global and local alignment of two sequences using dynamic programming

Sequence analysis and Genomics

L3: Blast: Keyword match basics

Pairwise sequence alignment

BLAST Database Searching. BME 110: CompBio Tools Todd Lowe April 8, 2010

An Introduction to Sequence Similarity ( Homology ) Searching

Homology Modeling (Comparative Structure Modeling) GBCB 5874: Problem Solving in GBCB

Motivating the need for optimal sequence alignments...

Scoring Matrices. Shifra Ben-Dor Irit Orr

bioinformatics 1 -- lecture 7

A Browser for Pig Genome Data

Tools and Algorithms in Bioinformatics

Sequence Alignments. Dynamic programming approaches, scoring, and significance. Lucy Skrabanek ICB, WMC January 31, 2013

2.6 Complexity Theory for Map-Reduce. Star Joins 2.6. COMPLEXITY THEORY FOR MAP-REDUCE 51

COMPUTING SIMILARITY BETWEEN DOCUMENTS (OR ITEMS) This part is to a large extent based on slides obtained from

Chapter 7: Rapid alignment methods: FASTA and BLAST

Collected Works of Charles Dickens

Week 10: Homology Modelling (II) - HHpred

Introduction to Bioinformatics

Protein Threading. BMI/CS 776 Colin Dewey Spring 2015

SUPPLEMENTARY INFORMATION

Comparative genomics: Overview & Tools + MUMmer algorithm

Exercise 5. Sequence Profiles & BLAST

Protein Structure Prediction II Lecturer: Serafim Batzoglou Scribe: Samy Hamdouche

Sequence comparison: Score matrices

Tiffany Samaroo MB&B 452a December 8, Take Home Final. Topic 1

Pairwise Alignment. Guan-Shieng Huang. Dept. of CSIE, NCNU. Pairwise Alignment p.1/55

Single alignment: Substitution Matrix. 16 march 2017

CISC 889 Bioinformatics (Spring 2004) Sequence pairwise alignment (I)

Grundlagen der Bioinformatik Summer semester Lecturer: Prof. Daniel Huson

Sequence comparison: Score matrices. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

High-throughput sequence alignment. November 9, 2017

Alignment & BLAST. By: Hadi Mozafari KUMS

DATA MINING LECTURE 3. Frequent Itemsets Association Rules

Sequence comparison: Score matrices. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

Sequence Analysis '17 -- lecture 7

Genomics and bioinformatics summary. Finding genes -- computer searches

Sequence analysis and comparison

Theoretical aspects of ERa, the fastest practical suffix tree construction algorithm

Bio nformatics. Lecture 23. Saad Mneimneh

Sequence Comparison. mouse human

Protein folding. α-helix. Lecture 21. An α-helix is a simple helix having on average 10 residues (3 turns of the helix)

7 Multiple Genome Alignment

Comparing whole genomes

CSE182-L7. Protein Sequence Analysis Patterns (regular expressions) Profiles HMM Gene Finding CSE182

Overview Multiple Sequence Alignment

Bioinformatics for Computer Scientists (Part 2 Sequence Alignment) Sepp Hochreiter

8 Grundlagen der Bioinformatik, SS 09, D. Huson, April 28, 2009

Linear-Space Alignment

EECS730: Introduction to Bioinformatics

Pairwise & Multiple sequence alignments

K-means-based Feature Learning for Protein Sequence Classification

Protein function prediction based on sequence analysis

Sequence Analysis 17: lecture 5. Substitution matrices Multiple sequence alignment

BMC Bioinformatics. Open Access. Abstract

CMPS 3110: Bioinformatics. Tertiary Structure Prediction

CMPS 6630: Introduction to Computational Biology and Bioinformatics. Tertiary Structure Prediction

Reducing storage requirements for biological sequence comparison

5. MULTIPLE SEQUENCE ALIGNMENT BIOINFORMATICS COURSE MTAT

Algorithms: COMP3121/3821/9101/9801

MACFP: Maximal Approximate Consecutive Frequent Pattern Mining under Edit Distance

Comparative Bioinformatics Midterm II Fall 2004

Repeat resolution. This exposition is based on the following sources, which are all recommended reading:

Bioinformatics. Scoring Matrices. David Gilbert Bioinformatics Research Centre

Local Alignment: Smith-Waterman algorithm

Succincter text indexing with wildcards

Multiple Sequence Alignment, Gunnar Klau, December 9, 2005, 17:

Seed-based sequence search: some theory and some applications

Fast profile matching algorithms A survey

Lecture 2, 5/12/2001: Local alignment the Smith-Waterman algorithm. Alignment scoring schemes and theory: substitution matrices and gap models

DATA MINING LECTURE 6. Similarity and Distance Sketching, Locality Sensitive Hashing

CONCEPT OF SEQUENCE COMPARISON. Natapol Pornputtapong 18 January 2018

Transcription:

Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 131 13 The DIAMOND algorithm This chapter is based on the following paper, which is recommended reading: Buchfink, B, Xie, C, & Huson, DH. Fast and Sensitive Protein Alignment using DIAMOND, Nature Methods, 12:59-60 (2015) 1 Functional analysis is an important computational problem in microbiome analysis. Typical problem: You have one billion DNA reads of length 100 150 bp. You want to compare them against a reference database of proteins, e.g. NCBI-nr, currently 113 million entries (Jan 2017). We need to perform protein-protein local alignment on all 6-frame translations of the reads, that is, on 6 billion queries. 13.1 Example To assess the effect of antibiotic on the gut microbiome, in a pilot study performed at UKT, stool samples were collected from two participants before, during and after the course of antibiotics 2 : Illumina HiSeq sequencing was performed on all 12 samples, giving rise to over 60 million reads per sample, over 800 million reads in total. 13.2 Choice of algorithms To solve a problem of this size using BLASTX takes on the order of 30 years on a single server (using 48 cores). DIAMOND solves this problem in few days. DIAMOND is approximately 20,000 times faster than BLASTX on a problem of this size, without much loss of sensitivity. Comparison of BLASTX, RAPSearch2 3 and DIAMOND: 1 http://www.nature.com/nmeth/journal/v12/n1/full/nmeth.3176.html 2 Willmann et al, Antibiotic Selection Pressure Determination through Sequence-Based Metagenomics. Antimicrob Agents Chemother. 2015. https://www.ncbi.nlm.nih.gov/pmc/articles/pmc4649198/ 3 Zhao, Y., Tang, H. & Ye, Y. Bioinformatics 28, 125-126 (2012)

132 Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 The goal of this chapter is to discuss some of the concepts on which the program DIAMOND is based. 13.3 BLAST The tool of choice for this problem was BLASTX: It translates each read in all six frames It extracts a set of seeds for each given query Seeds are compared against the reference sequences Seed matches are extended so as to produce local alignments BLASTX is too slow to be applied to high-throughput sequencing data. calculation significantly faster? More detailed outline of the algorithm employed by BLAST: Consider the following query: P Q G E F G (this is a translated read). Extract all seeds of fixed length (here: 3): PQG, QGE, GEF, EFG, How to do this type of Find all similar words with a BLOSUM62 (or other) score T, where T is a threshold, 15, say. Example: For PQG we also use PEG, but not PQA, because: P Q G P E G 7+2+6 = 15 P Q G P Q A 7+5+0 = 12 Once all seeds have been produced, they are put into a keyword tree : P" Q" G" E" G" This is used to scan the reference sequences for seed matches: A L V L P E G V L V Another example:

Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 133 Query:...L A R R G G V K R I S... Seeds: G V K 18 G A K 16 G I K 16 G G K 14 G L K 13 G N K 12... Possible alignment at seed match: Query:...L A R R G G V K R I S......L G + G I +... Reference:...L N Y G I G A K V I A... Original BLAST uses ungapped extension to full alignment:...r G G V K R......G I G L K V... Extension is stopped when the running score drops by a value of X below the best score seen so far, with X = 15, say. The challenge: How to increase speed without losing sensitivity? 13.4 Reduced alphabet For protein sequences, BLAST generates neighboring words to increase the sensitivity of seeds. An alternative approach to increase sensitivity is to use a reduced alphabet for seeds, treating letters that often replace each other in alignments as identical. Here is a reduction to four letters: [LVIMC] [FYW] [AGSTP] [EDNQKRH] Here is a reduction to 11 letters: [KREDQN] C G H [ILV] M F Y W P [STA] (Only) for the purpose of finding seeds, letters contained in brackets are considered identical. A reduction can be obtained from a set of known protein alignments thus: Count the number of times a given amino a replaces a given amino acid b. From this, infer a similiarity measure. Cluster by similiary. Here we see such a result obtained using the Neighbor-net method:

134 Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 13.5 Representing seeds and their locations Consider an alphabet using k letters. We can intepret a seed of length k as a base-k number. If using an alphabet with k = 11, then we can represent any seed with 18 letters by a single 64-bit number, because 11 18 < 2 64 < 11 19. Let S be a seed that occurs in sequence number r at position p and let a be the encoding of S. We describe this occurrence of S as a triple of numbers (a, r, p). Can we squeeze the encoding of a seed into 32 bits? If using an alphabet with k = 11 and a seed with 12 letters, then we require log 2 (11 12 ) 41.4 bits per seed. If we place all seeds into 2 10 = 1024 buckets based on their first 10 bits, then each seed can be represented by single integer (32 bits), as indicated here: SKSKKFIKGKII Seed (length=12, alphabet size=11) 51230534234182 Seed encoding 000000001001001001101100110101001001101001 10-bit bucket index 32-bit word 42 bits A seed is completely determined but a 32-bit word and its bucket number. 13.6 Double indexing Double indexing is an alternative to the keyword approach of BLAST and also to the use of a hash table, suffix tree or BWT. Outline: 1. Extract all reduced-alphabet seeds from references 2. Sort seeds lexicographically

Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 135 3. Extract all reduced-alphabet seeds from queries 4. Sort seeds lexicographically 5. Traverse both sorted lists simultaneously to find common seeds, as discussed later. This approach is called sort-merge join in relational databases, where it is used to compute a join of two tables based on the values of a given attribute, that is, is to find, for each distinct value of the attribute, the set of row in each table that display that value. 13.7 Sorting seeds We want to sort seeds, together with their locations, quickly. The data is triples of numbers (a, b, c), where a is the encoding of a seed and b, c its location. We want to sort these items by the first component. Idea: use radix sort, which sorts n words of size w in O(nw) time. Using radix sort, DIAMOND can sort all seeds extracted from NCBI-nr (tens of billions of seeds) in minutes on a server. 13.8 Seed matching GIYIWKIIKIFI IIIGMKSSKSKY Once all seeds in the query filegmiiisysiisi and in the references IYICKIIKIFIM file have been sorted, then both lists can be GWIIGKKKSKKS traversed simultaneously to find all seed matches: >Read51201 INGWILVGFSFSFSF MKTKSSNNIKKIYYI SS Sorted'' query' seeds' 13.9 Partitioning IKKIYISIIGIY IKGWIIKMKSSK IKIIIMKSIIIK IIGIICKIIKII IIIKIFMKKISI IIIGMKSSKSKY IIIGYIWKIIKI IIFIKKISIKSI IIFIIYISIIKG IMKKISIKSGMI IFIMKSSIISIG IFISYSSISKGW IYICKIIKIFIM IYYISIIGIICW ISIISIMIIISI ISIYISSIKWII ISSIIGYICKII ' YICWIIKIIIMK YYISIIGIYCWK YYISIIGIYCWK YYISIIGIYCWK YSISSIGWIIGK WKIIKIFIMKSI WIIIKMKSSKSK SIKGIIGKMKSS SIGMIFSIYISI SIGMIFSIYISI SIIKIGIIFSIY ISIKWIIGKKKS ISIISIMIIISI ISIISIMIIISI ISIISIMIIISI ISIISIMIIISI ISIYISSIKWII ISISKGIIIKMK ISSIIGYICKII MKKSSIKSIMII ' FIMKSIIIKIGM FISISIISIGWI FISISIISIGWF YICWIIKIIIMK YISSIIIYIWKI YISSIIIYIWKI YISSIIIYIWKI YISSIIIYIWKI YYISIIGIYCWK WKIIKIFIMKSI WIIIKMKSSKSK WIIIKMKSSKSK SKSSKIKIYISS Sorted'' reference' seeds' Assume the reference database has 90 million sequences with 200 seeds each. >gi 666666 INGWILVGRMFSFFSFSF MKTKSSNNIKKIYYISSI LVGIYLCWQIIIQIIFLM DNSIAILEAIGMVVFISV YSLAVAKKSSKKAQY Then there are 18 billion seeds in total and each requires 12 bytes for 3 integers (encoding, sequence number, position). Thus the memory usage is: 216GB. We can easily partition the problem into 2 h parts using the first h bits of the seeds. Choose h so as to get the desired number of parts 2 h. For example, using h = 10 will partition the problem into 1024 parts. 1'

136 Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 As our goal is to scan through seeds in lexicographical order so as find matches between the queries and references, each part can be processed independently. For example, we can create a queue of all parts and dispatch jobs to a set of worker threads. And/or we can parse through the input files multiple times, each time reading different parts of the list of seeds into memory for processing. 13.10 Spaced seeds The seeds used by BLASTX, and most other sequence database search tools, are contiguous seeds that consist of a set of consecutive letters. A spaced seed consists of a segment of length n in which only a fixed subset of positions is used, and the number of used positions is called the weight k. The exact layout of the positions to be used is determined by the seed shape Z, which is specified by a bit vector, e.g.: Z = 111101101110111, where 1 s indicate positions to use and 0 s indicate positions to ignore. Let Z be be spaced seed shape of weight k and length n. (Note that Z is a contiguous seed in the special case of k = n.) Let q be a query string and r a reference string. We say that there is a seed match of shape Z between q and r if there exist positions i 0 in q and j 0 in r such that q[i 0 + k] = r[j 0 + k] for all k for which the k-th bit in Z is 1 (with all indices starting at 0). Here is an example with i 0 = 1 and j 0 = 2: For seeds used in DNA alignment, a study was undertaken to compare the sensitivity of spaced seeds with that of contiguous seeds 4. Dynamic programming was used to compute the sensitivity when comparing a query and reference DNA sequence, both of length 64, for different levels of similiary, comparing a spaced seed of weight 11 with a contiguous seed of length 10 and 11: (Source: Ma et al, 2002) This plot shows that a spaced seed of weight 11 is more sensitive than a continguous seed of the same weight, or even of smaller weight 10. 4 Ma et al (2002) PatternHunter: faster and more sensitive homology search. Bioinformatics 18, 440 445

Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 137 Note that increasing the seed weight by 1 reduces the number of random hits by a factor of K, where K is related to the alphabet size. In consequence, a spaced seed of weight 11 is more sensitive and produces less random hits than a contiguous seed of weight 10. 13.11 Multiple spaced seeds One way to improve the sensitivity is to decrease the seed weight, at the cost of increasing the number of random hits by a factor of K. An alternative is to add another seed shape. This can significantly increase the sensitivity while only doubling the number of random hits. This figure shows that doubling the number of seeds provides an increase in sensitivity even when simultaneously increasing the weight 5 : (Source: Ilie et al, 2011) Hence, sensitivity is best increased by using multiple different seed shapes. For example, by default, the program DIAMOND uses the following four seed shapes of weight 12 and length 15 26: 111101101110111 1111000101011001111 11101001001000100101111 11101001000010100010100111 In sensitive mode, DIAMOND uses 16 seed shapes. 13.12 Left-most seeds Let Z be a seed shape that we have used to compute a double index for a set of query sequences Q and reference sequences R. Let q and r be a query and reference sequence, respectively, and assume that two sequences are very similar. It may occur that there is more than one seed for which q and r match, call them S 1 and S 2, say, both being part of the same larger alignment of q and r. In the doubling index approach, S 1 and S 2 will usually be encountered in quite different positions in the sorted lists of seeds for Q and R, respectively. 5 Ilie et al (2011) Seeds for effective oligonucleotide design, BMC Genomics 120

138 Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 How to avoid extending and then reporting the same alignment twice? Definition 13.12.1 (Left-most seed) Let Z be a seed shape and q and r two sequences. We say a seed match at positions i in q and j in r is left-most, if there is no other seed match with positions i in q and j in r that is further left, that is, with i < i and j < j, and is on the same diagonal, that is, with i j = i j. Being left-most is a property that can be easily checked by simply sliding the seed shape Z to the left in both sequences, position-by-position, and checking whether a match can be found: AVACAKCILLIPILIPRTVALCAP 11011 11011 MVAAAKCIVVIPLLIPTTVALCKK le$most$ not$le$most$ (If multiple seed shapes are used, then they all must be thus checked.) 13.13 Extension Extension not discussed in lecture. Once a seed match has been identified, the computational task is to extend the seed match to a full local alignment. This requires two dynamic programs, as indicated here: Query&q& dynamic& program& Reference&r& dynamic& program& Let us look closer at the bottom right alignment problem:

Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 139 Seedmatch r t r t+1 r j r n q s q s+1 q i q m 0.1.2 1 0.1.2 2 1 0.1.2 2 1 0.1.2 2 1 0.1.2 2 1 0.1.2 2 1 0.1 2 1 0 2 1 2 squareslabeled bydiagonal For the sake of speed, we intend to perform a banded dynamic program that only takes the labeled cells into account, that is, only those cells that are within a distance of w = 2 to the main diagonal. We can transform the matrix into a matrix that is centered along the band (note, however, that this is currently not done in DIAMOND): q s q s+1 q i q m )2 )1 0 1 2 t t+1 t+2 t+3 t+4 t+5 t t+1 t+2 t+3 t+4 t+5 t+6 t t+1 t+2 t+3 t+4 t+5 t+6 t+7 t+1 t+2 t+3 t+4 t+5 t+6 t+7 t+8 t+2 t+3 t+4 t+5 t+6 t+7 t+8 t+9 squareslabeled byreferenceindex 13.14 Banded alignment We can perform banded alignment in the rectangular matrix shown above. The first and last rows are initialized to the value. We assign the substitution score S(q s, r t ) to the cell F (s, 0) and then define the recursion based on the following figure: Standard&recursion& match& ref.& query& inser/on&in& query& inser/on&in& reference& Recursion&in&rectangular&band& band& match& query& inser/on&in& reference& inser/on&in& query& Note that we compute the index j(i, k) of the reference sequence as a function of the indices of a given cell in the banded alignment matrix as follows: j(i, k) = t + (i s) + k.

140 Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 The recursion is then as follows, for all i = s... m and k = w... w with t j(i, k) n: F (i 1, k) + S(q i, r j(i,k) ) F (i, k) = max F (i, k 1) d F (i 1, k + 1) d where d is the gap penalty and w the band width. When filling the matrix, we keep track of the cell z that contains the best value seen so far. Its value contributes to the total alignment score, which consists of the sum of the best score for the left and right alignments, plus the seed score. Traceback is performed from z to the cell with coordinates (s, 0). To speed up the calculation of local alignments, one can use the X-drop heuristic: Let Z be the best score seen in any of the previous columns. If the best score in the current column is less than Z X, then do not consider any further columns. Here, X is a value, of 15, say, for protein sequences. 13.15 The DIAMOND algorithm In summary, here is an outline of the DIAMOND algorithm. Input the list of query sequences Q. Translate all queries, extract all spaced seeds and their locations, using a reduced alphabet. them. Call this S(Q). Input the list of reference sequences R. Extract all spaced seeds and their locations, using a reduced alphabet. Sort them. Call this S(R). Traverse S(Q) and S(R) simuntaneously. For each seed S that occurs both in S(Q) and S(R), consider all pairs of its locations x and y in Q and R, respectively: check whether there is a left-most seed match. If this is the case, then attempt to extend the seed match to a significant banded alignment 6. Sort 13.16 Example Here is a summary of the performance of DIAMOND on the example data mentioned at the beginning: 6 T. Rognes, Faster Smith-Waterman database searches with inter-sequence SIMD parallelisation. BMC Bioinformatics 2011. https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-12-221

Bioinformatics I, WS 16/17, D. Huson, January 30, 2017 141 The total time is about two and a half days. 13.17 Summary Alignment of queries against a set of reference sequences is usually done in a seed-and-extend fashion One approach is to build an index for the seeds of the references and then to search for each query seed in the index An alternative to this is to sort all seeds occurring in the references, and in the queries, respectively, and then to traverse the lists together Spaced seeds offer more sensitivity and specificity than continguous seeds Based on these ideas, the program DIAMOND can align short sequencing reads against the NCBI-nr database 20,000 times as fast as BLASTX.