Skip to content

Commit

Permalink
bug fix: longFormat rowname type should be character, closes #331
Browse files Browse the repository at this point in the history
  • Loading branch information
LiNk-NY committed Jul 8, 2024
1 parent 66eed8e commit e81ec84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/MultiAssayExperiment-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,12 @@ setMethod("mergeReplicates", "ANY",
if (!requireNamespace("reshape2", quietly = TRUE))
stop("Package 'reshape2' is required for 'longFormat()' conversion")

reshape2::melt(
res <- reshape2::melt(
object, varnames = c("rowname", "colname"), value.name = "value"
)
if (!is.character(res[["rowname"]]))
res[["rowname"]] <- as.character(res[["rowname"]])
res
}

.longFormatElist <- function(object, i) {
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-MultiAssayExperiment-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,19 @@ test_that(".longFormatANY works", {
Reduce(union, rownames(miniACC))
)
)

m <- matrix(1:12, nrow = 4)
colnames(m) <- LETTERS[1:3]
se <- SummarizedExperiment(m)
rownames(se) <- c(1, 2, 4, 5)

mae <- MultiAssayExperiment(list(x = se))
longformat <- longFormat(mae)
expect_true(
is.character(longformat[["rowname"]])
)
expect_identical(
typeof(m),
typeof(longformat[["value"]])
)
})

0 comments on commit e81ec84

Please sign in to comment.