Skip to content
Open
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
26 changes: 26 additions & 0 deletions R/getMDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
#' difference is that these functions apply microbiome-specific options such
#' as \code{getDissimilarity} function by default.
#'
#' By default \code{scater::calculateMDS} keeps only the \code{ntop = 500}
#' most variable features. When rarefaction is enabled (\code{niter > 0}) the
Comment on lines +20 to +21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the R code throw a warning of this if it does not use all features? (if data has more than 500)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have mia::getMDS and mia::addMDS, we could set the default to no filtering. At least, I have not heard that variance filtering is commonly used in MDS in microbiome context (or then authors of papers have not explicitly stated that)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would also set the default to no filtering.

We can show examples on how to add filtering.

#' sampling depth is evaluated on this filtered matrix, so samples whose depth
#' falls below the requested \code{sample} are dropped. Pass \code{ntop = Inf}
#' (or specify \code{subset.row}) if you need to retain all taxa so that the
#' minimum depth of \code{assay(x, assay.type)} remains reachable.
#'
#' See \code{\link[scater:runMDS]{scater::calculateMDS}} for details.
#'
#' @return
Expand All @@ -40,6 +47,13 @@
#' \item \code{subset.result}: \code{Logical result}. Specifies whether to
#' subset \code{x} to match the result if some samples were removed during
#' calculation. (Default: \code{TRUE})
#'
#' \item \code{ntop}: \code{Numeric scalar}. Forwarded to
#' \code{scater::calculateMDS}. Controls how many of the most variable
#' features are kept before MDS is run. (Default: \code{500}). Set
#' \code{ntop = Inf} (or supply \code{subset.row}) when you need the full
#' assay for operations such as rarefaction where absolute library sizes
#' matter.
#' }
#'
#' @examples
Expand All @@ -60,6 +74,18 @@
#' # Calculate PCoA with Unifrac and rarefaction. (Note: increase iterations)
#' tse <- addMDS(tse, method = "unifrac", name = "unifrac_rare", niter = 2L)
#'
#' # Disable feature filtering when rarefying at the minimum depth
#' min_depth <- min(colSums(assay(tse, "counts")))
#' tse <- addMDS(
#' tse,
#' assay.type = "counts",
#' method = "bray",
#' niter = 2L,
#' sample = min_depth,
#' ntop = Inf
#' )
#' reducedDim(tse, "MDS")[1:3, 1:2]
#'
#' # Visualize results
#' p1 <- plotReducedDim(tse, "unifrac", colour_by = "SampleType") +
#' labs(title = "Not rarefied")
Expand Down
26 changes: 26 additions & 0 deletions man/addMDS.Rd

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

Loading