Skip to content

Commit

Permalink
get tests passing again
Browse files Browse the repository at this point in the history
  • Loading branch information
d-callan committed Mar 7, 2024
1 parent eb9aad8 commit 4e8d110
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 10 additions & 2 deletions R/methods.R
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 1 addition & 7 deletions tests/testthat/test-GetComputeResult.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4e8d110

Please sign in to comment.