Skip to content
Snippets Groups Projects
Commit ed44f8be authored by Simeon's avatar Simeon
Browse files

first try at fixing similarity to seq

parent fbc78132
No related branches found
No related tags found
No related merge requests found
......@@ -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)
}
......
......@@ -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.}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment