Problem with pairwiseAlignment in R
1
0
Entering edit mode
10.0 years ago
l.roca ▴ 10

Hi,

Based on two sequences from the book: Sequence Alignment Methods, Models, Concepts,and Strategies Edited by Michael S. Rosenberg.

I run the following script:

> library(Biostrings)
> s1 <- "GGAATGG"
> s2 <- "ATG"
> sigma <- nucleotideSubstitutionMatrix(match = 2, mismatch = -1, baseOnly = TRUE)
> globalAligns1s2 <- pairwiseAlignment(s1, s2, type="global", substitutionMatrix = sigma,  scoreOnly = FALSE)
> globalAligns1s2 # Print out the optimal alignment and its score

With the following output:

Global PairwiseAlignmentsSingleSubject (1 of 1)
pattern: [1] GGAATGG
subject: [1] AT----G
score: -26

Based on the book results I should get an alignment score of -5 and one of these alignment:

GGAATGG
---ATG-

Or

GGAATGG
---AT-G

Or

GGAATGG
--A-TG-

Or

GGAATGG
--A-T-G

Any help or idea what I did wrong?

Thanks

alignment r • 4.3k views
ADD COMMENT
0
Entering edit mode

Try tweaking the gapOpening and gapExtension parameters to be lower values, such as -2 and -1.

ADD REPLY
0
Entering edit mode

I tried without success. The parameters in the book where:

Match score = +1.

Mismatch score = -1.

Gap score = -2.

ADD REPLY
1
Entering edit mode
10.0 years ago
library(Biostrings)
sm <- nucleotideSubstitutionMatrix(match = 1, mismatch = -1, baseOnly = TRUE)
s1 <- DNAString("GGAATGG")
s2 <- DNAString("ATG")
pairwiseAlignment(s1,s2, substitutionMatrix=sm, scoreOnly=F, gapOpening=0, gapExtension=-2)

I get one of the expected results and a score of -5. Note that pairwiseAlignment() takes a bit of playing with to see how its scoring really works.

ADD COMMENT
0
Entering edit mode

Thanks a lot, I am getting it (slowley :-)).

How can I output it so it will look like this:

GGAATGG
--A-TG-
ADD REPLY
1
Entering edit mode

use writePairwiseAlignments() to write the alignment object to a file. It would like you have shown above.

ADD REPLY
0
Entering edit mode

No clue, I honestly don't use pairwiseAlignment() for anything real.

ADD REPLY

Login before adding your answer.

Traffic: 2072 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6