If I have two sequences:

1: A-B-C-D
1: X-A-B-C-D

and I do:

seqdist(sequence1, sequence2, method = "OM")

Will it then compare position 1, 2, 3, 4, 5 (in the 2nd sequence) and show that each position needs to be replaced, or is it smart enough to just insert the X at the front of the 1st sequence, and then shift the other markers so as to make the two sequences equal (aligned)?


1 Answer 1


Yes, this is the whole advantage of optimal matching over Hamming distance. You can check it like this

myseq <- seqdef(c("a-b-c-d", "x-a-b-c-d"))
seqdist(myseq, method="OM", sm="CONSTANT")

The resulting distance is one, because it only insert x at the front and then shift the rest of the sequence.

If you use


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.