diff --git a/R/similiarity_to_reference.R b/R/similiarity_to_reference.R index 5da43161dbcb0decb2662084f1cf8d4f067b6273..85b35c72d2868d6d22a7b1ac7f7550ce0ae58f06 100644 --- a/R/similiarity_to_reference.R +++ b/R/similiarity_to_reference.R @@ -2,12 +2,14 @@ #' #' This function takes in a set of sequences and parses a similarity matrix to extract the similarity to a reference sequence. The resulting data is filtered to return only the similarity values for the reference sequence. The function supports parallel processing with multiple cores. #' -#' @param seqs A DNAStringSet object containing the sequences. +#' @param seqs A named DNAStringSet object containing the sequences to compare to ref. +#' @param ref A named DNAStringSet object containing the reference sequences. #' @param ncores An integer specifying the number of cores to use for parallel processing. Defaults to 1. #' #' @import dplyr tibble tidyr #' @export -similiarity_to_reference <- function (seqs = DNAStringSet, +similiarity_to_reference <- function (seqs = named_DNAStringSet, + ref = named_DNAStringSet, ncores = 1) { if(length(seqs) > 1){ out <- alignment_based_distance_matrix(seqs = seqs, @@ -15,7 +17,7 @@ similiarity_to_reference <- function (seqs = DNAStringSet, as_tibble(rownames = "query") %>% pivot_longer(cols = -query, names_to = "seqnames", values_to = "sim_to_ref") %>% - mutate(seq_var = if_else(query == names(seqs)[1], "ref", "none")) %>% + mutate(seq_var = if_else(query == names(ref)[1], "ref", "none")) %>% filter(seq_var == "ref") %>% select(-seq_var, -query) } diff --git a/man/similiarity_to_reference.Rd b/man/similiarity_to_reference.Rd index e942b24ab97a4fa7519254fef998ed3be1caa8ec..f972befec69dbb2b14c8bc94314c307f52349148 100644 --- a/man/similiarity_to_reference.Rd +++ b/man/similiarity_to_reference.Rd @@ -4,10 +4,16 @@ \alias{similiarity_to_reference} \title{Parse similarity matrix to extract similarity to reference} \usage{ -similiarity_to_reference(seqs = DNAStringSet, ncores = 1) +similiarity_to_reference( + seqs = named_DNAStringSet, + ref = named_DNAStringSet, + ncores = 1 +) } \arguments{ -\item{seqs}{A DNAStringSet object containing the sequences.} +\item{seqs}{A named DNAStringSet object containing the sequences to compare to ref.} + +\item{ref}{A named DNAStringSet object containing the reference sequences.} \item{ncores}{An integer specifying the number of cores to use for parallel processing. Defaults to 1.} }