Skip to content

Commit

Permalink
optimize transformation param in trans_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiLiubio committed Mar 10, 2024
1 parent c4bfb4a commit 4ecc462
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
7 changes: 3 additions & 4 deletions R/microtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ microtable <- R6Class(classname = "microtable",
#' Calculate beta diversity dissimilarity matrix, such as Bray-Curtis, Jaccard, and UniFrac.
#' See An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035> and Lozupone et al. (2005) <doi:10.1128/AEM.71.12.8228–8235.2005>.
#'
#' @param method default NULL; a character vector with one or more elements; "bray" and "jaccard" are used when \code{method = NULL};
#' see the \code{method} parameter in \code{\link{vegdist}} function for more available options.
#' @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{\link{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.
Expand All @@ -762,8 +762,7 @@ microtable <- R6Class(classname = "microtable",
}
res[[i]] <- as.matrix(vegan::vegdist(eco_table, method = i, binary = binary_use, ...))
}

if(unifrac == T){
if(unifrac){
if(is.null(self$phylo_tree)){
stop("No phylogenetic tree provided, please change the parameter unifrac to FALSE")
}
Expand Down
10 changes: 5 additions & 5 deletions R/trans_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ trans_diff <- R6Class(classname = "trans_diff",
#' or used to generate significance letters when method is 'anova' or 'KW_dunn' like the alpha parameter in \code{cal_diff} of \code{trans_alpha} class.
#' @param p_adjust_method default "fdr"; p.adjust method; see method parameter of \code{p.adjust} function for other available options;
#' "none" means disable p value adjustment; So when \code{p_adjust_method = "none"}, P.adj is same with P.unadj.
#' @param transformation default NULL; feature abundance transformation method based on the mecodev package (https://github.com/ChiLiubio/mecodev),
#' such as 'AST' for the arc sine square root transformation. Please see the \code{trans_norm} class of mecodev package.
#' @param transformation default NULL; feature abundance transformation method in the class \code{\link{trans_norm}},
#' such as 'AST' for the arc sine square root transformation.
#' Only available when \code{method} is one of "KW", "KW_dunn", "wilcox", "t.test", "anova", "scheirerRayHare", "betareg" and "lme".
#' @param remove_unknown default TRUE; whether remove unknown features that donot have clear classification information.
#' @param lefse_subgroup default NULL; sample sub group used for sub-comparision in lefse; Segata et al. (2011) <doi:10.1186/gb-2011-12-6-r60>.
Expand Down Expand Up @@ -230,9 +230,9 @@ trans_diff <- R6Class(classname = "trans_diff",
if(method %in% c("KW", "KW_dunn", "wilcox", "t.test", "anova", "scheirerRayHare", "lm", "betareg", "lme", "glmm", "glmm_beta")){
abund_foralpha <- abund_table
if(!is.null(transformation)){
message("Perform the transformation with method: ", transformation, " ...")
tmp <- mecodev::trans_norm$new(abund_foralpha)
abund_foralpha <- tmp$norm(method = transformation)
message("Perform data transformation with method: ", transformation, " ...")
tmp <- suppressMessages(trans_norm$new(as.data.frame(t(abund_foralpha))))
abund_foralpha <- tmp$norm(method = transformation) %>% t %>% as.data.frame
}
if(method == "KW_dunn"){
# filter taxa with 1 across all samples
Expand Down
4 changes: 2 additions & 2 deletions man/microtable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/trans_diff.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ecc462

Please sign in to comment.