From 4e8d11053dfe8934b41713fda81e972c67de6fbe Mon Sep 17 00:00:00 2001 From: Danielle Callan Date: Thu, 7 Mar 2024 15:39:52 -0500 Subject: [PATCH] get tests passing again --- R/methods.R | 12 ++++++++++-- tests/testthat/test-GetComputeResult.R | 8 +------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/R/methods.R b/R/methods.R index 7f79313..da0da6b 100644 --- a/R/methods.R +++ b/R/methods.R @@ -1,3 +1,6 @@ +## TODO should import and reexport a bunch of functions and data from the data and computes package +## TODO should think some about how to organize these methods and the others into files etc. + #' Get Microbiome Dataset Compute Result #' #' Get the compute result from a Microbiome Dataset in a particular format. @@ -47,11 +50,16 @@ setMethod("getComputeResult", "DifferentialAbundanceResult", function(object, fo return(data.table::setDT(object@statistics)) }) +#' @importFrom microbiomeData getSampleMetadata +#' @importFrom microbiomeData getSampleMetadataIdColumns mergeComputeResultAndMetadata <- function(computeResult, dataset, metadataVariables) { dt <- getComputeResult(computeResult, "data.table") - metadata <- getSampleMetadata(dataset, metadataVariables) + metadata <- microbiomeData::getSampleMetadata(dataset, includeIds = TRUE, metadataVariables = metadataVariables) - metadataIdColumns <- getSampleMetadataIdColumnNames(dataset) + metadataIdColumns <- microbiomeData::getSampleMetadataIdColumns(dataset) + print(metadataIdColumns) + print(head(names(dt))) + print(head(names(metadata))) dt <- merge(dt, metadata, by = metadataIdColumns, all.x = TRUE) return(dt) diff --git a/tests/testthat/test-GetComputeResult.R b/tests/testthat/test-GetComputeResult.R index 833d24b..9edf762 100644 --- a/tests/testthat/test-GetComputeResult.R +++ b/tests/testthat/test-GetComputeResult.R @@ -1,11 +1,5 @@ test_that("we can get compute results in different formats", { - dataFile1 <- '../../inst/extdata/DiabImmune/DiabImmune_entity_16SRRNAV4Assay.txt' - metadataFile1 <- '../../inst/extdata/DiabImmune/DiabImmune_ParticipantRepeatedMeasure.txt' - dataFile2 <- '../../inst/extdata/DiabImmune/DiabImmune_MetagenomicSequencingAssay.txt' - metadataFile2 <- '../../inst/extdata/DiabImmune/DiabImmune_Participant.txt' - metadataFile3 <- '../../inst/extdata/DiabImmune/DiabImmune_Sample.txt' - ontologyFile <- '../../inst/extdata/DiabImmune/DiabImmune_OntologyMetadata.txt' - mbioDataset <- MbioDataset(list(dataFile1, dataFile2), list(metadataFile1, metadataFile2, metadataFile3), ontologyFile) + mbioDataset <- microbiomeData::DiabImmune genus <- getCollection(mbioDataset, "16S Genus", continuousMetadataOnly = TRUE) # make sure metadata dont contain IRIs