From 8834d03ebb1773c06e3b9af729313214db0445ca Mon Sep 17 00:00:00 2001 From: Daena Rys Date: Thu, 21 Nov 2024 15:19:57 +0200 Subject: [PATCH 1/3] change name to character vector Signed-off-by: Daena Rys --- R/getBaselineDivergence.R | 34 ++++++------- R/getStepwiseDivergence.R | 7 +-- man/addBaselineDivergence.Rd | 15 +++--- man/addStepwiseDivergence.Rd | 11 +++-- man/miaTime-package.Rd | 4 +- tests/testthat/test-getBaselineDivergence.R | 53 ++++++++++++++------- tests/testthat/test-getStepwiseDivergence.R | 36 ++++++++------ vignettes/articles/minimalgut.Rmd | 3 +- vignettes/miaTime.Rmd | 2 +- 9 files changed, 96 insertions(+), 69 deletions(-) diff --git a/R/getBaselineDivergence.R b/R/getBaselineDivergence.R index cb3f9fb..951a4cf 100644 --- a/R/getBaselineDivergence.R +++ b/R/getBaselineDivergence.R @@ -54,12 +54,9 @@ #' \code{colData} that identifies the baseline samples to be used. #' (Default: \code{NULL}) #' -#' @param name \code{Character scalar}. Specifies a column name for storing +#' @param name \code{Character vector}. Specifies a column name for storing #' divergence results. (Default: \code{"divergence"}) #' -#' @param name.time \code{Character scalar}. Specifies a column name for storing -#' time differences. (Default: \code{"time_diff"}) -#' #' @param ... Optional arguments passed into #' \code{\link[mia:addDivergence]{mia::addDivergence()}}. #' @@ -86,8 +83,8 @@ #' reference = "reference", #' group = "subject", #' time.col = "time", -#' name = "divergence_from_baseline", -#' name.time = "time_from_baseline", +#' name = c("divergence_from_baseline", +#' "time_from_baseline", "reference_samples"), #' assay.type = "relabundance", #' method = "bray") #' @@ -153,7 +150,7 @@ setMethod("getBaselineDivergence", signature = c(x = "SummarizedExperiment"), reference <- args[["reference"]] time_res <- .get_time_difference(x, time.col, reference) # Create a DF to return - res <- .convert_divergence_to_df(x, res, time_res, ...) + res <- .convert_divergence_to_df(x, res, reference, time_res, ...) return(res) } ) @@ -161,12 +158,13 @@ setMethod("getBaselineDivergence", signature = c(x = "SummarizedExperiment"), #' @rdname addBaselineDivergence #' @export setMethod("addBaselineDivergence", signature = c(x = "SummarizedExperiment"), - function(x, name = "divergence", name.time = "time_diff", ...){ + function(x, name = c("divergence", + "time_diff", "ref_samples"), ...){ # Calculate divergence res <- getBaselineDivergence(x, ...) # Add to colData res <- as.list(res) |> unname() - x <- .add_values_to_colData(x, res, list(name, name.time), ...) + x <- .add_values_to_colData(x, res, name, ...) return(x) } ) @@ -330,13 +328,15 @@ setMethod("addBaselineDivergence", signature = c(x = "SummarizedExperiment"), # This function converts time divergence results to DF object .convert_divergence_to_df <- function( - x, res, time_res, name = "divergence", name.time = "time_diff", ...){ - # - temp <- .check_input(name, list("character scalar")) - # - temp <- .check_input(name.time, list("character scalar")) - # - df <- DataFrame(res, time_res, row.names = colnames(x)) - colnames(df) <- c(name, name.time) + x, res, reference, time_res, name = c("divergence", + "time_diff", "ref_samples"), ...){ + # Validate 'name' param + if (length(name) != 3) { + stop("'name' must be a vector of length 3: + c('divergence', 'time_diff', 'ref_samples')", call. = FALSE) + } + temp <- .check_input(name[1:3], list("character vector")) + df <- DataFrame(res, time_res, reference, row.names = colnames(x)) + colnames(df) <- name return(df) } diff --git a/R/getStepwiseDivergence.R b/R/getStepwiseDivergence.R index 6d4bbad..f0e6565 100644 --- a/R/getStepwiseDivergence.R +++ b/R/getStepwiseDivergence.R @@ -102,7 +102,7 @@ setMethod("getStepwiseDivergence", signature = c(x = "ANY"), reference <- args[["reference"]] time_res <- .get_time_difference(x, time.col, reference) # Create a DF to return - res <- .convert_divergence_to_df(x, res, time_res, ...) + res <- .convert_divergence_to_df(x, res, reference, time_res, ...) return(res) } ) @@ -110,12 +110,13 @@ setMethod("getStepwiseDivergence", signature = c(x = "ANY"), #' @rdname addStepwiseDivergence #' @export setMethod("addStepwiseDivergence", signature = c(x = "SummarizedExperiment"), - function(x, name = "divergence", name.time = "time_diff", ...){ + function(x, name = c("divergence", + "time_diff", "ref_samples"), ...){ # Calculate divergence res <- getStepwiseDivergence(x, ...) # Add to colData res <- as.list(res) |> unname() - x <- .add_values_to_colData(x, res, list(name, name.time), ...) + x <- .add_values_to_colData(x, res, name, ...) return(x) } ) diff --git a/man/addBaselineDivergence.Rd b/man/addBaselineDivergence.Rd index 48a03fd..880b1ab 100644 --- a/man/addBaselineDivergence.Rd +++ b/man/addBaselineDivergence.Rd @@ -21,7 +21,11 @@ addBaselineDivergence(x, ...) ... ) -\S4method{addBaselineDivergence}{SummarizedExperiment}(x, name = "divergence", name.time = "time_diff", ...) +\S4method{addBaselineDivergence}{SummarizedExperiment}( + x, + name = c("divergence", "time_diff", "ref_samples"), + ... +) } \arguments{ \item{x}{A @@ -49,11 +53,8 @@ used in the dissimilarity estimation. (Default: \code{"counts"})} Method is passed to the function that is specified by \code{dis.fun}. (Default: \code{"bray"})} -\item{name}{\code{Character scalar}. Specifies a column name for storing +\item{name}{\code{Character vector}. Specifies a column name for storing divergence results. (Default: \code{"divergence"})} - -\item{name.time}{\code{Character scalar}. Specifies a column name for storing -time differences. (Default: \code{"time_diff"})} } \value{ \code{getBaselineDivergence} returns \code{DataFrame} object @@ -106,8 +107,8 @@ tse <- addBaselineDivergence( reference = "reference", group = "subject", time.col = "time", - name = "divergence_from_baseline", - name.time = "time_from_baseline", + name = c("divergence_from_baseline", + "time_from_baseline", "reference_samples"), assay.type = "relabundance", method = "bray") diff --git a/man/addStepwiseDivergence.Rd b/man/addStepwiseDivergence.Rd index d8ddd9c..b7e9845 100644 --- a/man/addStepwiseDivergence.Rd +++ b/man/addStepwiseDivergence.Rd @@ -21,7 +21,11 @@ addStepwiseDivergence(x, ...) ... ) -\S4method{addStepwiseDivergence}{SummarizedExperiment}(x, name = "divergence", name.time = "time_diff", ...) +\S4method{addStepwiseDivergence}{SummarizedExperiment}( + x, + name = c("divergence", "time_diff", "ref_samples"), + ... +) } \arguments{ \item{x}{A @@ -50,11 +54,8 @@ step, then increase this accordingly. (Default: \code{1L})} Method is passed to the function that is specified by \code{dis.fun}. (Default: \code{"bray"})} -\item{name}{\code{Character scalar}. Specifies a column name for storing +\item{name}{\code{Character vector}. Specifies a column name for storing divergence results. (Default: \code{"divergence"})} - -\item{name.time}{\code{Character scalar}. Specifies a column name for storing -time differences. (Default: \code{"time_diff"})} } \value{ \code{getStepwiseDivergence} returns \code{DataFrame} object diff --git a/man/miaTime-package.Rd b/man/miaTime-package.Rd index 41e150e..a2676ce 100644 --- a/man/miaTime-package.Rd +++ b/man/miaTime-package.Rd @@ -12,18 +12,18 @@ \link[TreeSummarizedExperiment:TreeSummarizedExperiment-class]{TreeSummarizedExperiment} class } \author{ -\strong{Maintainer}: Yagmur Simsek \email{yagmur.simsek@hsrw.org} +\strong{Maintainer}: Tuomas Borman \email{tuomas.v.borman@utu.fi} (\href{https://orcid.org/0000-0002-8563-8884}{ORCID}) Authors: \itemize{ \item Leo Lahti \email{leo.lahti@iki.fi} (\href{https://orcid.org/0000-0001-5537-637X}{ORCID}) + \item Yagmur Simsek \email{yagmur.simsek@hsrw.org} } Other contributors: \itemize{ \item Sudarshan Shetty \email{sudarshanshetty9@gmail.com} [contributor] \item Chouaib Benchraka [contributor] - \item Tuomas Borman \email{tuomas.v.borman@utu.fi} (\href{https://orcid.org/0000-0002-8563-8884}{ORCID}) [contributor] \item Muluh Muluh [contributor] } diff --git a/tests/testthat/test-getBaselineDivergence.R b/tests/testthat/test-getBaselineDivergence.R index 057b9da..e060786 100644 --- a/tests/testthat/test-getBaselineDivergence.R +++ b/tests/testthat/test-getBaselineDivergence.R @@ -4,7 +4,8 @@ test_that("addBaselineDivergence output", { tse <- hitchip1006 tse2 <- addBaselineDivergence( tse, group = "subject", time.col = "time", - name = "divergence_from_baseline", name.time = "time_from_baseline") + name = c("divergence_from_baseline", "time_from_baseline", + "reference_samples")) # Input and output classes should match expect_equal(class(tse), class(tse2)) # A subject to check time difference calculation @@ -29,7 +30,8 @@ test_that("Divergence in baseline other than 0", { inds <- which(tse[["subject"]] == "843")[2:5] tse2 <- addBaselineDivergence( tse[, inds], group = "subject", time.col = "time", - name = "divergence_from_baseline", name.time = "time_from_baseline") + name = c("divergence_from_baseline", "time_from_baseline", + "reference_samples")) time2 <- tse[, inds][["time"]] - min(tse[, inds][["time"]]) time_diff_2 <- tse2[["time_from_baseline"]] expect_true( all(time2 == time_diff_2) ) @@ -46,10 +48,12 @@ test_that("addBaselineDivergence reference", { # Define the baseline sample manually tse3 <- addBaselineDivergence( tse, time.col = "time", group = "subject", reference = "Sample-843", - name.time = "time_from_baseline", name = "divergence_from_baseline") + name = c("divergence_from_baseline", "time_from_baseline", + "reference_samples")) tse4 <- addBaselineDivergence( tse, time.col = "time", group = "subject", reference = "Sample-1075", - name.time = "time_from_baseline", name = "divergence_from_baseline") + name = c("divergence_from_baseline", "time_from_baseline", + "reference_samples")) # Now the times from baseline should be shifted and dissimilarities differ # Sample baseline when the zero time baseline is automatically checked or # manually set @@ -59,14 +63,17 @@ test_that("addBaselineDivergence reference", { tse5 <- addBaselineDivergence( tse[, tse[["subject"]] == "843"], group = "subject", - time.col = "time", name.time = "time_from_baseline", - name = "divergence_from_baseline") + time.col = "time", name = c("divergence_from_baseline", + "time_from_baseline", + "reference_samples")) tse6 <- addBaselineDivergence( tse, group = "subject", time.col = "time", - name.time = "time_from_baseline", name = "divergence_from_baseline") + name = c("divergence_from_baseline", "time_from_baseline", + "reference_samples")) tse7 <- addBaselineDivergence( tse, group = "subject", time.col = "time", reference = "Sample-1075", - name.time = "time_from_baseline", name = "divergence_from_baseline") + name = c("divergence_from_baseline", "time_from_baseline", + "reference_samples")) expect_identical( colData(tse5)["Sample-843", "time_from_baseline"], colData(tse6)["Sample-843", "time_from_baseline"]) @@ -83,14 +90,16 @@ test_that("addBaselineDivergence reference", { "Sample-1075" tse8 <- addBaselineDivergence( tse, group = "subject", time.col = "time", reference = baselines, - name.time = "time_from_baseline", name = "divergence_from_baseline") + name = c("divergence_from_baseline", "time_from_baseline", + "reference_samples")) expect_identical( colData(tse7)["Sample-843", "time_from_baseline"], colData(tse8)["Sample-843", "time_from_baseline"]) tse[["reference_sam"]] <- baselines[ match(tse$subject, names(baselines)) ] res <- addBaselineDivergence( tse, group = "subject", time.col = "time", reference = "reference_sam", - name.time = "time_from_baseline", name = "divergence_from_baseline") + name = c("divergence_from_baseline", "time_from_baseline", + "reference_samples")) ref <- getDivergence(tse, reference = "reference_sam") expect_equal(res[["divergence_from_baseline"]], ref) }) @@ -120,7 +129,7 @@ test_that(".get_reference_samples with different time intervals", { res <- getBaselineDivergence( tse, group = "subject", time.col = "time", assay.type = "counts", method = "euclidean") - expect_equal(colData(tse)[, c("divergence", "time_diff")], res) + expect_equal(colData(tse)[, c("divergence", "time_diff", "ref_samples")], res) }) # Basic SummarizedExperiment for testing @@ -164,8 +173,8 @@ test_that("addBaselineDivergence adds columns to colData", { # Custom column naming test for addBaselineDivergence test_that("addBaselineDivergence handles custom column names", { se_result <- addBaselineDivergence( - se, time.col = "time", name = "custom_div", - name.time = "custom_time_diff") + se, time.col = "time", name = c("custom_div", "custom_time_diff", + "custom_ref_samples")) expect_true("custom_div" %in% colnames(colData(se_result))) expect_true("custom_time_diff" %in% colnames(colData(se_result))) }) @@ -200,11 +209,16 @@ test_that(".get_time_difference calculates correct time diff", { test_that(".convert_divergence_to_df formats correctly", { divergence <- c(0.1, 0.2, 0.3, 0, NA, 2) time_diff <- c(0, 1, 2, 1, 0, NA) + reference <- c("sample1", "sample2", + "sample3", "sample4", "sample5", "sample6") df <- .convert_divergence_to_df( - se, divergence, time_diff, name = "test_div", - name.time = "test_time_diff") + se, divergence, reference, time_diff, name = c("test_div", + "test_time_diff", + "test_reference_samples")) expect_s4_class(df, "DataFrame") - expect_equal(colnames(df), c("test_div", "test_time_diff")) + expect_equal(colnames(df), c("test_div", + "test_time_diff", + "test_reference_samples")) expect_equal(df$test_div, divergence) expect_equal(df$test_time_diff, time_diff) }) @@ -235,9 +249,12 @@ test_that("addBaselineDivergence with custom reference sample", { test_that(".convert_divergence_to_df with NA divergence values", { divergence <- c(0.1, NA, 0.3, NA, 0.5, 0.6) time_diff <- c(0, 1, 2, 1, 0, NA) + reference <- c("sample1", "sample2", + "sample3", "sample4", "sample5", "sample6") df <- .convert_divergence_to_df( - se, divergence, time_diff, name = "test_div", - name.time = "test_time_diff") + se, divergence, reference, time_diff, name = c("test_div", + "test_time_diff", + "test_reference_samples")) expect_s4_class(df, "DataFrame") expect_true(all(is.na(df$test_div[is.na(divergence)]))) }) diff --git a/tests/testthat/test-getStepwiseDivergence.R b/tests/testthat/test-getStepwiseDivergence.R index 85c3e1e..e328a7e 100644 --- a/tests/testthat/test-getStepwiseDivergence.R +++ b/tests/testthat/test-getStepwiseDivergence.R @@ -5,7 +5,8 @@ test_that("Basic functionality of addStepwiseDivergence", { tse2 <- addStepwiseDivergence( tse, group = "subject", time.interval = 1, time.col = "time", assay.type="counts", dis.fun = vegan::vegdist, method = "bray", - name.time = "time_difference") + name = c("divergence", + "time_diff", "ref_samples")) expect_equal(class(tse), class(tse2)) }) @@ -16,7 +17,8 @@ test_that("Adding new colData field with existing name generates warning", { tse[["time_difference"]] <- NA expect_warning(addStepwiseDivergence( tse, group = "subject", time.interval = 1, time.col = "time", - name.time = "time_difference")) + name = c("divergence", + "time_difference", "ref_samples"))) }) # Test: Time difference calculation for a specific subject @@ -26,7 +28,8 @@ test_that("Time difference calculation is correct for a specific subject", { tse2 <- addStepwiseDivergence( tse, group = "subject", time.interval = 1, time.col = "time", assay.type="counts", dis.fun = vegan::vegdist, method = "bray", - name.time = "time_difference") + name = c("divergence", + "time_difference", "ref_samples")) obs_diff <- colData(tse2)[ which(tse2[["subject"]] == "843"), "time_difference"] exp_diff <- c(NA, diff(colData(tse)[ @@ -41,7 +44,8 @@ test_that("addStepwiseDivergence with n > 1 calculates divergences correctly", { tse2 <- addStepwiseDivergence( tse, group = "subject", time.interval = 2, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", - name.time = "time_difference") + name = c("divergence", + "time_difference", "ref_samples")) time_interval <- 2 time <- colData(tse2)[which(tse2[["subject"]] == "843"), "time"] time_diff <- colData(tse2)[which(tse2[["subject"]] == "843"), "time_difference"] @@ -57,7 +61,8 @@ test_that("Interval check for divergence calculation", { tse2 <- addStepwiseDivergence( tse, group = "subject", time.interval = 2, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", - name.time = "time_difference") + name = c("divergence", + "time_difference", "ref_samples")) time <- colData(tse2)[which(tse2[["subject"]] == "843"), "time"] calculated_diff <- time[(1 + 2):length(time)] - time[seq_len(length(time) - 2)] @@ -75,8 +80,8 @@ test_that("Single time point results in NA divergence values", { tse2 <- addStepwiseDivergence( tse2, group = "subject", time.interval = 1, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", - name = "time_divergence", - name.time = "time_difference") + name = c("time_divergence", + "time_diff", "ref_samples")) expect_true(all(is.na(colData(tse2)[ which(duplicated(tse2[["subject"]]) == FALSE), "time_divergence"]))) @@ -89,11 +94,13 @@ test_that("Comparing vegan distances (bray vs euclidean)", { tse2 <- addStepwiseDivergence( tse, group = "subject", time.interval = 1, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", - name.time = "timedifference", name = "timedivergence") + name = c("timedivergence", + "timedifference", "ref_samples")) tse2 <- addStepwiseDivergence( tse2, group = "subject", time.interval = 1, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "euclidean", - name.time = "timedifference2", name = "timedivergence2") + name = c("timedivergence2", + "timedifference2", "ref_samples")) expect_true(identical(tse2$timedifference, tse2$timedifference2)) expect_true(!identical(tse2$timedivergence, tse2$timedivergence2)) }) @@ -108,7 +115,8 @@ test_that("AltExp functionality in addStepwiseDivergence", { altexp = "Family") altExp(tse, "Family_test") <- addStepwiseDivergence( altExp(tse, "Family"), group = "subject", time.interval = 1, - time.col = "time", name.time = "timedifference", name = "timedivergence") + time.col = "time", name = c("timedivergence", + "timedifference", "ref_samples")) expect_equal( altExp(tse, "Family")$time_diff, altExp(tse, "Family_test")$timedifference) @@ -176,7 +184,7 @@ test_that(".get_reference_samples with different time intervals", { res <- getStepwiseDivergence( tse, group = "subject", time.interval = 2, time.col = "time", assay.type = "counts", method = "euclidean") - expect_equal(colData(tse)[, c("divergence", "time_diff")], res) + expect_equal(colData(tse)[, c("divergence", "time_diff", "ref_samples")], res) }) # Basic SummarizedExperiment for testing @@ -201,7 +209,7 @@ test_that("getStepwiseDivergence input validations", { test_that("getStepwiseDivergence dissimilarity calculation", { result <- getStepwiseDivergence(se, time.col = "time", method = "bray") expect_s4_class(result, "DataFrame") - expect_true(all(c("divergence", "time_diff") %in% colnames(result))) + expect_true(all(c("divergence", "time_diff", "ref_samples") %in% colnames(result))) }) # Correct time difference calculation test @@ -220,8 +228,8 @@ test_that("addStepwiseDivergence adds columns to colData", { # Custom column naming test for addStepwiseDivergence test_that("addStepwiseDivergence handles custom column names", { se_result <- addStepwiseDivergence( - se, time.col = "time", name = "custom_div", - name.time = "custom_time_diff") + se, time.col = "time", name = c("custom_div", + "custom_time_diff", "ref_samples")) expect_true("custom_div" %in% colnames(colData(se_result))) expect_true("custom_time_diff" %in% colnames(colData(se_result))) }) diff --git a/vignettes/articles/minimalgut.Rmd b/vignettes/articles/minimalgut.Rmd index bee4822..7dd4cac 100644 --- a/vignettes/articles/minimalgut.Rmd +++ b/vignettes/articles/minimalgut.Rmd @@ -133,8 +133,7 @@ tse <- addStepwiseDivergence( group = "StudyIdentifier", time.interval = 1, time.col = "Time.hr", - name = "divergence_from_previous_step", - name.time = "time_from_previous_step" + name = c("divergence_from_previous_step", "time_from_previous_step", "reference_samples") ) ``` diff --git a/vignettes/miaTime.Rmd b/vignettes/miaTime.Rmd index 9524e70..49efd4b 100755 --- a/vignettes/miaTime.Rmd +++ b/vignettes/miaTime.Rmd @@ -74,7 +74,7 @@ data(hitchip1006) tse <- hitchip1006 res <- getBaselineDivergence( - tse, time.col = "time", group = "sample", name = "baseline") + tse, time.col = "time", group = "sample", name = c("baseline", "time_diff", "ref_samples")) res |> head() ``` From 0d1373bb27a6ed6100a73bd87c81a52a107a5f6e Mon Sep 17 00:00:00 2001 From: Daena Rys Date: Mon, 25 Nov 2024 14:02:07 +0200 Subject: [PATCH 2/3] add changes to refsam Signed-off-by: Daena Rys --- R/getBaselineDivergence.R | 28 ++++---- R/getStepwiseDivergence.R | 7 +- R/utils.R | 11 ++- man/addBaselineDivergence.Rd | 5 +- man/addStepwiseDivergence.Rd | 3 +- tests/testthat/test-getBaselineDivergence.R | 77 +++++++++++++-------- tests/testthat/test-getStepwiseDivergence.R | 69 +++++++++--------- vignettes/articles/minimalgut.Rmd | 3 +- vignettes/miaTime.Rmd | 3 +- 9 files changed, 122 insertions(+), 84 deletions(-) diff --git a/R/getBaselineDivergence.R b/R/getBaselineDivergence.R index 951a4cf..bfad68a 100644 --- a/R/getBaselineDivergence.R +++ b/R/getBaselineDivergence.R @@ -55,7 +55,8 @@ #' (Default: \code{NULL}) #' #' @param name \code{Character vector}. Specifies a column name for storing -#' divergence results. (Default: \code{"divergence"}) +#' divergence results. +#' (Default: \code{c("divergence", "time_diff", "ref_samples")}) #' #' @param ... Optional arguments passed into #' \code{\link[mia:addDivergence]{mia::addDivergence()}}. @@ -84,7 +85,7 @@ #' group = "subject", #' time.col = "time", #' name = c("divergence_from_baseline", -#' "time_from_baseline", "reference_samples"), +#' "time_from_baseline", "reference_samples"), #' assay.type = "relabundance", #' method = "bray") #' @@ -150,7 +151,7 @@ setMethod("getBaselineDivergence", signature = c(x = "SummarizedExperiment"), reference <- args[["reference"]] time_res <- .get_time_difference(x, time.col, reference) # Create a DF to return - res <- .convert_divergence_to_df(x, res, reference, time_res, ...) + res <- .convert_divergence_to_df(x, res, time_res, reference, ...) return(res) } ) @@ -158,8 +159,9 @@ setMethod("getBaselineDivergence", signature = c(x = "SummarizedExperiment"), #' @rdname addBaselineDivergence #' @export setMethod("addBaselineDivergence", signature = c(x = "SummarizedExperiment"), - function(x, name = c("divergence", - "time_diff", "ref_samples"), ...){ + function(x, name = c("divergence", "time_diff", "ref_samples"), + ...){ + ######################################################################## # Calculate divergence res <- getBaselineDivergence(x, ...) # Add to colData @@ -315,7 +317,7 @@ setMethod("addBaselineDivergence", signature = c(x = "SummarizedExperiment"), return(res) } -# This function get time difference between a sample and its referene sample +# This function get time difference between a sample and its reference sample .get_time_difference <- function(x, time.col, reference){ # Get timepoints time_point <- x[[time.col]] @@ -327,16 +329,12 @@ setMethod("addBaselineDivergence", signature = c(x = "SummarizedExperiment"), } # This function converts time divergence results to DF object -.convert_divergence_to_df <- function( - x, res, reference, time_res, name = c("divergence", - "time_diff", "ref_samples"), ...){ +.convert_divergence_to_df <- function( x, res, time_res, reference, + name = c("divergence", "time_diff", "ref_samples"), + ...){ # Validate 'name' param - if (length(name) != 3) { - stop("'name' must be a vector of length 3: - c('divergence', 'time_diff', 'ref_samples')", call. = FALSE) - } - temp <- .check_input(name[1:3], list("character vector")) - df <- DataFrame(res, time_res, reference, row.names = colnames(x)) + temp <- .check_input(name, list("character vector"), length = 3) + df <- DataFrame(res, time_res, x[[reference]], row.names = colnames(x)) colnames(df) <- name return(df) } diff --git a/R/getStepwiseDivergence.R b/R/getStepwiseDivergence.R index f0e6565..9e1d4cc 100644 --- a/R/getStepwiseDivergence.R +++ b/R/getStepwiseDivergence.R @@ -102,7 +102,7 @@ setMethod("getStepwiseDivergence", signature = c(x = "ANY"), reference <- args[["reference"]] time_res <- .get_time_difference(x, time.col, reference) # Create a DF to return - res <- .convert_divergence_to_df(x, res, reference, time_res, ...) + res <- .convert_divergence_to_df(x, res, time_res, reference, ...) return(res) } ) @@ -110,8 +110,9 @@ setMethod("getStepwiseDivergence", signature = c(x = "ANY"), #' @rdname addStepwiseDivergence #' @export setMethod("addStepwiseDivergence", signature = c(x = "SummarizedExperiment"), - function(x, name = c("divergence", - "time_diff", "ref_samples"), ...){ + function(x, name = c("divergence", "time_diff", "ref_samples"), + ...){ + ######################################################################## # Calculate divergence res <- getStepwiseDivergence(x, ...) # Add to colData diff --git a/R/utils.R b/R/utils.R index 6a4d25b..61201ad 100644 --- a/R/utils.R +++ b/R/utils.R @@ -6,7 +6,7 @@ # Borrowed from HoloFoodR. .check_input <- function( variable, supported_class, supported_values = NULL, limits = NULL, - variable_name = .get_name_in_parent(variable)){ + length = NULL, variable_name = .get_name_in_parent(variable)){ # Convert supported classes to character classes_char <- lapply(supported_class, function(class){ if( is.null(class) ){ @@ -54,6 +54,11 @@ msg <- paste0(msg, ")") } + # If length was provided + if( !is.null(length) ){ + msg <- paste0(msg, " The length must be ", length, ".") + } + # List all the input types. Run the check if the variable must be that type. # If correct type was found, change the result to TRUE. input_correct <- FALSE @@ -128,6 +133,10 @@ input_correct <- FALSE } } + # Check length if provided + if( !is.null(length) && length(variable) != length ){ + input_correct <- FALSE + } # Give error if variable was not correct type if( !input_correct ){ stop(msg, call. = FALSE) diff --git a/man/addBaselineDivergence.Rd b/man/addBaselineDivergence.Rd index 880b1ab..ed798f9 100644 --- a/man/addBaselineDivergence.Rd +++ b/man/addBaselineDivergence.Rd @@ -54,7 +54,8 @@ Method is passed to the function that is specified by \code{dis.fun}. (Default: \code{"bray"})} \item{name}{\code{Character vector}. Specifies a column name for storing -divergence results. (Default: \code{"divergence"})} +divergence results. +(Default: \code{c("divergence", "time_diff", "ref_samples")})} } \value{ \code{getBaselineDivergence} returns \code{DataFrame} object @@ -108,7 +109,7 @@ tse <- addBaselineDivergence( group = "subject", time.col = "time", name = c("divergence_from_baseline", - "time_from_baseline", "reference_samples"), + "time_from_baseline", "reference_samples"), assay.type = "relabundance", method = "bray") diff --git a/man/addStepwiseDivergence.Rd b/man/addStepwiseDivergence.Rd index b7e9845..20f948f 100644 --- a/man/addStepwiseDivergence.Rd +++ b/man/addStepwiseDivergence.Rd @@ -55,7 +55,8 @@ Method is passed to the function that is specified by \code{dis.fun}. (Default: \code{"bray"})} \item{name}{\code{Character vector}. Specifies a column name for storing -divergence results. (Default: \code{"divergence"})} +divergence results. +(Default: \code{c("divergence", "time_diff", "ref_samples")})} } \value{ \code{getStepwiseDivergence} returns \code{DataFrame} object diff --git a/tests/testthat/test-getBaselineDivergence.R b/tests/testthat/test-getBaselineDivergence.R index e060786..a922805 100644 --- a/tests/testthat/test-getBaselineDivergence.R +++ b/tests/testthat/test-getBaselineDivergence.R @@ -5,7 +5,7 @@ test_that("addBaselineDivergence output", { tse2 <- addBaselineDivergence( tse, group = "subject", time.col = "time", name = c("divergence_from_baseline", "time_from_baseline", - "reference_samples")) + "reference_samples")) # Input and output classes should match expect_equal(class(tse), class(tse2)) # A subject to check time difference calculation @@ -31,7 +31,7 @@ test_that("Divergence in baseline other than 0", { tse2 <- addBaselineDivergence( tse[, inds], group = "subject", time.col = "time", name = c("divergence_from_baseline", "time_from_baseline", - "reference_samples")) + "reference_samples")) time2 <- tse[, inds][["time"]] - min(tse[, inds][["time"]]) time_diff_2 <- tse2[["time_from_baseline"]] expect_true( all(time2 == time_diff_2) ) @@ -49,11 +49,11 @@ test_that("addBaselineDivergence reference", { tse3 <- addBaselineDivergence( tse, time.col = "time", group = "subject", reference = "Sample-843", name = c("divergence_from_baseline", "time_from_baseline", - "reference_samples")) + "reference_samples")) tse4 <- addBaselineDivergence( tse, time.col = "time", group = "subject", reference = "Sample-1075", name = c("divergence_from_baseline", "time_from_baseline", - "reference_samples")) + "reference_samples")) # Now the times from baseline should be shifted and dissimilarities differ # Sample baseline when the zero time baseline is automatically checked or # manually set @@ -69,11 +69,11 @@ test_that("addBaselineDivergence reference", { tse6 <- addBaselineDivergence( tse, group = "subject", time.col = "time", name = c("divergence_from_baseline", "time_from_baseline", - "reference_samples")) + "reference_samples")) tse7 <- addBaselineDivergence( tse, group = "subject", time.col = "time", reference = "Sample-1075", name = c("divergence_from_baseline", "time_from_baseline", - "reference_samples")) + "reference_samples")) expect_identical( colData(tse5)["Sample-843", "time_from_baseline"], colData(tse6)["Sample-843", "time_from_baseline"]) @@ -91,7 +91,7 @@ test_that("addBaselineDivergence reference", { tse8 <- addBaselineDivergence( tse, group = "subject", time.col = "time", reference = baselines, name = c("divergence_from_baseline", "time_from_baseline", - "reference_samples")) + "reference_samples")) expect_identical( colData(tse7)["Sample-843", "time_from_baseline"], colData(tse8)["Sample-843", "time_from_baseline"]) @@ -99,7 +99,7 @@ test_that("addBaselineDivergence reference", { res <- addBaselineDivergence( tse, group = "subject", time.col = "time", reference = "reference_sam", name = c("divergence_from_baseline", "time_from_baseline", - "reference_samples")) + "reference_samples")) ref <- getDivergence(tse, reference = "reference_sam") expect_equal(res[["divergence_from_baseline"]], ref) }) @@ -129,21 +129,26 @@ test_that(".get_reference_samples with different time intervals", { res <- getBaselineDivergence( tse, group = "subject", time.col = "time", assay.type = "counts", method = "euclidean") - expect_equal(colData(tse)[, c("divergence", "time_diff", "ref_samples")], res) + expect_equal(colData(tse)[, c("divergence", + "time_diff", + "ref_samples")], res) }) # Basic SummarizedExperiment for testing col_data <- DataFrame( time = c(0, 1, 2, 1, 2, 0), group = c("A", "A", "A", "B", "B", "B"), - row.names = c("Sample1", "Sample2", "Sample3", "Sample4", "Sample5", "Sample6")) + row.names = c("Sample1", "Sample2", + "Sample3", "Sample4", "Sample5", "Sample6")) count_data <- matrix(c(10, 20, 30, 40, 50, 60), ncol = 6, byrow = TRUE) -se <- SummarizedExperiment(assays = list(counts = count_data), colData = col_data) +se <- SummarizedExperiment(assays = list(counts = count_data), + colData = col_data) # Input validation for getBaselineDivergence test_that("getBaselineDivergence input validations", { expect_error(getBaselineDivergence(se, time.col = "nonexistent")) - expect_error(getBaselineDivergence(se, time.col = "time", assay.type = "unknown")) + expect_error(getBaselineDivergence(se, time.col = "time", + assay.type = "unknown")) expect_error(getBaselineDivergence(se, group = "nonexistent")) expect_error(getBaselineDivergence(se, reference = "nonexistent")) expect_error(getBaselineDivergence(se, name = "nonexistent")) @@ -173,8 +178,9 @@ test_that("addBaselineDivergence adds columns to colData", { # Custom column naming test for addBaselineDivergence test_that("addBaselineDivergence handles custom column names", { se_result <- addBaselineDivergence( - se, time.col = "time", name = c("custom_div", "custom_time_diff", - "custom_ref_samples")) + se, time.col = "time", + name = c("custom_div", "custom_time_diff", + "custom_ref_samples")) expect_true("custom_div" %in% colnames(colData(se_result))) expect_true("custom_time_diff" %in% colnames(colData(se_result))) }) @@ -183,7 +189,9 @@ test_that("addBaselineDivergence handles custom column names", { test_that(".add_reference_samples_to_coldata assigns correct baselines", { res <- .add_reference_samples_to_coldata( se, time.col = "time", group = "group") - expect_true("temporal_reference_for_divergence" %in% colnames(colData(res[[1]]))) + expect_true( + "temporal_reference_for_divergence" %in% + colnames(colData(res[[1]]))) }) # Reference sample assignments @@ -207,18 +215,24 @@ test_that(".get_time_difference calculates correct time diff", { # Convert divergence to DataFrame test_that(".convert_divergence_to_df formats correctly", { + col_data <- DataFrame( + reference <- c("sample1", "sample2", "sample3", "sample4", + "sample5", "sample6") + ) + colnames(col_data) <- c("reference") divergence <- c(0.1, 0.2, 0.3, 0, NA, 2) time_diff <- c(0, 1, 2, 1, 0, NA) - reference <- c("sample1", "sample2", - "sample3", "sample4", "sample5", "sample6") + se <- SummarizedExperiment( + assays = list(), + colData = col_data + ) + reference <- "reference" df <- .convert_divergence_to_df( - se, divergence, reference, time_diff, name = c("test_div", - "test_time_diff", - "test_reference_samples")) + se, divergence, time_diff, reference, + name = c("test_div", "test_time_diff", "test_reference_samples")) expect_s4_class(df, "DataFrame") - expect_equal(colnames(df), c("test_div", - "test_time_diff", - "test_reference_samples")) + expect_equal(colnames(df), + c("test_div", "test_time_diff", "test_reference_samples")) expect_equal(df$test_div, divergence) expect_equal(df$test_time_diff, time_diff) }) @@ -247,14 +261,21 @@ test_that("addBaselineDivergence with custom reference sample", { # Test that postprocessing works with NA values test_that(".convert_divergence_to_df with NA divergence values", { + col_data <- DataFrame( + reference <- c("sample1", "sample2", "sample3", "sample4", + "sample5", "sample6") + ) divergence <- c(0.1, NA, 0.3, NA, 0.5, 0.6) time_diff <- c(0, 1, 2, 1, 0, NA) - reference <- c("sample1", "sample2", - "sample3", "sample4", "sample5", "sample6") + colnames(col_data) <- c("reference") + se <- SummarizedExperiment( + assays = list(), + colData = col_data + ) + reference <- "reference" df <- .convert_divergence_to_df( - se, divergence, reference, time_diff, name = c("test_div", - "test_time_diff", - "test_reference_samples")) + se, divergence, time_diff, reference, + name = c("test_div", "test_time_diff", "test_reference_samples")) expect_s4_class(df, "DataFrame") expect_true(all(is.na(df$test_div[is.na(divergence)]))) }) diff --git a/tests/testthat/test-getStepwiseDivergence.R b/tests/testthat/test-getStepwiseDivergence.R index e328a7e..cefa7c9 100644 --- a/tests/testthat/test-getStepwiseDivergence.R +++ b/tests/testthat/test-getStepwiseDivergence.R @@ -5,8 +5,7 @@ test_that("Basic functionality of addStepwiseDivergence", { tse2 <- addStepwiseDivergence( tse, group = "subject", time.interval = 1, time.col = "time", assay.type="counts", dis.fun = vegan::vegdist, method = "bray", - name = c("divergence", - "time_diff", "ref_samples")) + name = c("divergence", "time_diff", "ref_samples")) expect_equal(class(tse), class(tse2)) }) @@ -17,8 +16,7 @@ test_that("Adding new colData field with existing name generates warning", { tse[["time_difference"]] <- NA expect_warning(addStepwiseDivergence( tse, group = "subject", time.interval = 1, time.col = "time", - name = c("divergence", - "time_difference", "ref_samples"))) + name = c("divergence", "time_difference", "ref_samples"))) }) # Test: Time difference calculation for a specific subject @@ -26,10 +24,9 @@ test_that("Time difference calculation is correct for a specific subject", { data(hitchip1006) tse <- hitchip1006 tse2 <- addStepwiseDivergence( - tse, group = "subject", time.interval = 1, time.col = "time", - assay.type="counts", dis.fun = vegan::vegdist, method = "bray", - name = c("divergence", - "time_difference", "ref_samples")) + tse, group = "subject", time.interval = 1, time.col = "time", + assay.type="counts", dis.fun = vegan::vegdist, method = "bray", + name = c("divergence", "time_difference", "ref_samples")) obs_diff <- colData(tse2)[ which(tse2[["subject"]] == "843"), "time_difference"] exp_diff <- c(NA, diff(colData(tse)[ @@ -44,11 +41,11 @@ test_that("addStepwiseDivergence with n > 1 calculates divergences correctly", { tse2 <- addStepwiseDivergence( tse, group = "subject", time.interval = 2, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", - name = c("divergence", - "time_difference", "ref_samples")) + name = c("divergence", "time_difference", "ref_samples")) time_interval <- 2 time <- colData(tse2)[which(tse2[["subject"]] == "843"), "time"] - time_diff <- colData(tse2)[which(tse2[["subject"]] == "843"), "time_difference"] + time_diff <- colData(tse2)[which(tse2[["subject"]] == "843"), + "time_difference"] divergence_number <- length(time) - time_interval divergence_calculated <- length(which(!is.na(time_diff) == TRUE)) expect_equal(divergence_number, divergence_calculated) @@ -59,10 +56,9 @@ test_that("Interval check for divergence calculation", { data(hitchip1006) tse <- hitchip1006 tse2 <- addStepwiseDivergence( - tse, group = "subject", time.interval = 2, time.col = "time", - assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", - name = c("divergence", - "time_difference", "ref_samples")) + tse, group = "subject", time.interval = 2, time.col = "time", + assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", + name = c("divergence", "time_difference", "ref_samples")) time <- colData(tse2)[which(tse2[["subject"]] == "843"), "time"] calculated_diff <- time[(1 + 2):length(time)] - time[seq_len(length(time) - 2)] @@ -80,8 +76,7 @@ test_that("Single time point results in NA divergence values", { tse2 <- addStepwiseDivergence( tse2, group = "subject", time.interval = 1, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", - name = c("time_divergence", - "time_diff", "ref_samples")) + name = c("time_divergence", "time_diff", "ref_samples")) expect_true(all(is.na(colData(tse2)[ which(duplicated(tse2[["subject"]]) == FALSE), "time_divergence"]))) @@ -94,13 +89,11 @@ test_that("Comparing vegan distances (bray vs euclidean)", { tse2 <- addStepwiseDivergence( tse, group = "subject", time.interval = 1, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "bray", - name = c("timedivergence", - "timedifference", "ref_samples")) + name = c("timedivergence", "timedifference", "ref_samples")) tse2 <- addStepwiseDivergence( tse2, group = "subject", time.interval = 1, time.col = "time", assay.type = "counts", dis.fun = vegan::vegdist, method = "euclidean", - name = c("timedivergence2", - "timedifference2", "ref_samples")) + name = c("timedivergence2", "timedifference2", "ref_samples")) expect_true(identical(tse2$timedifference, tse2$timedifference2)) expect_true(!identical(tse2$timedivergence, tse2$timedivergence2)) }) @@ -113,10 +106,11 @@ test_that("AltExp functionality in addStepwiseDivergence", { tse <- addStepwiseDivergence( tse, group = "subject", time.interval = 1, time.col = "time", altexp = "Family") + altExp(tse, "Family_test") <- addStepwiseDivergence( - altExp(tse, "Family"), group = "subject", time.interval = 1, - time.col = "time", name = c("timedivergence", - "timedifference", "ref_samples")) + altExp(tse, "Family"), group = "subject", time.interval = 1, + time.col = "time", + name = c("timedivergence", "timedifference", "ref_samples")) expect_equal( altExp(tse, "Family")$time_diff, altExp(tse, "Family_test")$timedifference) @@ -184,21 +178,26 @@ test_that(".get_reference_samples with different time intervals", { res <- getStepwiseDivergence( tse, group = "subject", time.interval = 2, time.col = "time", assay.type = "counts", method = "euclidean") - expect_equal(colData(tse)[, c("divergence", "time_diff", "ref_samples")], res) + expect_equal(colData(tse)[, c("divergence", + "time_diff", + "ref_samples")], res) }) # Basic SummarizedExperiment for testing col_data <- DataFrame( time = c(0, 1, 2, 1, 2, 0), group = c("A", "A", "A", "B", "B", "B"), - row.names = c("Sample1", "Sample2", "Sample3", "Sample4", "Sample5", "Sample6")) + row.names = c("Sample1", "Sample2", "Sample3", "Sample4", + "Sample5", "Sample6")) count_data <- matrix(c(10, 20, 30, 40, 50, 60), ncol = 6, byrow = TRUE) -se <- SummarizedExperiment(assays = list(counts = count_data), colData = col_data) +se <- SummarizedExperiment(assays = list(counts = count_data), + colData = col_data) # Input validation for getStepwiseDivergence test_that("getStepwiseDivergence input validations", { expect_error(getStepwiseDivergence(se, time.col = "nonexistent")) - expect_error(getStepwiseDivergence(se, time.col = "time", assay.type = "unknown")) + expect_error(getStepwiseDivergence(se, time.col = "time", + assay.type = "unknown")) expect_error(getStepwiseDivergence(se, group = "nonexistent")) expect_error(getStepwiseDivergence(se, reference = "nonexistent")) expect_error(getStepwiseDivergence(se, name = "nonexistent")) @@ -209,7 +208,9 @@ test_that("getStepwiseDivergence input validations", { test_that("getStepwiseDivergence dissimilarity calculation", { result <- getStepwiseDivergence(se, time.col = "time", method = "bray") expect_s4_class(result, "DataFrame") - expect_true(all(c("divergence", "time_diff", "ref_samples") %in% colnames(result))) + expect_true( + all(c("divergence", "time_diff", "ref_samples") %in% + colnames(result))) }) # Correct time difference calculation test @@ -228,8 +229,9 @@ test_that("addStepwiseDivergence adds columns to colData", { # Custom column naming test for addStepwiseDivergence test_that("addStepwiseDivergence handles custom column names", { se_result <- addStepwiseDivergence( - se, time.col = "time", name = c("custom_div", - "custom_time_diff", "ref_samples")) + se, time.col = "time", + name = c("custom_div", "custom_time_diff", "ref_samples")) + # Test expect_true("custom_div" %in% colnames(colData(se_result))) expect_true("custom_time_diff" %in% colnames(colData(se_result))) }) @@ -238,7 +240,9 @@ test_that("addStepwiseDivergence handles custom column names", { test_that(".add_reference_samples_to_coldata assigns correct baselines", { res <- .add_reference_samples_to_coldata( se, time.col = "time", group = "group") - expect_true("temporal_reference_for_divergence" %in% colnames(colData(res[[1]]))) + expect_true( + "temporal_reference_for_divergence" %in% + colnames(colData(res[[1]]))) }) # Reference sample assignments @@ -270,6 +274,7 @@ test_that("getStepwiseDivergence unsupported method", { test_that("addStepwiseDivergence with custom reference sample", { res <- getStepwiseDivergence( se, time.col = "time", group = "group") + # se[["reference"]] <- c(NA, "Sample1", "Sample2", "Sample6", "Sample4", NA) time_diff <- c(NA, 1, 1, 1, 1, NA) ref <- getDivergence(se, reference = "reference") diff --git a/vignettes/articles/minimalgut.Rmd b/vignettes/articles/minimalgut.Rmd index 7dd4cac..f0f58ab 100644 --- a/vignettes/articles/minimalgut.Rmd +++ b/vignettes/articles/minimalgut.Rmd @@ -133,7 +133,8 @@ tse <- addStepwiseDivergence( group = "StudyIdentifier", time.interval = 1, time.col = "Time.hr", - name = c("divergence_from_previous_step", "time_from_previous_step", "reference_samples") + name = c("divergence_from_previous_step", + "time_from_previous_step", "reference_samples") ) ``` diff --git a/vignettes/miaTime.Rmd b/vignettes/miaTime.Rmd index 49efd4b..6f88a61 100755 --- a/vignettes/miaTime.Rmd +++ b/vignettes/miaTime.Rmd @@ -74,7 +74,8 @@ data(hitchip1006) tse <- hitchip1006 res <- getBaselineDivergence( - tse, time.col = "time", group = "sample", name = c("baseline", "time_diff", "ref_samples")) + tse, time.col = "time", group = "sample", + name = c("baseline", "time_diff", "ref_samples")) res |> head() ``` From 781d01f3a7b3f6b0f007bf071b76ea7f70d529fe Mon Sep 17 00:00:00 2001 From: TuomasBorman Date: Mon, 16 Dec 2024 15:05:10 +0200 Subject: [PATCH 3/3] up --- R/getBaselineDivergence.R | 12 ++++++------ R/getStepwiseDivergence.R | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/R/getBaselineDivergence.R b/R/getBaselineDivergence.R index bfad68a..2945aa3 100644 --- a/R/getBaselineDivergence.R +++ b/R/getBaselineDivergence.R @@ -159,9 +159,8 @@ setMethod("getBaselineDivergence", signature = c(x = "SummarizedExperiment"), #' @rdname addBaselineDivergence #' @export setMethod("addBaselineDivergence", signature = c(x = "SummarizedExperiment"), - function(x, name = c("divergence", "time_diff", "ref_samples"), - ...){ - ######################################################################## + function( + x, name = c("divergence", "time_diff", "ref_samples"), ...){ # Calculate divergence res <- getBaselineDivergence(x, ...) # Add to colData @@ -329,11 +328,12 @@ setMethod("addBaselineDivergence", signature = c(x = "SummarizedExperiment"), } # This function converts time divergence results to DF object -.convert_divergence_to_df <- function( x, res, time_res, reference, - name = c("divergence", "time_diff", "ref_samples"), - ...){ +.convert_divergence_to_df <- function( + x, res, time_res, reference, + name = c("divergence", "time_diff", "ref_samples"), ...){ # Validate 'name' param temp <- .check_input(name, list("character vector"), length = 3) + # df <- DataFrame(res, time_res, x[[reference]], row.names = colnames(x)) colnames(df) <- name return(df) diff --git a/R/getStepwiseDivergence.R b/R/getStepwiseDivergence.R index 9e1d4cc..6750d0a 100644 --- a/R/getStepwiseDivergence.R +++ b/R/getStepwiseDivergence.R @@ -110,9 +110,8 @@ setMethod("getStepwiseDivergence", signature = c(x = "ANY"), #' @rdname addStepwiseDivergence #' @export setMethod("addStepwiseDivergence", signature = c(x = "SummarizedExperiment"), - function(x, name = c("divergence", "time_diff", "ref_samples"), - ...){ - ######################################################################## + function( + x, name = c("divergence", "time_diff", "ref_samples"), ...){ # Calculate divergence res <- getStepwiseDivergence(x, ...) # Add to colData