Entering edit mode
6.3 years ago
cool_abbecker
•
0
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