How to calculate Levenshtein distance with custom substitution matrix?
0
0
Entering edit mode
6.3 years ago

How can I calculate a Levenshtein distance (edit distance) in R (for DNA) with a custom substitution matrix that scores transversions and transitions differently?

No, Biostrings::stringDist does not work for that. It is either Hamming with subst. matrix OR edit distance without subst. matrix.

No ape::dist.dna, does not work for this, while it can score transversions and transitions differently, it does not allow to supply a custom substitution matrix.

Thanks!

something like this:

subst <- matrix(nrow=4,ncol=4,dimnames=list(c("A","C","T","G"),c("A","C","T","G")),data=1.1)
diag(subst) <- 0
subst["A","G"] <- 0.9
subst["T","C"] <- 0.9
subst["G","A"] <- 0.9
subst["C","T"] <- 0.9
R • 1.6k views
ADD COMMENT

Login before adding your answer.

Traffic: 1984 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