pairwiseAlignment {Biostrings} | R Documentation |
Solves (Needleman-Wunsch) global alignment, (Smith-Waterman) local alignment, and (ends-free) overlap alignment problems.
pairwiseAlignment(pattern, subject, ...) ## S4 method for signature 'XStringSet, XStringSet': pairwiseAlignment(pattern, subject, patternQuality = PhredQuality(22L), subjectQuality = PhredQuality(22L), type = "global", substitutionMatrix = NULL, fuzzyMatrix = NULL, gapOpening = -10, gapExtension = -4, scoreOnly = FALSE) ## S4 method for signature 'QualityScaledXStringSet, ## QualityScaledXStringSet': pairwiseAlignment(pattern, subject, type = "global", substitutionMatrix = NULL, fuzzyMatrix = NULL, gapOpening = -10, gapExtension = -4, scoreOnly = FALSE)
pattern |
a character vector of any length, an XString , or an
XStringSet object. |
subject |
a character vector of length 1 or an XString object. |
patternQuality, subjectQuality |
objects of class XStringQuality
representing the respective quality scores for pattern and subject
that are used in a quality-based method for generating a substitution matrix.
These two arguments are ignored if !is.null(substitutionMatrix) or if its
respective string set (pattern , subject ) is of class
QualityScaledXStringSet . |
type |
type of alignment. One of "global" , "local" ,
"overlap" , "patternOverlap" , and "subjectOverlap" where
"global" = align whole strings with end gap penalties,
"local" = align string fragments,
"overlap" = align whole strings without end gap penalties,
"patternOverlap" = align whole strings without end gap penalties on
pattern and with end gap penalties on subject ,
"subjectOverlap" = align whole strings with end gap penalties on
pattern and without end gap penalties on subject . |
substitutionMatrix |
substitution matrix for a non-quality based alignment.
It cannot be used in conjunction with patternQuality and
subjectQuality arguments. |
fuzzyMatrix |
fuzzy match matrix for quality-based alignments. It takes values between 0 and 1; where 0 is an unambiguous mismatch, 1 is an unambiguous match, and values in between represent a fraction of "matchiness". |
gapOpening |
the cost for opening a gap in the alignment. |
gapExtension |
the incremental cost incurred along the length of the gap in the alignment. |
scoreOnly |
logical to denote whether or not to return just the scores of the optimal pairwise alignment. |
... |
optional arguments to generic function to support additional methods. |
If scoreOnly == FALSE
, the pairwise alignment with the maximum alignment
score is returned. If more than one pairwise alignment has the maximum alignment
score exists, the first alignment along the subject is returned. If there are
multiple pairwise alignments with the maximum alignment score at the chosen subject
location, then at each location along the alignment mismatches are given preference
to insertions/deletions. For example, pattern: [1] ATTA; subject: [1] AT-A
is chosen above pattern: [1] ATTA; subject: [1] A-TA
if they both have the
maximum alignment score.
General implementation based on Chapter 2 of Haubold and Wiehe (2006). Quality-based method for generating a substitution matrix based on the Bioinformatics article by Ketil Malde given below.
If scoreOnly == FALSE
, an instance of class PairwiseAlignedFixedSubject
is returned.
If scoreOnly == TRUE
, a numeric vector containing the scores for the optimal
pairwise alignments is returned.
Use matchPattern
or vmatchPattern
if you need to
find all the occurences (eventually with indels) of a given pattern in a
reference sequence or set of sequences.
Use matchPDict
if you need to match a (big) set of patterns
against a reference sequence.
P. Aboyoun and H. Pages
R. Durbin, S. Eddy, A. Krogh, G. Mitchison, Biological Sequence Analysis, Cambridge UP 1998, sec 2.3.
B. Haubold, T. Wiehe, Introduction to Computational Biology, Birkhauser Verlag 2006, Chapter 2.
K. Malde, The effect of sequence quality on sequence alignment, Bioinformatics 2008 24(7):897-900.
stringDist
,
PairwiseAlignedFixedSubject-class,
XStringQuality-class,
substitution.matrices,
matchPattern
## Nucleotide global, local, and overlap alignments s1 <- DNAString("ACTTCACCAGCTCCCTGGCGGTAAGTTGATCAAAGGAAACGCAAAGTTTTCAAG") s2 <- DNAString("GTTTCACTACTTCCTTTCGGGTAAGTAAATATATAAATATATAAAAATATAATTTTCATC") # First use a fixed substitution matrix mat <- nucleotideSubstitutionMatrix(match = 1, mismatch = -3, baseOnly = TRUE) globalAlign <- pairwiseAlignment(s1, s2, substitutionMatrix = mat, gapOpening = -5, gapExtension = -2) localAlign <- pairwiseAlignment(s1, s2, type = "local", substitutionMatrix = mat, gapOpening = -5, gapExtension = -2) overlapAlign <- pairwiseAlignment(s1, s2, type = "overlap", substitutionMatrix = mat, gapOpening = -5, gapExtension = -2) # Then use quality-based method for generating a substitution matrix pairwiseAlignment(s1, s2, patternQuality = SolexaQuality(rep(c(22L, 12L), times = c(36, 18))), subjectQuality = SolexaQuality(rep(c(22L, 12L), times = c(40, 20))), scoreOnly = TRUE) ## Amino acid global alignment pairwiseAlignment(AAString("PAWHEAE"), AAString("HEAGAWGHEE"), substitutionMatrix = "BLOSUM50", gapOpening = 0, gapExtension = -8)