Add variation of Jukes-Cantor distance - #61
Merged
Merged
Conversation
Add variation of Jukes-Cantor distance. The Jukes-Cantor equation remains unchanged, but the definition of which base pairs are considered different is modified. In this function, the fraction of nucleotides that are different incorporates not only the mismatches from the alignment matrix but also the base pairs that are left unaligned.
Add documentation for new function and update documentation of existing functions from the family "Alignment statistics" and "Similarity indexes".
charles-plessy
requested changes
Aug 27, 2026
charles-plessy
left a comment
Collaborator
There was a problem hiding this comment.
Can I ask you two minor changes?
| #' d <- JC69_distance_allseq(gb, exampleSubstitutionMatrix) | ||
| #' | ||
| #' @export | ||
| JC69_distance_allseq <- function(gb, m, adjust_p=FALSE) { |
Collaborator
There was a problem hiding this comment.
Can you add the usual guard for object length 0 ?
if(length(gb) == 0) return(numeric(0))
| # Gets the smallest sequence length. | ||
| totBps <- min(sum(seqlengths(gb)),sum(seqlengths(gb$query))) | ||
| if(is.na(totBps)){ | ||
| totBps <- min(sum(guessSeqLengths(gb)),sum(guessSeqLengths(gb$query))) |
Collaborator
There was a problem hiding this comment.
guessSeqLengths always returns seqlengths when available, so you can run totBps <- min(sum(guessSeqLengths(gb)),sum(guessSeqLengths(gb$query))) straight. Maybe I could have called the function safeSeqLengths but it is probably too late to rename it.
Add safeguard for gb object Remove redundant code
Contributor
Author
|
Thanks Charles for your comments! I have updated the code with the proposed changes. |
charles-plessy
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds a variation of the Jukes-Cantor distance that takes into account unaligned base pairs in the computation.
It also updates the documentation of existing functions from the family "Alignment statistics" and "Similarity indexes".