Department of Microbiology, University of Hong Kong, Pokfulam, Hong Kong, China

Department of Biochemistry, University of Hong Kong, Pokfulam, Hong Kong, China

Department of Biology, University of Ottawa, Canada

Abstract

Background

MATLAB is a high-performance language for technical computing, integrating computation, visualization, and programming in an easy-to-use environment. It has been widely used in many areas, such as mathematics and computation, algorithm development, data acquisition, modeling, simulation, and scientific and engineering graphics. However, few functions are freely available in MATLAB to perform the sequence data analyses specifically required for molecular biology and evolution.

Results

We have developed a MATLAB toolbox, called MBEToolbox, aimed at filling this gap by offering efficient implementations of the most needed functions in molecular biology and evolution. It can be used to manipulate aligned sequences, calculate evolutionary distances, estimate synonymous and nonsynonymous substitution rates, and infer phylogenetic trees. Moreover, it provides an extensible, functional framework for users with more specialized requirements to explore and analyze aligned nucleotide or protein sequences from an evolutionary perspective. The full functions in the toolbox are accessible through the command-line for seasoned MATLAB users. A graphical user interface, that may be especially useful for non-specialist end users, is also provided.

Conclusion

MBEToolbox is a useful tool that can aid in the exploration, interpretation and visualization of data in molecular biology and evolution. The software is publicly available at

Background

MATLAB integrates programming, visualization and computation in an easy-to-use environment and is widely used in scientific and engineering studies. One of the most attractive features of MATLAB is that the basic data element of the system is a matrix that does not require dimensioning. This allows users to solve many technical computing problems, especially those with matrix and vector formulations, in a very effective way. The MATLAB environment itself offers a comprehensive set of built-in functions and many toolboxes have been developed, and are often freely available, for more specialized needs.

However, to our knowledge, these advantages in the MATLAB environment have not been fully utilized in the area of molecular biology and evolution. Only a few MATLAB toolboxes or functions are freely available for data analysis, exploration, and visualization of nucleotide and protein sequences. MATHWORKS has recently provided a bioinformatics toolbox, however this toolbox has relatively limited functions for molecular evolutionary studies. MBEToolbox, is presented here to fulfil the most obvious needs in sequence manipulation, genetic distance estimation and phylogeny inference under the MATLAB environment. Moreover, this toolbox provides an extensible, functional framework to formulate and solve problems in evolutionary data analysis. It facilitates the rapid construction of both general applications, as well as special-purpose tools for evolutionary biologists, in a fraction of the time it would take to write a program in a scalar, noninteractive language such as C or FORTRAN.

Implementation

MBEToolbox is written in the MATLAB language and has been tested on the WINDOWS platform with MATLAB version 6.1.0. The main functions implemented are: sequence manipulation, computation of evolutionary distances derived from nucleotide-, amino acid- or codon-based substitution models, phylogenetic tree construction, sequence statistics and graphics functions to visualize the results of analyses. Although it implements only a small fraction of the multiplicity of existing methods used in molecular evolutionary analyses, interested users can easily extend the toolbox.

Input data and formats

MBEToolbox requires a single ASCII file containing the nucleotide or amino acid sequence alignment in either PHYLIP

After input, in common with the MATHWORKS bioinformatics toolbox, MBEToolbox represents the alignment as a numeric matrix with every element standing for a nucleic or amino acid character. Nucleotides A, C, G and T are converted to integers 1 to 4, and the 20 amino acids are converted to integers 1 to 20. A header, containing information about the names and type of the sequences as well as the relevant genetic code for protein-coding nucleotides, is attached to the alignment matrix to form a MATLAB

aln =

seqtype: 2

geneticcode: 1

seqnames: {1 × n cell}

seq: [n × m double]

where

Sequence manipulation and statistics

The alignment structure, aln, can be manipulated using the MATLAB language. For example, aln.seq(x,:) will extract the

Evolutionary distances

The evolutionary distance is one of the important measures in molecular evolutionary studies. It is required to measure the diversity among sequences and to infer distance-based phylogenies. MBEToolbox contains a number of functions to calculate evolutionary distances based on the observed number of differences. The formulae used in these functions are analytical solutions of a variety of Markov substitution models, such as JC69 **F**, where _{ij }denotes the proportion of sites for which sequence 1 (_{1}) has an _{2}) has a _{1 }and _{2 }is then given by

where **∏ **denotes the diagonal matrix with values of nucleotide equilibrium frequencies on the diagonal, and **A**)denotes the trace of matrix **A**. The above formula can be expressed in MATLAB syntax directly as:

>> d = -trace(PI*logm(inv(PI)*F))

MBEToolbox also calculates the gamma distribution distance and the LogDet distance

For alignments of codons, the toolbox provides calculation or estimation of the synonymous (_{s}) and non-synonymous (_{a}) substitution rates by the counting method of Nei and Gojobori _{s }and _{a }require that the input sequences are aligned in the appropriate reading frame, which can be performed by the function alignseqfile. Unresolved codon sites will be removed automatically. In addition, several quantities, including the number of substitutions per site at only synonymous sites, at only non-synonymous sites, at only four-fold-degenerate sites, or at only zero-fold-degenerate sites can be calculated. The output from these calculations are distance matrices which can be exported into text or excel files, or used directly in further operations.

Phylogeny inference

Two distance-based tree creation algorithms, Unweighted Pair Group Method with Arithmetic mean (UPGMA) and neighbor-joining (NJ)

The simplest case of estimation of the evolutionary distance between two sequences, **Q**, is used to indicate the rate of changing from one state to another. For a specified time interval or distance, **P**(^{Qt}. If there are

In this equation,

In MBEToolbox, to calculate the likelihood, **Q**, (Q = R*diag(pi)). Once the model is specified, the function likelidist(t, model, s1, s2) can calculate the log likelihood of the alignment of the two sequences,

In most cases we wish to estimate

Log-likelihood of evolutionary distance

**Log-likelihood of evolutionary distance**. (a) Likelihood as function of K2P distance. The distance is estimated by maximising the likelihood of the alignment with the bias of transitions to transversions,

When calculating the likelihood of a phylogenetic tree, where _{a}, we must sum over all possible assignments of nucleotides to _{a }to get the likelihood of the distance between

Combination of functions

Basic operations can be combined to give more complicated functions. A simple combination of the function to extract the fourfold degenerate sites with the function to calculate GC content produces a new function (countgc4) that determines the GC content at 4-fold degenerate sites (GC4). A subfunction for calculating synonymous and nonsynonymous differences between two codons, getsynnonsyndiff, can be converted into a program for calculating codon volatility

Graphics and GUI

Good visualisation is essential for successful numerical model building. Leveraging the rich graphics functionality of MATLAB, MBEToolbox provides a number of functions that can be used to create graphic output, such as scatterplots of _{s }vs _{a}, plots of the number of transitions and transversions against genetic distance, sliding window analyses on a nucleotide sequence and the Z-curve (a 3-dimensional curve representation of a DNA sequence

MBEToolbox GUI

**MBEToolbox GUI**. (a) Distances submenu; (b) Phylogeny submenu; (c) Graph submenu; and (d) Polymorphism submenu.

Results and discussion

Vectorization simplifies programming

MATLAB is a matrix language, which means it is designed for vector and matrix operations. Programming can be simplified and made more efficient by using algorithms that take advantage of

where

function [z,z_raw] = zscores(s1,s2,nboot)

ml = length(s1);

m2 = length(s2);

% Initialise two vectors holding Z-score of

% s1_rep and s2_rep, i.e., replicate samples

% of sequences s1 and s2.

v_z1 = zeros(1,nboot);

v_z2 = zeros(1,nboot);

z_raw = smithwaterman(s1,s2);

for (k = 1:nboot),

s1_rep = s1(:,randperm(m1));

v_z1(1,k) = smithwaterman(s1_rep, s2) ;

s2_rep = s2(:,randperm(m2));

v_z2(1,k) = smithwaterman(s1, s2_rep);

end

z1 = (z_raw-mean(v_z1))./std(v_z1);

z2 = (z_raw-mean(v_z2))./std(v_z2);

z = min(z1,z2);

where randperm(n) is a vector function returning a random permutation of the integers from 1 to

Extensibility

An important distinction between compiled languages with subroutine libraries and interactive environments like MATLAB is the ease with which problems can be specified and solved in the latter. Moreover, MATLAB toolboxes are traditionally organised in a less object-oriented mode and, consequently, functions are more independent of each other and easier to combine and extend. Several examples were given in the Implementation section.

Comparison with other toolboxes

Some other toolboxes have been developed in MATLAB for bioinformatics related analyses. These include PHYLLAB

MBEToolbox provides a much broader range of molecular evolution related functions and phylogenetic methods than either the more specialized PHYLLAB project or the more general bioinformatics toolbox from MATHWORKS. These extra functions include IO in PHYLIP format, statistical and sequence manipulation functions relevant to molecular evolution (e.g. count segregating sites), evolutionary distance calculation for nucleic and amino acid sequences, phylogeny inference functions and graphic plots relevant to molecular evolution (e.g. _{a }vs _{s}). As such it makes an important contribution to the bioinformatics analyses that can be performed in the MATLAB environment.

A novel enhanced window analysis

To test for the selective pressures in the different lineages of a phylogenetic tree, the nonsynonymous to synonymous rate ratio (_{a}/_{s}) is normally estimated _{a}/_{s }= 1, > 1, or < 1 indicate neutrality, positive selection, or purifying selection, respectively. However, _{s }and _{a }are measurements of average synonymous and nonsynonymous substitutions per site along the whole length of the sequences. Average _{s }and _{a}values give neither the pattern of intragenic fluctuation of selective constraints, nor region- or site-specific information. A sliding window method is usually adopted to examine the _{s }would indicate that the neutral substitution rate varies across the gene, whereas heterogeneity in _{a}may indicate that selective constraints vary along the gene. The results and accuracy of sliding window methods, either overlapping or non-overlapping, depend on both the size of the window and the moving distance adopted. Large window lengths may obliterate the details of patterns in _{s }or _{a}, whereas small window lengths usually result in larger statistical fluctuations. Hence, the resolution of a sliding window is usually limited.

A mathematical formalism, similar to the Z'-curve _{s }or _{a}. In the _{s }or _{a }occurring from the first to the _{s }or _{a }and

The two-dimensional curve of (

To compare these two curve representations, the example dataset of Suzuki and Gojobori _{s }and _{a }values. The reduction of _{s }in the C, El and NS5B regions, as well as its elevation in NS3, which have been shown in previous studies

A comparison between sliding window and enhanced sliding window methods

**A comparison between sliding window and enhanced sliding window methods**. Sliding window analysis of _{s }and _{a }for the concatenated coding regions of two hepatitis C virus strains, HCV-JS and HCV-JT. The number of codons for the C, El, E2, NS2, NS3, NS4, NS5A, and NS5B genes are 191, 192, 426, 217, 631, 315, 447, and 591, respectively. The different coding regions are separated by vertical lines. (a) illustrates the result of a normal sliding window analysis; (b) illustrates the result of the enhanced sliding window analysis. Beginnings and ends of regions poor in synonymous substitutions (** a **and

Limitations

The current version of this toolbox lacks novel algorithms yet it implements a variety of existing algorithms. There are some limitations in the practical use of MBEToolbox. First, though the toolbox provides many methods to infer and handle sequence and evolutionary analyses, the full range of these features can only be accessed through the MATLAB command line interface, as in the majority of MATLAB packages. Second, some of the functions cannot handle ambiguous nucleotide or amino acid codes in the sequences. The future development of MBEToolbox will overcome these present limitations.

Conclusion

The MBEToolbox project is an ongoing effort to provide an easy-to-use, yet powerful, analysis environment for molecular biology and evolution. Currently, it offers a substantial set of frequently used functions to manipulate sequences, to calculate genetic distances, to infer phylogenetic trees and related analyses. MBEToolbox is a useful tool which should inspire evolutionary biologists to take advantage of the MATLAB environment.

Availability and requirements

**Project name: **MBEToolbox

**Project web page: **

**Operating system: **WINDOWS 95/98/2000/XP

**Programming language: **MATLAB 6.0 or higher

**Other requirements: **Statistics Toolbox

**License: **GPL

**Any restrictions on use by non-academics: **License needed

Authors' contributions

JJC designed and implemented the software and wrote the draft of the manuscript. DKS participated in the design and revised the manuscript. XX participated in the design and provided suggestions for future development. KYY supervised and participated in the design of the study. All authors read and approved the final version of the manuscript.

Acknowledgements

This work was supported by the AIDS Trust Fund (MSS 083), Research Grant Council Grant (HKU 7363/03M), and University Development Fund, University of Hong Kong. JJC would like to thank Dr. Nam-Kiu Tsing (Department of Mathematics, University of Hong Kong) for valuable discussions, and Dr. Richard E. Strauss (Department of Biological Sciences, Texas Tech University) for allowing his NJ routine to be adapted for MBEToolbox and for releasing his MATLAB library to the public.