Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rarefaction in unifrac #686

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mia
Type: Package
Version: 1.15.20
Version: 1.15.21
Authors@R:
c(person(given = "Tuomas", family = "Borman", role = c("aut", "cre"),
email = "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,4 @@ Changes in version 1.15.x
+ Add addPrevalence function that adds results of getPrevalence to rowData
+ Added support for dimred to getCrossAssociation
+ Add wrapper for PhILR transformation
+ Support rarefaction when applying unifrac
15 changes: 14 additions & 1 deletion R/addDissimilarity.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#' \item \code{dis.fun}: \code{Character scalar}. Specifies the dissimilarity
#' function to be used.
#'
#' \item \code{transf}: \code{Function}. Specifies the optional
#' transformation applied before calculating the dissimilarity matrix.
#'
#' \item \code{tree.name}: (Unifrac) \code{Character scalar}. Specifies the
#' name of the tree from \code{rowTree(x)} that is used in calculation.
#' Disabled when \code{tree} is specified. (Default: \code{"phylo"})
Expand Down Expand Up @@ -171,6 +174,15 @@
#' res <- getDissimilarity(tse, method = "bray", assay.type = "relabundance")
#' as.matrix(res)[1:6, 1:6]
#'
#' # If applying rarefaction, the input must be count matrix and transformation
#' # method specified in function call (Note: increase niter)
#' rclr <- function(x){
#' vegan::decostand(x, method="rclr")
#' }
#' res <- getDissimilarity(
#' tse, method = "euclidean", transf = rclr, niter = 2L)
#' as.matrix(res)[1:6, 1:6]
#'
NULL

#' @rdname getDissimilarity
Expand Down Expand Up @@ -238,6 +250,7 @@ setMethod(
args <- .get_tree_args(
x, method = method, assay.type = assay.type,
transposed = transposed, ...)
args <- c(args, list(niter = niter))
} else{
# For other cases, do not fetch tree data from TreeSE
mat <- assay(x, assay.type)
Expand Down Expand Up @@ -301,7 +314,7 @@ setMethod(
}
}
# Initialize an argument list
args <- c(list(mat), list(...))
args <- c(list(x = mat), list(...))
# If rarefaction is specified, calculate dissimilarity with vegan::avgdist
# function that utilizes the specified dissimilarity function. Otherwise,
# call the specified function directly.
Expand Down
12 changes: 12 additions & 0 deletions man/getDissimilarity.Rd

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

Loading