diff --git a/DESCRIPTION b/DESCRIPTION index 1c77ab1..6dbd6d8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,11 +11,11 @@ Authors@R: c( person("Vincent J", "Carey", , , c("aut", "ctb")), person("Levi", "Waldron", , "lwaldron.research@gmail.com", "aut"), person("MultiAssay", "SIG", , "biocmultiassay@googlegroups.com", "ctb")) -Description: MultiAssayExperiment harmonizes data management of multiple - experimental assays performed on an overlapping set of specimens. It - provides a familiar Bioconductor user experience by extending concepts - from SummarizedExperiment, supporting an open-ended mix of standard - data classes for individual assays, and allowing subsetting by genomic +Description: Harmonize data management of multiple experimental assays + performed on an overlapping set of specimens. It provides a familiar + Bioconductor user experience by extending concepts from + SummarizedExperiment, supporting an open-ended mix of standard data + classes for individual assays, and allowing subsetting by genomic ranges or rownames. Facilities are provided for reshaping data into wide and long formats for adaptability to graphing and downstream analysis. @@ -33,7 +33,6 @@ Imports: IRanges, methods, S4Vectors (>= 0.23.19), - stats, tidyr, utils Suggests: @@ -43,6 +42,7 @@ Suggests: maftools (>= 2.7.10), R.rsp, RaggedExperiment, + reshape2, rmarkdown, survival, survminer, diff --git a/R/MultiAssayExperiment-helpers.R b/R/MultiAssayExperiment-helpers.R index 2f50964..be28e4d 100644 --- a/R/MultiAssayExperiment-helpers.R +++ b/R/MultiAssayExperiment-helpers.R @@ -340,27 +340,20 @@ setMethod("mergeReplicates", "ANY", .longFormatANY <- function(object, i) { rowNAMES <- rownames(object) - nullROWS <- is.null(rowNAMES) - if (nullROWS) - rowNAMES <- as.character(seq_len(nrow(object))) + if (is.null(rowNAMES)) + rowNames <- as.character(seq_len(nrow(object))) if (is(object, "ExpressionSet")) object <- Biobase::exprs(object) if (is(object, "SummarizedExperiment") || is(object, "RaggedExperiment")) object <- assay(object, i = i) - if (is(object, "matrix")) - object <- as.data.frame(object) - - ## use stats::reshape instead of reshape2::melt - if (nullROWS) - rownames(object) <- rowNAMES - object <- stats::reshape(object, idvar = "rowname", - ids = rownames(object), times = names(object), - timevar = "colname", varying = list(names(object)), - direction = "long", v.names = "value") - ## Reshape leaves rownames even if new.row.names = NULL - rownames(object) <- NULL - object[, c("rowname", "colname", "value")] + + if (!requireNamespace("reshape2", quietly = TRUE)) + stop("Package 'reshape2' is required for 'longFormat()' conversion") + + reshape2::melt( + object, varnames = c("rowname", "colname"), value.name = "value" + ) } .longFormatElist <- function(object, i) { diff --git a/tests/testthat/test-MultiAssayExperiment-helpers.R b/tests/testthat/test-MultiAssayExperiment-helpers.R index 0749190..a675440 100644 --- a/tests/testthat/test-MultiAssayExperiment-helpers.R +++ b/tests/testthat/test-MultiAssayExperiment-helpers.R @@ -238,3 +238,20 @@ test_that("renaming helpers work", { newaffynames ) }) + + +test_that(".longFormatANY works", { + denv <- new.env(parent = emptyenv()) + data("miniACC", package="MultiAssayExperiment", envir = denv) + miniACC <- denv[["miniACC"]] + + expect_silent( + longdf <- longFormat(miniACC) + ) + expect_true( + all( + as.character(longdf[["rowname"]]) %in% + Reduce(union, rownames(miniACC)) + ) + ) +})