diff --git a/R/meshclustR.R b/R/meshclustR.R index 990a9df62cfc0b22b284406db1148c35aa32080e..bc6a6b878c3a70e8e47b617104690afd4d30bfad 100644 --- a/R/meshclustR.R +++ b/R/meshclustR.R @@ -13,6 +13,10 @@ #' `which meshclust` on commandline). Default is set to "meshclust". #' @param filepath The path to the directory where the temporary and log #' files will be saved. +#' @param threshold Numeric value between 0 and 0.99 or FALSE (default). +#' Numeric values will be used as clustering thresholds for meshclust to override +#' the automatically set threshold. If FALSE, meshclust will determine the +#' threshold (recommended). #' @return A data frame with information regarding the clustering analysis. #' #' @examples @@ -23,7 +27,8 @@ #' @export meshclustR <- function(seqs = MyDNAStringSet, meshclust_bin = meshclust, - filepath = path){ + filepath = path, + threshold = FALSE){ #create temporary file path temp_file <- file.path(filepath, 'cluster_me.fa') @@ -34,8 +39,14 @@ meshclustR <- function(seqs = MyDNAStringSet, tools::file_path_sans_ext(basename(temp_file)),'.txt')) #run Meshclust - system2(meshclust_bin, args = c('-d', temp_file, - '-o', out_file)) + if(is.numeric(threshold) && 0 < threshold && threshold <= 0.99){ + system2(meshclust, args = c("-d", temp_file, + "-o", out_file, + "-t", threshold)) + }else{ + system2(meshclust, args = c("-d", temp_file, + "-o", out_file)) + } #read output file and parse stable_cluster <- readr::read_delim(out_file, delim = '\t', diff --git a/man/meshclustR.Rd b/man/meshclustR.Rd index 5c459fcbaba1594671759a4654b01ae89cfac25c..ab6de91f6ab2de587c45b52e7c662477b396b1f9 100644 --- a/man/meshclustR.Rd +++ b/man/meshclustR.Rd @@ -4,7 +4,12 @@ \alias{meshclustR} \title{Write temporary file to cluster using MeshclustR} \usage{ -meshclustR(seqs = MyDNAStringSet, meshclust_bin = meshclust, filepath = path) +meshclustR( + seqs = MyDNAStringSet, + meshclust_bin = meshclust, + filepath = path, + threshold = FALSE +) } \arguments{ \item{seqs}{A DNAStringSet object containing the DNA sequences to be clustered.} @@ -14,6 +19,11 @@ meshclustR(seqs = MyDNAStringSet, meshclust_bin = meshclust, filepath = path) \item{filepath}{The path to the directory where the temporary and log files will be saved.} + +\item{threshold}{Numeric value between 0 and 0.99 or FALSE (default). +Numeric values will be used as clustering thresholds for meshclust to override +the automatically set threshold. If FALSE, meshclust will determine the +threshold (recommended).} } \value{ A data frame with information regarding the clustering analysis.