diff --git a/R/microtable.R b/R/microtable.R index dddeaf1..5278256 100644 --- a/R/microtable.R +++ b/R/microtable.R @@ -762,8 +762,10 @@ microtable <- R6Class(classname = "microtable", #' @param method default NULL; a character vector with one or more elements; \code{c("bray", "jaccard")} is used when \code{method = NULL}; #' See the \code{method} parameter in \code{vegdist} function for more available options, such as 'aitchison' and 'robust.aitchison'. #' @param unifrac default FALSE; whether UniFrac indexes (weighted and unweighted) are calculated. Phylogenetic tree is necessary when \code{unifrac = TRUE}. - #' @param binary default FALSE; Whether convert abundance to binary data (presence/absence) when \code{method} is not "jaccard". - #' TRUE is used for "jaccard" automatically. + #' @param binary default FALSE; Whether convert abundance to binary data (presence/absence). + #' @param force_jaccard_binary default TRUE; Whether forcibly convert abundance to binary data (presence/absence) when \code{method = "jaccard"}. + #' The reason for this setting is that the Jaccard metric is commonly used for binary data. + #' If \code{force_jaccard_binary = FALSE} is set, the conversion will not be enforced, but will instead be based on the setting of the \code{binary} parameter. #' @param ... parameters passed to \code{vegdist} function of vegan package. #' @return beta_diversity list stored in the object. #' @examples @@ -771,7 +773,7 @@ microtable <- R6Class(classname = "microtable", #' m1$cal_betadiv(unifrac = FALSE) #' class(m1$beta_diversity) #' } - cal_betadiv = function(method = NULL, unifrac = FALSE, binary = FALSE, ...){ + cal_betadiv = function(method = NULL, unifrac = FALSE, binary = FALSE, force_jaccard_binary = TRUE, ...){ res <- list() eco_table <- t(self$otu_table) sample_table <- self$sample_table @@ -784,7 +786,11 @@ microtable <- R6Class(classname = "microtable", for(i in method){ i <- match.arg(i, vegdist_methods) if(i == "jaccard"){ - binary_use <- TRUE + if(force_jaccard_binary){ + binary_use <- TRUE + }else{ + binary_use <- binary + } }else{ binary_use <- binary } diff --git a/R/trans_beta.R b/R/trans_beta.R index e339098..ebb675a 100644 --- a/R/trans_beta.R +++ b/R/trans_beta.R @@ -90,7 +90,7 @@ trans_beta <- R6Class(classname = "trans_beta", #' For the methods details, please refer to the papers (for PCoA, NMDS, PCA and DCA) and #' (for PLS-DA or OPLS-DA). #' @param ncomp default 3; dimensions shown in the results (except method "NMDS"). - #' @param trans default FALSE; whether species abundance will be square transformed; only available when \code{method} is "PCA" or "DCA". + #' @param trans default FALSE; whether species abundance will be square root transformed; only available when \code{method} is "PCA" or "DCA". #' @param scale_species default FALSE; whether species loading in PCA or DCA is scaled. #' @param scale_species_ratio default 0.8; the ratio to scale up the loading; multiply by the maximum distance between samples and origin. #' Only available when \code{scale_species = TURE}. diff --git a/man/microtable.Rd b/man/microtable.Rd index db7a774..7a8ca95 100644 --- a/man/microtable.Rd +++ b/man/microtable.Rd @@ -814,7 +814,13 @@ Save alpha diversity table to the computer. Calculate beta diversity dissimilarity matrix, such as Bray-Curtis, Jaccard, and UniFrac. See An et al. (2019) and Lozupone et al. (2005) . \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{microtable$cal_betadiv(method = NULL, unifrac = FALSE, binary = FALSE, ...)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{microtable$cal_betadiv( + method = NULL, + unifrac = FALSE, + binary = FALSE, + force_jaccard_binary = TRUE, + ... +)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -825,8 +831,11 @@ See the \code{method} parameter in \code{vegdist} function for more available op \item{\code{unifrac}}{default FALSE; whether UniFrac indexes (weighted and unweighted) are calculated. Phylogenetic tree is necessary when \code{unifrac = TRUE}.} -\item{\code{binary}}{default FALSE; Whether convert abundance to binary data (presence/absence) when \code{method} is not "jaccard". -TRUE is used for "jaccard" automatically.} +\item{\code{binary}}{default FALSE; Whether convert abundance to binary data (presence/absence).} + +\item{\code{force_jaccard_binary}}{default TRUE; Whether forcibly convert abundance to binary data (presence/absence) when \code{method = "jaccard"}. +The reason for this setting is that the Jaccard metric is commonly used for binary data. +If \code{force_jaccard_binary = FALSE} is set, the conversion will not be enforced, but will instead be based on the setting of the \code{binary} parameter.} \item{\code{...}}{parameters passed to \code{vegdist} function of vegan package.} } diff --git a/man/trans_beta.Rd b/man/trans_beta.Rd index 6c598c1..e395731 100644 --- a/man/trans_beta.Rd +++ b/man/trans_beta.Rd @@ -161,7 +161,7 @@ For the methods details, please refer to the papers