help sqomSJ6-4: st0111)

Title

sqom -- Optimal matching of sequences

Syntax

sqom
[if] [in]
[, options]

sqom save filename [, replace]

sqom use filename [, clear]

full calculate full dissimilarity matrix between sequences

indelcost(#) set indel costs to #

idealtype(spec) compare with a specified ideal typical sequence

k(#) restrict indels (to save calculation time)

name(varname) specify name for distance variable

refseqid(spec) select reference sequence

sadi(name) call SADI-plugin (if installed)

standard(#|cut|longer|longest|none) standardization of sequences of different length

subcost(#|implied formula|matexp|matname) specify substitution costs

subsequence(a,b) use only subsequence between positions a and b

clear overwrites matrix SQdist with matrix on disk

replace overwrites file on disk

Description

sqom performs optimal matching of sequences. The command
uses the Needleman-Wunsch algorithm to find the alignment between two
sequences that have the lowest Levenshtein distance. The Levenshtein
distances are then stored for further use.

sqom also provides an interface to the distance measures
of Brandan Halpins SADI programms, such as the "Hamming distance",
"Halpins Duration-Adjusted OM", the "Hollister's Localised OM",
"Lesnard's Dynamic Hamming measure", "Time-Warp Edit Distance", and
"Elzinga's number of common subsequences measure". Distances are stored
for further use.

By default, all sequences are compared to the most frequent
sequence and the resulting distances are stored in a variable. It is,
however, possible to compare all sequences with a preselected
reference distance or to compare all sequences with every other
sequence. In the latter case, the resulting distances are stored in a
Stata matrix.

Comparing all sequences with any other sequence is
computationally intensive. We recommend the option sadi() for
working with large datasets.

sqom save saves the distance matrix obtained by
sqom, full under the given filename on disk. If filename is
given without extension, .mmat is used.

sqom use retrieves a distance matrix stored as a file on
disk for subsequent use by other sequence analysis commands. If
filename is given without extension .mmat is assumed.

Options

indelcost(#) specifies the cost attached to an
insertion or deletion of an alignment. The default is indelcost(1).

subcost(#|implied
formula|matexp|matname} specifies the cost attached to a
substitution in an alignment. Substitution costs may be specified as
real number, as implied formula, or as full matrix. Specifying
substitution cost as, for example, subcost(3) will attach the
cost of 3 to any substitution necessary in an alignment, regardless of
how similar the substituted values may be. The default is two times
the value specified as indel cost. A full substitution cost matrix
can be specified either by specifying the name of a matrix containing
the substitution cost or by typing valid matrix syntax into the option
itself. The matrix has to be a symmetric n*n matrix, where n is the
number of different elements in all sequences.

implied formula generates substitution costs based on the data. The implied formula is specified with a keyword. The following keywords are allowed

rawdistance use the
absolute value of the difference between the numeric values representing the respective elements

meanprobdistance calculates symmetric substitiution cost matrix based on the mean of the transitions' probabilities (p) in the data
between every two neighboring elements in the sequences. The substitution costs between elements x and y are defined by: SC(x,y) = SC(y,x) = 2-p(x,y)-p(y,x) if x is not equal to y, otherwise 0.

minprobdistance calculates symmetric substitiution cost matrix based on the transitions' probabilities (p) in the data
between every two neighboring elements in sequences. The substitution cost matrix contains the minimal substitution costs for
each pair of symmetric transitions: SC(x,y) = SC(y,x) = min(1-p(x,y),1-p(y,x))*2 if x is not equal to y, otherwise 0.

maxprobdistance calculates symmetric substitiution cost matrix based on the transitions' probabilities (p) in the data
between every two neighboring elements in sequences. The substitution cost matrix contains the maximal substitution costs for
each pair of symmetric transitions: SC(x,y) = SC(y,x) = max(1-p(x,y),1-p(y,x))*2 if x is not equal to y, otherwise 0.

The substitution costs in last three cases have values between 0 and 2

Specifying a full substitution cost matrix or generating a data based substitution
cost matrix can increase the running time of the program considerably.
Options k(), or sadi() might be considered for sqom with full
substitution cost matrix.

name(varname) is used to specify the name of the
variable in which the distances are stored. If not specified,
_SQdist is used. The automatically generated distance
variable will get overwritten without warning whenever a sqom
command without name() is invoked.

refseqid(spec) is used to select the
reference sequence against which all sequences in the dataset are
being tested. Within the parentheses, an existing value of the sequence
identifier has to be stated.

full is used to perform optimal matching for all
sequences in the dataset against any other. The results of these
comparisons are stored in the distance matrix "SQdist". Specifying
the option full will increase the running time of the program
considerably. Options k(), or sadi() might be considered for sqom
full.

Two companion programs, sqclusterdat and sqclustermat,
help to further analyze the distance matrix produced with sqom, full.

k(#) is used to speed up the calculation of the
optimal matching algorithm. Within the parentheses, an integer
positive number between 1 and the number of positions of the longest
sequence can be given. The speed up will be higher with small numbers.
Very small numbers can have the effect that the algorithm doesn't find
the best alignment between some sequences, and this problem tends to
increase if substitution costs are high relative to indel
costs. The option is ignored when option sadi() is specified.

Note: The implementation of the k() is based partly on the
source code of TDA, written by Goetz Rohwer and Ulrich Poetter. TDA is
a very powerful program for transitory data analysis. It is programmed
in C and distributed as freeware under the terms of the General
Public License. It is downloadable from
http://www.stat.ruhr-uni-bochum.de/tda.html.

sadi(name) calls Brandan Halpins SADI
programs for calculating the full distance matrix. These programs are
developed independenly from the SQ-Ados as plugins written in the
command language C and therefore run much faster than the Mata
implmentation used for standard sqom. Options of sqom are
automatically translated to SADI, and all further functionality of the
SQ-Ados remain unchanged. sqom also automatically handles all
required options of SADI and allow the specification of the additional
SADI options (see help sadi).

sadi() allows to specify one of the following distance
measures. Note that Elzinga's number of common subsequences measure,
which is implemented in SADI is not yet supported by sqom, sadi()

name Distance measure

hamming Hamming distance

oma Levenshtein (same as standard sqom)

omav Halpin's duration-adjusted OM

hollister Hollister's "Localised OM"

dynhamming Lesnard's Dynamic Hamming measure

twed Time warp edit distance

Two companion program, sqclusterdat and sqmdsadd
help to further analyze the distance matrix produced with sqom, sadi().

standard(#|cut|longer|longest|none)
is used to define the standardization of the resulting distances. With
standard(#) all sequences are cut to the length #. The keyword
cut automatically cuts all sequences to the length of the
shortest sequence in the dataset. standard(longer) divides all
distances by the length of the longer sequence of the respective
alignment. standard(longest) divides all distances by the length
of the longest sequence in the dataset; this is the
default. none is specified if no standardization is needed.

subsequence(a,b) is used to include only the part of
the sequence that is between position a and b, whereby a and b refer
to the position defined in the order variable.

idealtype(spec) allows to specify an ideal typical
sequence against which all sequences are compared. To specify the
sequence use element[:repetitions] [element:repetitions]. For example,
with idealtype(3:20 5 1:20 3:20) you specifiy an ideal typical
sequence of length 61. The ideal typical sequence starts with element
3 over 20 positions, followed by one position of elment 5, 20 positions
of element 1 and finally again 20 positions of element 3.

Authors

Ulrich Kohler, University of Potsdam, ulrich.kohler@uni-potsdam.de

Magdalena Luniak

Examples

. sqom, name(mydist)

. sqindexplot, order(mydist)

. sqom, full k(2)

. sqclustermat ward, name(mydist2)

. sqindexplot, order(mydist2)

Also see

Online: sq,
sqdemo, sqset, sqdes, sqegen, sqstat,
sqindexplot, sqparcoord, sqom,
sqclusterdat, sqclustermat