Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
TuomasBorman committed Jan 19, 2025
1 parent 886a185 commit 759191f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions R/addAlpha.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#' These functions estimates alpha diversity indices optionally using
#' rarefaction.
#'
#' @inheritParams calculateDMN
#'
#' @param x a \code{\link{SummarizedExperiment}} object.
#'
#' @param assay.type \code{Character scalar}. Specifies the name of assay
Expand Down Expand Up @@ -622,9 +624,13 @@ setMethod("getAlpha", signature = c(x = "SummarizedExperiment"),
#' @importFrom BiocParallel bplapply
.alpha_rarefaction <- function(x, assay.type, index, name, niter, BPPARAM, ...){
# Subsample the data and then calculate index based on the rarified data
temp_assay <- "temporary_assay_name"
res <- bplapply(seq(niter), function(i){
x_sub <- rarefyAssay(x, assay.type = assay.type, verbose = FALSE, ...)
temp <- .calculate_alpha(x_sub, "subsampled", index, name, ...)
args <- c(list(x = x, assay.type = assay.type), list(...))
args[["name"]] <- temp_assay
args[["verbose"]] <- FALSE
x_sub <- do.call(rarefyAssay, args)
temp <- .calculate_alpha(x_sub, temp_assay, index, name, ...)
return(temp)
}, BPPARAM = BPPARAM)
# Combine list of matrices from multiple iterations
Expand Down
4 changes: 4 additions & 0 deletions man/addAlpha.Rd

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

3 changes: 2 additions & 1 deletion man/transformAssay.Rd

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

0 comments on commit 759191f

Please sign in to comment.