Skip to content

Commit

Permalink
rename calculateDPCoA, calculateNMDS, calculateRDA, calculateCCA (mic…
Browse files Browse the repository at this point in the history
…robiome#524)

Co-authored-by: Leo Lahti <[email protected]>
  • Loading branch information
thpralas and antagomir authored May 29, 2024
1 parent b627edc commit 9198263
Show file tree
Hide file tree
Showing 14 changed files with 251 additions and 162 deletions.
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.13.18
Version: 1.13.19
Authors@R:
c(person(given = "Felix G.M.", family = "Ernst", role = c("aut"),
email = "[email protected]",
Expand Down
20 changes: 14 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ export(TAXONOMY_RANKS)
export(ZTransform)
export(addCluster)
export(addContaminantQC)
export(addDPCoA)
export(addDivergence)
export(addDominant)
export(addMediation)
export(addNMDS)
export(addNotContaminantQC)
export(addPerSampleDominantFeatures)
export(addPerSampleDominantTaxa)
Expand All @@ -17,12 +19,14 @@ export(agglomerateByRank)
export(agglomerateByRanks)
export(agglomerateByVariable)
export(bestDMNFit)
export(calculateCCA)
export(calculateDMN)
export(calculateDMNgroup)
export(calculateDPCoA)
export(calculateJSD)
export(calculateNMDS)
export(calculateOverlap)
export(calculateRDA)
export(calculateUnifrac)
export(cluster)
export(countDominantFeatures)
Expand All @@ -37,10 +41,12 @@ export(full_join)
export(getBestDMNFit)
export(getCrossAssociation)
export(getDMN)
export(getDPCoA)
export(getDominant)
export(getExperimentCrossAssociation)
export(getExperimentCrossCorrelation)
export(getMediation)
export(getNMDS)
export(getPrevalence)
export(getPrevalent)
export(getPrevalentAbundance)
Expand Down Expand Up @@ -95,11 +101,13 @@ export(readQZA)
export(relAbundanceCounts)
export(relabundance)
export(right_join)
export(runCCA)
export(runDMN)
export(runDPCoA)
export(runJSD)
export(runNMDS)
export(runOverlap)
export(runRDA)
export(runUnifrac)
export(setTaxonomyRanks)
export(splitByRanks)
Expand All @@ -126,6 +134,7 @@ export(unsplitByRanks)
export(unsplitOn)
exportMethods("relabundance<-")
exportMethods(ZTransform)
exportMethods(addCCA)
exportMethods(addCluster)
exportMethods(addContaminantQC)
exportMethods(addDivergence)
Expand All @@ -135,20 +144,17 @@ exportMethods(addMediation)
exportMethods(addNotContaminantQC)
exportMethods(addPerSampleDominantFeatures)
exportMethods(addPerSampleDominantTaxa)
exportMethods(addRDA)
exportMethods(addTaxonomyTree)
exportMethods(agglomerateByPrevalence)
exportMethods(agglomerateByRank)
exportMethods(agglomerateByRanks)
exportMethods(agglomerateByVariable)
exportMethods(bestDMNFit)
exportMethods(calculateCCA)
exportMethods(calculateDMN)
exportMethods(calculateDMNgroup)
exportMethods(calculateDPCoA)
exportMethods(calculateJSD)
exportMethods(calculateNMDS)
exportMethods(calculateOverlap)
exportMethods(calculateRDA)
exportMethods(calculateUnifrac)
exportMethods(checkTaxonomy)
exportMethods(cluster)
Expand All @@ -162,18 +168,22 @@ exportMethods(estimateFaith)
exportMethods(estimateRichness)
exportMethods(full_join)
exportMethods(getBestDMNFit)
exportMethods(getCCA)
exportMethods(getCrossAssociation)
exportMethods(getDMN)
exportMethods(getDPCoA)
exportMethods(getDominant)
exportMethods(getExperimentCrossAssociation)
exportMethods(getExperimentCrossCorrelation)
exportMethods(getHierarchyTree)
exportMethods(getMediation)
exportMethods(getNMDS)
exportMethods(getPrevalence)
exportMethods(getPrevalent)
exportMethods(getPrevalentAbundance)
exportMethods(getPrevalentFeatures)
exportMethods(getPrevalentTaxa)
exportMethods(getRDA)
exportMethods(getRare)
exportMethods(getRareFeatures)
exportMethods(getRareTaxa)
Expand Down Expand Up @@ -208,9 +218,7 @@ exportMethods(rarefyAssay)
exportMethods(relAbundanceCounts)
exportMethods(relabundance)
exportMethods(right_join)
exportMethods(runCCA)
exportMethods(runOverlap)
exportMethods(runRDA)
exportMethods(splitOn)
exportMethods(subsampleCounts)
exportMethods(subsetByPrevalent)
Expand Down
4 changes: 3 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Changes in version 1.11.x
+ rename importers loadFromBiom, loadFromQIIME2, readQZA, loadFromMothur, loadFromMetaphlan, loadFromHumann
+ fix typo in loadFromBiom definition (deprecate file)
+ deprecate subsetSamples, subsetFeatures and subsetTaxa
+ deprecate plotNMDS after moving it to miaViz package
+ deprecate plotNMDS after moving it to miaViz
+ rename estimateDivergence to addDivergence
+ Add details to documentation of function agglomerateByPrevalence

Expand All @@ -134,3 +134,5 @@ Changes in version 1.13.x
+ Explain that rarefyAssay returns a new SummarizedExperiment object that
includes the newly added subsampled assay.
+ Fix bug in mergeFeaturesByPrevalence
+ new aliases calculateDPCoA to getDPCoA, calculateNMDS to getNMDS, calculateRDA to getRDA,
calculateCCA to getCCA
15 changes: 7 additions & 8 deletions R/deprecate.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @param x A
#' \code{\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}}
#' object.
#'
#'
#' @param ... Additional parameters. See dedicated function.
#'
#' @name deprecate
Expand All @@ -17,7 +17,6 @@ setGeneric("cluster", signature = c("x"),

#' @rdname deprecate
#' @export
#' @importFrom bluster clusterRows
setMethod("cluster", signature = c(x = "SummarizedExperiment"),
function(x,...){
.Deprecated(msg = paste0("'cluster' is deprecated. ",
Expand Down Expand Up @@ -471,12 +470,12 @@ setGeneric("full_join", signature = c("x"),
#' @rdname deprecate
#' @export
setMethod("full_join", signature = c(x = "ANY"),
function(x, ...){
.Deprecated(msg = paste0("'full_join' is deprecated. ",
"Use 'mergeSEs' with 'join = full' ",
"instead."))
mergeSEs(x, join = "full", ...)
}
function(x, ...){
.Deprecated(msg = paste0("'full_join' is deprecated. ",
"Use 'mergeSEs' with 'join = full' ",
"instead."))
mergeSEs(x, join = "full", ...)
}
)

#' @rdname deprecate
Expand Down
74 changes: 51 additions & 23 deletions R/runCCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
#' specified by \code{homogeneity.test} parameter.
#'
#' @return
#' For \code{calculateCCA} a matrix with samples as rows and CCA dimensions as
#' For \code{getCCA} a matrix with samples as rows and CCA dimensions as
#' columns. Attributes include calculated \code{cca}/\code{rda} object and
#' significance analysis results.
#'
#' For \code{runCCA} a modified \code{x} with the results stored in
#' For \code{addCCA} a modified \code{x} with the results stored in
#' \code{reducedDim} as the given \code{name}.
#'
#' @name runCCA
Expand All @@ -100,18 +100,18 @@
#' @examples
#' library(scater)
#' data(GlobalPatterns)
#' GlobalPatterns <- runCCA(GlobalPatterns, data ~ SampleType)
#' GlobalPatterns <- addCCA(GlobalPatterns, data ~ SampleType)
#' plotReducedDim(GlobalPatterns,"CCA", colour_by = "SampleType")
#'
#' # Fetch significance results
#' attr(reducedDim(GlobalPatterns, "CCA"), "significance")
#'
#' GlobalPatterns <- runRDA(GlobalPatterns, data ~ SampleType)
#' GlobalPatterns <- addRDA(GlobalPatterns, data ~ SampleType)
#' plotReducedDim(GlobalPatterns,"CCA", colour_by = "SampleType")
#'
#' # Specify dissimilarity measure
#' GlobalPatterns <- transformAssay(GlobalPatterns, method = "relabundance")
#' GlobalPatterns <- runRDA(
#' GlobalPatterns <- addRDA(
#' GlobalPatterns, data ~ SampleType, assay.type = "relabundance", method = "bray")
#'
#' # To scale values when using *RDA functions, use transformAssay(MARGIN = "features", ...)
Expand All @@ -121,36 +121,36 @@
#' # their value is NA
#' tse <- tse[ rowSums( is.na( assay(tse, "z") ) ) == 0, ]
#' # Calculate RDA
#' tse <- runRDA(tse, formula = data ~ SampleType,
#' tse <- addRDA(tse, formula = data ~ SampleType,
#' assay.type = "z", name = "rda_scaled", na.action = na.omit)
#' # Plot
#' plotReducedDim(tse,"rda_scaled", colour_by = "SampleType")
#' # A common choice along with PERMANOVA is ANOVA when statistical significance
#' # of homogeneity of groups is analysed. Moreover, full signficance test results
#' # can be returned.
#' tse <- runRDA(tse, data ~ SampleType, homogeneity.test = "anova", full = TRUE)
#' tse <- addRDA(tse, data ~ SampleType, homogeneity.test = "anova", full = TRUE)
#'
NULL

#' @rdname runCCA
setGeneric("calculateCCA", signature = c("x"),
setGeneric("getCCA", signature = c("x"),
function(x, ...)
standardGeneric("calculateCCA"))
standardGeneric("getCCA"))

#' @rdname runCCA
setGeneric("runCCA", signature = c("x"),
setGeneric("addCCA", signature = c("x"),
function(x, ...)
standardGeneric("runCCA"))
standardGeneric("addCCA"))

#' @rdname runCCA
setGeneric("calculateRDA", signature = c("x"),
setGeneric("getRDA", signature = c("x"),
function(x, ...)
standardGeneric("calculateRDA"))
standardGeneric("getRDA"))

#' @rdname runCCA
setGeneric("runRDA", signature = c("x"),
setGeneric("addRDA", signature = c("x"),
function(x, ...)
standardGeneric("runRDA"))
standardGeneric("addRDA"))

.remove_special_functions_from_terms <- function(terms){
names(terms) <- terms
Expand Down Expand Up @@ -210,7 +210,7 @@ setGeneric("runRDA", signature = c("x"),

#' @export
#' @rdname runCCA
setMethod("calculateCCA", "ANY",
setMethod("getCCA", "ANY",
function(x, ...){
.calculate_cca(x, ...)
})
Expand Down Expand Up @@ -250,7 +250,7 @@ setMethod("calculateCCA", "ANY",

#' @export
#' @rdname runCCA
setMethod("calculateCCA", "SummarizedExperiment",
setMethod("getCCA", "SummarizedExperiment",
function(x, formula, variables, test.signif = TRUE,
assay.type = assay_name, assay_name = exprs_values, exprs_values = "counts",
scores = "wa", ...)
Expand Down Expand Up @@ -289,10 +289,17 @@ setMethod("calculateCCA", "SummarizedExperiment",
}
)

#' @export
#' @rdname runCCA
#' @aliases getCCA
calculateCCA <- function(x,...){
getCCA(x,...)
}

#' @export
#' @rdname runCCA
#' @importFrom SingleCellExperiment reducedDim<-
setMethod("runCCA", "SingleCellExperiment",
setMethod("addCCA", "SingleCellExperiment",
function(x, formula, variables, altexp = NULL, name = "CCA", ...)
{
if (!is.null(altexp)) {
Expand All @@ -301,13 +308,20 @@ setMethod("runCCA", "SingleCellExperiment",
y <- x
}
# Calculate CCA
cca <- calculateCCA(y, formula, variables, ...)
cca <- getCCA(y, formula, variables, ...)
# Add object to reducedDim
x <- .add_object_to_reduceddim(x, cca, name = name, ...)
return(x)
}
)

#' @export
#' @rdname runCCA
#' @aliases addCCA
runCCA <- function(x,...){
addCCA(x,...)
}

#' @importFrom vegan sppscores<-
.calculate_rda <- function(
x, formula, variables, scores, method = distance, distance = "euclidean", ...){
Expand Down Expand Up @@ -548,14 +562,14 @@ setMethod("runCCA", "SingleCellExperiment",

#' @export
#' @rdname runCCA
setMethod("calculateRDA", "ANY",
setMethod("getRDA", "ANY",
function(x, ...){
.calculate_rda(x, ...)
})

#' @export
#' @rdname runCCA
setMethod("calculateRDA", "SummarizedExperiment",
setMethod("getRDA", "SummarizedExperiment",
function(x, formula, variables, test.signif = TRUE,
assay.type = assay_name, assay_name = exprs_values, exprs_values = "counts",
scores = "wa", ...)
Expand Down Expand Up @@ -595,10 +609,17 @@ setMethod("calculateRDA", "SummarizedExperiment",
}
)

#' @export
#' @rdname runCCA
#' @aliases getRDA
calculateRDA <- function(x,...){
getRDA(x,...)
}

#' @export
#' @rdname runCCA
#' @importFrom SingleCellExperiment reducedDim<-
setMethod("runRDA", "SingleCellExperiment",
setMethod("addRDA", "SingleCellExperiment",
function(x, formula, variables, altexp = NULL, name = "RDA", ...)
{
if (!is.null(altexp)) {
Expand All @@ -607,9 +628,16 @@ setMethod("runRDA", "SingleCellExperiment",
y <- x
}
# Calculate RDA
rda <- calculateRDA(y, formula, variables, ...)
rda <- getRDA(y, formula, variables, ...)
# Add object to reducedDim
x <- .add_object_to_reduceddim(x, rda, name = name, ...)
return(x)
}
)

#' @export
#' @rdname runCCA
#' @aliases addRDA
runRDA <- function(x,...){
addRDA(x,...)
}
Loading

0 comments on commit 9198263

Please sign in to comment.