Skip to content

Commit

Permalink
replace calculateRDA with getRDA and calculateCCA with getCCA (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: Tuomas Borman <[email protected]>
  • Loading branch information
thpral and TuomasBorman authored Jun 28, 2024
1 parent 867d9de commit c9f36b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
38 changes: 19 additions & 19 deletions R/plotCCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#'
#' @param object a
#' \code{\link[TreeSummarizedExperiment:TreeSummarizedExperiment-constructor]{TreeSummarizedExperiment}}
#' or a matrix of weights. The latter is returned as output from \code{\link[mia:runCCA]{calculateRDA}}.
#' or a matrix of weights. The latter is returned as output from \code{\link[mia:runCCA]{getRDA}}.
#'
#' @param dimred A string or integer scalar indicating the reduced dimension to
#' plot. This is the output of \code{\link[mia:runCCA]{runRDA}} and resides in
#' plot. This is the output of \code{\link[mia:runCCA]{addRDA}} and resides in
#' \code{reducedDim(tse, dimred)}.
#'
#' @param add.ellipse One of \code{c(TRUE, FALSE, "fill", "colour", "color")},
Expand Down Expand Up @@ -85,10 +85,10 @@
#' for supervised ordination of microbiome data. Either a
#' \code{\link[TreeSummarizedExperiment:TreeSummarizedExperiment-constructor]{TreeSummarizedExperiment}}
#' or a matrix object is supported as input. When the input is a
#' TreeSummarizedExperiment, this should contain the output of runRDA
#' TreeSummarizedExperiment, this should contain the output of addRDA
#' in the reducedDim slot and the argument \code{dimred} needs to be defined.
#' When the input is a matrix, this should be returned as output from
#' calculateRDA. However, the first method is recommended because it provides
#' getRDA. However, the first method is recommended because it provides
#' the option to adjust aesthetics to the colData variables through the
#' arguments inherited from \code{\link[scater:plotReducedDim]{plotReducedDim}}.
#'
Expand All @@ -104,7 +104,7 @@
#' tse <- enterotype
#'
#' # Run RDA and store results into TreeSE
#' tse <- runRDA(tse,
#' tse <- addRDA(tse,
#' formula = assay ~ ClinicalStatus + Gender + Age,
#' FUN = vegan::vegdist,
#' distance = "bray",
Expand Down Expand Up @@ -135,11 +135,11 @@
#' add.vectors = FALSE)
#'
#' # Calculate RDA as a separate object
#' rda_mat <- calculateRDA(tse,
#' formula = assay ~ ClinicalStatus + Gender + Age,
#' FUN = vegan::vegdist,
#' distance = "bray",
#' na.action = na.exclude)
#' rda_mat <- getRDA(tse,
#' formula = assay ~ ClinicalStatus + Gender + Age,
#' FUN = vegan::vegdist,
#' distance = "bray",
#' na.action = na.exclude)
#'
#' # Create RDA plot from RDA matrix
#' plotRDA(rda_mat)
Expand Down Expand Up @@ -330,9 +330,9 @@ setMethod("plotRDA", signature = c(object = "matrix"),
expl_var <- summary(rda)$concont$importance[2, ]*100
} else{
# If it cannot be found, give warning
warning(paste("RDA/CCA object was not found. Please compute",
"RDA/CCA by using runCCA or calculateCCA."),
call. = FALSE)
warning(
paste("RDA/CCA object was not found. Please compute",
"RDA/CCA by using addCCA or getCCA."), call. = FALSE)
}
}

Expand Down Expand Up @@ -364,9 +364,9 @@ setMethod("plotRDA", signature = c(object = "matrix"),
vector_data[["group"]] <- rownames(vector_data)
} else{
# If it cannot be found, give warning
warning(paste("RDA/CCA object was not found. Please compute RDA/CCA",
"by using runCCA or calculateCCA."),
call. = FALSE)
warning(
paste("RDA/CCA object was not found. Please compute RDA/CCA",
"by using addCCA or getCCA."), call. = FALSE)
}
}

Expand Down Expand Up @@ -429,9 +429,9 @@ setMethod("plotRDA", signature = c(object = "matrix"),
vector_data[["vector_label"]] <- vector_label
} else{
# If it cannot be found, give warning
warning(paste("Significance data was not found. please compute",
"CCA/RDA by using runCCA or calculateCCA."),
call. = FALSE)
warning(
paste("Significance data was not found. please compute",
"CCA/RDA by using addCCA or getCCA."), call. = FALSE)
}
}

Expand Down
12 changes: 6 additions & 6 deletions man/plotCCA.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-plotCCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ test_that("plot RDA/CCA", {
expect_error(plotRDA(tse, "RDA"), "'dimred' must specify reducedDim.")

# Run/calculate RDA
tse <- runRDA(tse, assay ~ patient_status + cohort)
rda <- calculateRDA(tse, assay ~ patient_status + cohort)
tse <- addRDA(tse, assay ~ patient_status + cohort)
rda <- getRDA(tse, assay ~ patient_status + cohort)

# Minimal functionality
expect_no_error(plotRDA(tse, "RDA"))
Expand Down

0 comments on commit c9f36b0

Please sign in to comment.