diff --git a/DESCRIPTION b/DESCRIPTION index 74568de..181a366 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: MicrobiomeDB Title: Curated Data and Analysis Tools from MicrobiomeDB.org -Version: 1.1.1 +Version: 1.1.2 Authors@R: c(person(given = "Danielle", family = "Callan", @@ -12,15 +12,15 @@ Imports: data.table, DESeq2, igraph, - veupathUtils, + mbioUtils (>= 0.1.0), Maaslin2, methods, - microbiomeComputations, + microbiomeComputations (>= 5.1.7), purrr, SummarizedExperiment, TreeSummarizedExperiment Remotes: - microbiomeDB/veupathUtils, + microbiomeDB/mbioUtils, microbiomeDB/corGraph, microbiomeDB/microbiomeComputations, microbiomeDB/microbiomeData @@ -30,7 +30,7 @@ Description: This package is intended to be used to explore the curated datasets License: Apache License (>= 2) Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.3 Suggests: testthat (>= 3.0.0), S4Vectors, diff --git a/NAMESPACE b/NAMESPACE index b85fde1..1c0e040 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -38,6 +38,25 @@ importFrom(corGraph,bipartiteNetwork) importFrom(corGraph,unipartiteNetwork) importFrom(data.table,data.table) importFrom(igraph,graph_from_data_frame) +importFrom(mbioUtils,Collection) +importFrom(mbioUtils,Collections) +importFrom(mbioUtils,ComputeResult) +importFrom(mbioUtils,CorrelationResult) +importFrom(mbioUtils,SampleMetadata) +importFrom(mbioUtils,VariableSpec) +importFrom(mbioUtils,correlation) +importFrom(mbioUtils,findAncestorIdColumns) +importFrom(mbioUtils,findRecordIdColumn) +importFrom(mbioUtils,getCollectionNames) +importFrom(mbioUtils,getCollectionVariableNames) +importFrom(mbioUtils,getDataFromSource) +importFrom(mbioUtils,getIdColumns) +importFrom(mbioUtils,getMetadataVariableNames) +importFrom(mbioUtils,getMetadataVariableSummary) +importFrom(mbioUtils,getSampleMetadata) +importFrom(mbioUtils,getSampleMetadataIdColumns) +importFrom(mbioUtils,matchArg) +importFrom(mbioUtils,selfCorrelation) importFrom(microbiomeComputations,AbsoluteAbundanceData) importFrom(microbiomeComputations,AbundanceData) importFrom(microbiomeComputations,Comparator) @@ -48,22 +67,3 @@ importFrom(microbiomeComputations,internalDiffAbund) importFrom(microbiomeComputations,rankedAbundance) importFrom(microbiomeComputations,selfCorrelation) importFrom(purrr,reduce) -importFrom(veupathUtils,Collection) -importFrom(veupathUtils,Collections) -importFrom(veupathUtils,ComputeResult) -importFrom(veupathUtils,CorrelationResult) -importFrom(veupathUtils,SampleMetadata) -importFrom(veupathUtils,VariableSpec) -importFrom(veupathUtils,correlation) -importFrom(veupathUtils,findAncestorIdColumns) -importFrom(veupathUtils,findRecordIdColumn) -importFrom(veupathUtils,getCollectionNames) -importFrom(veupathUtils,getCollectionVariableNames) -importFrom(veupathUtils,getDataFromSource) -importFrom(veupathUtils,getIdColumns) -importFrom(veupathUtils,getMetadataVariableNames) -importFrom(veupathUtils,getMetadataVariableSummary) -importFrom(veupathUtils,getSampleMetadata) -importFrom(veupathUtils,getSampleMetadataIdColumns) -importFrom(veupathUtils,matchArg) -importFrom(veupathUtils,selfCorrelation) diff --git a/R/class-MbioDataset.R b/R/class-MbioDataset.R index bb745a1..ebfca3c 100644 --- a/R/class-MbioDataset.R +++ b/R/class-MbioDataset.R @@ -22,7 +22,7 @@ check_mbio_dataset <- function(object) { #' This class represents a MicrobiomeDB dataset. #' @name MbioDataset-class #' @rdname MbioDataset-class -#' @importFrom veupathUtils SampleMetadata +#' @importFrom mbioUtils SampleMetadata setClass("MbioDataset", slots = c( collections = "Collections", diff --git a/R/constructors-MbioDataset.R b/R/constructors-MbioDataset.R index 8f78df8..0a30ab4 100644 --- a/R/constructors-MbioDataset.R +++ b/R/constructors-MbioDataset.R @@ -1,13 +1,13 @@ -#' @importFrom veupathUtils findRecordIdColumn -#' @importFrom veupathUtils findAncestorIdColumns -#' @importFrom veupathUtils getDataFromSource +#' @importFrom mbioUtils findRecordIdColumn +#' @importFrom mbioUtils findAncestorIdColumns +#' @importFrom mbioUtils getDataFromSource sampleMetadataBuilder <- function(dataSource) { - dt <- veupathUtils::getDataFromSource(dataSource, keepIdsAndNumbersOnly=FALSE, cleanColumnNames=TRUE) + dt <- mbioUtils::getDataFromSource(dataSource, keepIdsAndNumbersOnly=FALSE, cleanColumnNames=TRUE) dataColNames <- names(dt) - recordIdColumn <- veupathUtils::findRecordIdColumn(dataColNames) - ancestorIdColumns <- veupathUtils::findAncestorIdColumns(dataColNames) + recordIdColumn <- mbioUtils::findRecordIdColumn(dataColNames) + ancestorIdColumns <- mbioUtils::findAncestorIdColumns(dataColNames) sampleMetadata <- new("SampleMetadata", data=dt, @@ -54,8 +54,8 @@ sampleMetadataFromDataSources <- function(dataSources) { #' @param ontology An data.frame containing the ontology of the dataset, or a character vector #' containing a file path to a data.frame #' @export -#' @importFrom veupathUtils Collection -#' @importFrom veupathUtils Collections +#' @importFrom mbioUtils Collection +#' @importFrom mbioUtils Collections #' @rdname MbioDataset-methods setGeneric("MbioDataset", function(collections, metadata, ontology) standardGeneric("MbioDataset")) @@ -168,369 +168,369 @@ setMethod("MbioDataset", signature("Collections", "character", "character"), fun #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,SampleMetadata,missing-method setMethod("MbioDataset", signature("Collection", "SampleMetadata", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,SampleMetadata,data.frame-method setMethod("MbioDataset", signature("Collection", "SampleMetadata", "data.frame"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,SampleMetadata,character-method setMethod("MbioDataset", signature("Collection", "SampleMetadata", "character"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,data.frame,missing-method setMethod("MbioDataset", signature("Collection", "data.frame", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,data.frame,data.frame-method setMethod("MbioDataset", signature("Collection", "data.frame", "data.frame"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,data.frame,character-method setMethod("MbioDataset", signature("Collection", "data.frame", "character"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,list,missing-method setMethod("MbioDataset", signature("Collection", "list", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,list,data.frame-method setMethod("MbioDataset", signature("Collection", "list", "data.frame"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,list,character-method setMethod("MbioDataset", signature("Collection", "list", "character"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,missing,missing-method setMethod("MbioDataset", signature("Collection", "missing", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections)) + new("MbioDataset", collections = mbioUtils::Collections(collections)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,missing,data.frame-method setMethod("MbioDataset", signature("Collection", "missing", "data.frame"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,missing,character-method setMethod("MbioDataset", signature("Collection", "missing", "character"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,character,missing-method setMethod("MbioDataset", signature("Collection", "character", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,character,data.frame-method setMethod("MbioDataset", signature("Collection", "character", "data.frame"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,Collection,character,character-method setMethod("MbioDataset", signature("Collection", "character", "character"), function(collections, metadata, ontology) { warning("Ontology specified but not used when a Collection object is provided.") - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,SampleMetadata,missing-method setMethod("MbioDataset", signature("list", "SampleMetadata", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,SampleMetadata,data.frame-method setMethod("MbioDataset", signature("list", "SampleMetadata", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,SampleMetadata,character-method setMethod("MbioDataset", signature("list", "SampleMetadata", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,data.frame,missing-method setMethod("MbioDataset", signature("list", "data.frame", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,data.frame,data.frame-method setMethod("MbioDataset", signature("list", "data.frame", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,data.frame,character-method setMethod("MbioDataset", signature("list", "data.frame", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,missing,missing-method setMethod("MbioDataset", signature("list", "missing", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections)) + new("MbioDataset", collections = mbioUtils::Collections(collections)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,missing,data.frame-method setMethod("MbioDataset", signature("list", "missing", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,missing,character-method setMethod("MbioDataset", signature("list", "missing", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,list,missing-method setMethod("MbioDataset", signature("list", "list", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,list,data.frame-method setMethod("MbioDataset", signature("list", "list", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,list,character-method setMethod("MbioDataset", signature("list", "list", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,character,missing-method setMethod("MbioDataset", signature("list", "character", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,character,data.frame-method setMethod("MbioDataset", signature("list", "character", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,list,character,character-method setMethod("MbioDataset", signature("list", "character", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,SampleMetadata,missing-method setMethod("MbioDataset", signature("data.frame", "SampleMetadata", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,SampleMetadata,data.frame-method setMethod("MbioDataset", signature("data.frame", "SampleMetadata", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,SampleMetadata,character-method setMethod("MbioDataset", signature("data.frame", "SampleMetadata", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,list,missing-method setMethod("MbioDataset", signature("data.frame", "list", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,list,data.frame-method setMethod("MbioDataset", signature("data.frame", "list", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,list,character-method setMethod("MbioDataset", signature("data.frame", "list", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,missing,missing-method setMethod("MbioDataset", signature("data.frame", "missing", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections)) + new("MbioDataset", collections = mbioUtils::Collections(collections)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,missing,data.frame-method setMethod("MbioDataset", signature("data.frame", "missing", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,missing,character-method setMethod("MbioDataset", signature("data.frame", "missing", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology))) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,data.frame,missing-method setMethod("MbioDataset", signature("data.frame", "data.frame", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,data.frame,data.frame-method setMethod("MbioDataset", signature("data.frame", "data.frame", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,data.frame,character-method setMethod("MbioDataset", signature("data.frame", "data.frame", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,character,missing-method setMethod("MbioDataset", signature("data.frame", "character", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,character,data.frame-method setMethod("MbioDataset", signature("data.frame", "character", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,data.frame,character,character-method setMethod("MbioDataset", signature("data.frame", "character", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,character,missing-method setMethod("MbioDataset", signature("character", "character", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,character,data.frame-method setMethod("MbioDataset", signature("character", "character", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,character,character-method setMethod("MbioDataset", signature("character", "character", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(list(metadata))) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(list(metadata))) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,list,missing-method setMethod("MbioDataset", signature("character", "list", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,list,data.frame-method setMethod("MbioDataset", signature("character", "list", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,list,character-method setMethod("MbioDataset", signature("character", "list", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataFromDataSources(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,missing,missing-method setMethod("MbioDataset", signature("character", "missing", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections)) + new("MbioDataset", collections = mbioUtils::Collections(collections)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,missing,data.frame-method setMethod("MbioDataset", signature("character", "missing", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,missing,character-method setMethod("MbioDataset", signature("character", "missing", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,data.frame,missing-method setMethod("MbioDataset", signature("character", "data.frame", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,data.frame,data.frame-method setMethod("MbioDataset", signature("character", "data.frame", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,data.frame,character-method setMethod("MbioDataset", signature("character", "data.frame", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataBuilder(metadata)) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = sampleMetadataBuilder(metadata)) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,SampleMetadata,missing-method setMethod("MbioDataset", signature("character", "SampleMetadata", "missing"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,SampleMetadata,data.frame-method setMethod("MbioDataset", signature("character", "SampleMetadata", "data.frame"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, ontology), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections, ontology), metadata = metadata) }) #' @rdname MbioDataset-methods #' @aliases MbioDataset,character,SampleMetadata,character-method setMethod("MbioDataset", signature("character", "SampleMetadata", "character"), function(collections, metadata, ontology) { - new("MbioDataset", collections = veupathUtils::Collections(collections, data.table::fread(ontology)), metadata = metadata) + new("MbioDataset", collections = mbioUtils::Collections(collections, data.table::fread(ontology)), metadata = metadata) }) \ No newline at end of file diff --git a/R/importers-MbioDataset.R b/R/importers-MbioDataset.R index 326a026..35b90c1 100644 --- a/R/importers-MbioDataset.R +++ b/R/importers-MbioDataset.R @@ -6,7 +6,7 @@ buildCollectionFromTreeSE <- function( normalizationMethod = c("TSS", "none"), verbose = c(TRUE, FALSE) ) { - verbose <- veupathUtils::matchArg(verbose) + verbose <- mbioUtils::matchArg(verbose) assayDataName <- collectionName$assayDataName rowDataColumnName <- collectionName$rowDataColumnName @@ -66,7 +66,7 @@ buildCollectionFromTreeSE <- function( collectionName <- paste0(collectionName, " (", normalizationMethod, " normalized)") } - collection <- veupathUtils::Collection( + collection <- mbioUtils::Collection( data = dt, recordIdColumn = recordIdColumn, ancestorIdColumns = ancestorIdColumns, @@ -125,9 +125,9 @@ buildCollectionFromTreeSE <- function( #' @export importTreeSummarizedExperiment <- function(data, normalizationMethod = c("TSS", "none"), keepRawValues = c(TRUE, FALSE), verbose = c(TRUE, FALSE)) { - normalizationMethod <- veupathUtils::matchArg(normalizationMethod) - keepRawValues <- veupathUtils::matchArg(keepRawValues) - verbose <- veupathUtils::matchArg(verbose) + normalizationMethod <- mbioUtils::matchArg(normalizationMethod) + keepRawValues <- mbioUtils::matchArg(keepRawValues) + verbose <- mbioUtils::matchArg(verbose) if (!inherits(data, "SummarizedExperiment")) { stop("data must be or extend a SummarizedExperiment") @@ -182,7 +182,7 @@ importTreeSummarizedExperiment <- function(data, normalizationMethod = c("TSS", collectionsList <- c(rawCollectionsList, normalizedCollectionsList) } else { - collectionsList <- veupathUtils::Collections() + collectionsList <- mbioUtils::Collections() } diff --git a/R/method-differentialAbundance.R b/R/method-differentialAbundance.R index 16e9b8c..f2c342c 100644 --- a/R/method-differentialAbundance.R +++ b/R/method-differentialAbundance.R @@ -31,23 +31,23 @@ assignToBinaryGroups <- function(x, groupAPredicate, groupBPredicate = NULL) { return(x) } -#' @importFrom veupathUtils VariableSpec -#' @importFrom veupathUtils getIdColumns +#' @importFrom mbioUtils VariableSpec +#' @importFrom mbioUtils getIdColumns buildBinaryComparator <- function(covariate, groupAValue, groupBValue) { - binA <- veupathUtils::Bin(binLabel=groupAValue) - binB <- veupathUtils::Bin(binLabel=groupBValue) + binA <- mbioUtils::Bin(binLabel=groupAValue) + binB <- mbioUtils::Bin(binLabel=groupBValue) - groupABins <- veupathUtils::BinList(S4Vectors::SimpleList(c(binA))) - groupBBins <- veupathUtils::BinList(S4Vectors::SimpleList(c(binB))) + groupABins <- mbioUtils::BinList(S4Vectors::SimpleList(c(binA))) + groupBBins <- mbioUtils::BinList(S4Vectors::SimpleList(c(binB))) comparatorVariable <- microbiomeComputations::Comparator( - variable = veupathUtils::VariableMetadata( + variable = mbioUtils::VariableMetadata( variableSpec = VariableSpec( variableId = covariate, entityId = '' ), - dataShape = veupathUtils::DataShape(value="CATEGORICAL") + dataShape = mbioUtils::DataShape(value="CATEGORICAL") ), groupA = groupABins, groupB = groupBBins @@ -156,8 +156,8 @@ function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verb #' @aliases differentialAbundance,CollectionWithMetadata,character,missingOrNULL,missingOrNULL-method setMethod("differentialAbundance", signature("CollectionWithMetadata", "character", "missingOrNULL", "missingOrNULL"), function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verbose = c(TRUE, FALSE)) { - method <- veupathUtils::matchArg(method) - verbose <- veupathUtils::matchArg(verbose) + method <- mbioUtils::matchArg(method) + verbose <- mbioUtils::matchArg(verbose) if (data.table::uniqueN(data@sampleMetadata@data[[covariate]]) < 2) { stop("Argument 'covariate' must have at least two unique values") @@ -176,8 +176,8 @@ function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verb #' @aliases differentialAbundance,CollectionWithMetadata,character,function,missingOrNULL-method setMethod("differentialAbundance", signature("CollectionWithMetadata", "character", "function", "missingOrNULL"), function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verbose = c(TRUE, FALSE)) { - method <- veupathUtils::matchArg(method) - verbose <- veupathUtils::matchArg(verbose) + method <- mbioUtils::matchArg(method) + verbose <- mbioUtils::matchArg(verbose) if (data.table::uniqueN(data@sampleMetadata@data[[covariate]]) < 2) { stop("Argument 'covariate' must have at least two unique values") @@ -193,8 +193,8 @@ function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verb #' @aliases differentialAbundance,CollectionWithMetadata,character,character,missingOrNULL-method setMethod("differentialAbundance", signature("CollectionWithMetadata", "character", "character", "missingOrNULL"), function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verbose = c(TRUE, FALSE)) { - method <- veupathUtils::matchArg(method) - verbose <- veupathUtils::matchArg(verbose) + method <- mbioUtils::matchArg(method) + verbose <- mbioUtils::matchArg(verbose) covariateDataType <- class(data@sampleMetadata@data[[covariate]]) if (!covariateDataType %in% c("factor", "character")) { @@ -215,8 +215,8 @@ function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verb #' @aliases differentialAbundance,CollectionWithMetadata,character,function,function-method setMethod("differentialAbundance", signature("CollectionWithMetadata", "character", "function", "function"), function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verbose = c(TRUE, FALSE)) { - method <- veupathUtils::matchArg(method) - verbose <- veupathUtils::matchArg(verbose) + method <- mbioUtils::matchArg(method) + verbose <- mbioUtils::matchArg(verbose) if (data.table::uniqueN(data@sampleMetadata@data[[covariate]]) < 2) { stop("Argument 'covariate' must have at least two unique values") @@ -233,8 +233,8 @@ function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verb #' @aliases differentialAbundance,CollectionWithMetadata,character,character,character-method setMethod("differentialAbundance", signature("CollectionWithMetadata", "character", "character", "character"), function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verbose = c(TRUE, FALSE)) { - method <- veupathUtils::matchArg(method) - verbose <- veupathUtils::matchArg(verbose) + method <- mbioUtils::matchArg(method) + verbose <- mbioUtils::matchArg(verbose) covariateDataType <- class(data@sampleMetadata@data[[covariate]]) if (!covariateDataType %in% c("factor", "character")) { @@ -297,12 +297,12 @@ setGeneric("Maaslin2", function(data, verbose = c(TRUE,FALSE), ...) standardGene #' @rdname Maaslin2 #' @aliases Maaslin2,CollectionWithMetadata-method setMethod("Maaslin2", signature("CollectionWithMetadata"), function(data, verbose = c(TRUE,FALSE), ...) { - verbose <- veupathUtils::matchArg(verbose) + verbose <- mbioUtils::matchArg(verbose) recordIdColumn <- data@recordIdColumn ancestorIdColumns <- data@ancestorIdColumns allIdColumns <- c(recordIdColumn, ancestorIdColumns) - sampleMetadata <- veupathUtils::getSampleMetadata(data) + sampleMetadata <- mbioUtils::getSampleMetadata(data) abundances <- microbiomeComputations::getAbundances(data) # remove rows in sampleMetadata where covariate is NA or empty string @@ -353,12 +353,12 @@ setGeneric("DESeqDataSetFromCollection", function(data, verbose = c(TRUE,FALSE), #' @rdname DESeqDataSetFromCollection #' @aliases DESeqDataSetFromCollection,AbsoluteAbundanceData-method setMethod("DESeqDataSetFromCollection", signature("AbsoluteAbundanceData"), function(data, verbose = c(TRUE,FALSE), ...) { - verbose <- veupathUtils::matchArg(verbose) + verbose <- mbioUtils::matchArg(verbose) recordIdColumn <- data@recordIdColumn ancestorIdColumns <- data@ancestorIdColumns allIdColumns <- c(recordIdColumn, ancestorIdColumns) - sampleMetadata <- veupathUtils::getSampleMetadata(data) + sampleMetadata <- mbioUtils::getSampleMetadata(data) abundances <- microbiomeComputations::getAbundances(data, verbose = verbose) # First, remove id columns and any columns that are all 0s. @@ -375,7 +375,7 @@ setMethod("DESeqDataSetFromCollection", signature("AbsoluteAbundanceData"), func # expects the order to match, and will not perform this check. if (!identical(rownames(sampleMetadata), colnames(counts))){ # Reorder sampleMetadata to match counts - veupathUtils::logWithTime("Sample order differs between data and metadata. Reordering data based on the metadata sample order.", verbose) + mbioUtils::logWithTime("Sample order differs between data and metadata. Reordering data based on the metadata sample order.", verbose) data.table::setcolorder(counts, rownames(sampleMetadata)) } diff --git a/R/methods-ComputeResult.R b/R/methods-ComputeResult.R index 4614c8c..a6e0fd5 100644 --- a/R/methods-ComputeResult.R +++ b/R/methods-ComputeResult.R @@ -17,7 +17,7 @@ #' @param format The format of the compute result. Currently only "data.table" and "igraph" are supported. #' @param ... additional arguments passed to getComputeResult method of the subclasses of ComputeResult #' @return The compute result in the specified format -#' @importFrom veupathUtils matchArg ComputeResult +#' @importFrom mbioUtils matchArg ComputeResult #' @export #' @rdname getComputeResult setGeneric("getComputeResult", function(object, format = c("data.table"), ...) standardGeneric("getComputeResult")) @@ -26,7 +26,7 @@ setGeneric("getComputeResult", function(object, format = c("data.table"), ...) s #' @rdname getComputeResult #' @aliases getComputeResult,ComputeResult-method setMethod("getComputeResult", "ComputeResult", function(object, format = c("data.table", "igraph"), ...) { - format <- veupathUtils::matchArg(format) + format <- mbioUtils::matchArg(format) if (!!length(object@statistics)) { return(getComputeResult(object@statistics, format, ...)) @@ -41,7 +41,7 @@ setMethod("getComputeResult", "ComputeResult", function(object, format = c("data return(dt) }) -#' @importFrom veupathUtils CorrelationResult +#' @importFrom mbioUtils CorrelationResult #' @rdname getComputeResult #' @param correlationCoefThreshold threshold to filter edges by correlation coefficient. #' Edges with correlation coefficients below this threshold will be removed. Default is .5 @@ -49,7 +49,7 @@ setMethod("getComputeResult", "ComputeResult", function(object, format = c("data #' @aliases getComputeResult,CorrelationResult-method #' @importFrom igraph graph_from_data_frame setMethod("getComputeResult", "CorrelationResult", function(object, format = c("data.table", "igraph"), correlationCoefThreshold = .5, pValueThreshold = .05) { - format <- veupathUtils::matchArg(format) + format <- mbioUtils::matchArg(format) result <- data.table::setDT(object@statistics) @@ -66,17 +66,17 @@ setMethod("getComputeResult", "CorrelationResult", function(object, format = c(" #' @rdname getComputeResult #' @aliases getComputeResult,DifferentialAbundanceResult-method setMethod("getComputeResult", "DifferentialAbundanceResult", function(object, format = c("data.table")) { - format <- veupathUtils::matchArg(format) + format <- mbioUtils::matchArg(format) return(data.table::setDT(object@statistics)) }) -#' @importFrom veupathUtils getSampleMetadata -#' @importFrom veupathUtils getSampleMetadataIdColumns +#' @importFrom mbioUtils getSampleMetadata +#' @importFrom mbioUtils getSampleMetadataIdColumns mergeComputeResultAndMetadata <- function(computeResult, dataset, metadataVariables) { dt <- getComputeResult(computeResult, "data.table") - metadata <- veupathUtils::getSampleMetadata(dataset, includeIds = TRUE, metadataVariables = metadataVariables) + metadata <- mbioUtils::getSampleMetadata(dataset, includeIds = TRUE, metadataVariables = metadataVariables) - metadataIdColumns <- veupathUtils::getSampleMetadataIdColumns(dataset) + metadataIdColumns <- mbioUtils::getSampleMetadataIdColumns(dataset) dt <- merge(dt, metadata, by = metadataIdColumns, all.x = TRUE) return(dt) @@ -117,7 +117,7 @@ function(object, dataset, format = c("data.table"), metadataVariables = NULL) #' @aliases getComputeResultWithMetadata,ComputeResult,MbioDataset-method setMethod("getComputeResultWithMetadata", signature = c("ComputeResult", "MbioDataset"), function(object, dataset = NULL, format = c("data.table"), metadataVariables = NULL) { - format <- veupathUtils::matchArg(format) + format <- mbioUtils::matchArg(format) dt <- mergeComputeResultAndMetadata(object, dataset, metadataVariables) return(dt) @@ -127,7 +127,7 @@ function(object, dataset = NULL, format = c("data.table"), metadataVariables = N #' @aliases getComputeResultWithMetadata,ComputeResult,Collection-method setMethod("getComputeResultWithMetadata", signature = c("ComputeResult", "Collection"), function(object, dataset = NULL, format = c("data.table"), metadataVariables = NULL) { - format <- veupathUtils::matchArg(format) + format <- mbioUtils::matchArg(format) dt <- mergeComputeResultAndMetadata(object, dataset, metadataVariables) return(dt) @@ -137,7 +137,7 @@ function(object, dataset = NULL, format = c("data.table"), metadataVariables = N #' @aliases getComputeResultWithMetadata,ComputeResult,AbundanceData-method setMethod("getComputeResultWithMetadata", signature = c("ComputeResult", "AbundanceData"), function(object, dataset = NULL, format = c("data.table"), metadataVariables = NULL) { - format <- veupathUtils::matchArg(format) + format <- mbioUtils::matchArg(format) dt <- mergeComputeResultAndMetadata(object, dataset, metadataVariables) return(dt) @@ -196,7 +196,7 @@ setMethod("correlationNetwork", "data.frame", function( pValueThreshold = .05, bipartiteNetwork = c(FALSE, TRUE) ) { - bipartiteNetwork <- veupathUtils::matchArg(bipartiteNetwork) + bipartiteNetwork <- mbioUtils::matchArg(bipartiteNetwork) warning("data.frame input assumes the columns are in the following order: source, target, correlationCoef, pValue.") names(object) <- c("source", "target", "value", "pValue") diff --git a/R/methods-MbioDataset.R b/R/methods-MbioDataset.R index 1ba26fd..8ac6525 100644 --- a/R/methods-MbioDataset.R +++ b/R/methods-MbioDataset.R @@ -1,4 +1,4 @@ -collectionNamesGeneric <- getGeneric("getCollectionNames", "veupathUtils") +collectionNamesGeneric <- getGeneric("getCollectionNames", "mbioUtils") #' Get Names of Collections #' #' Get the names of the collections in a MbioDataset object @@ -8,10 +8,10 @@ collectionNamesGeneric <- getGeneric("getCollectionNames", "veupathUtils") #' @param object An MbioDataset #' @return A character vector of collection names #' @export -#' @importFrom veupathUtils getCollectionNames +#' @importFrom mbioUtils getCollectionNames setMethod(collectionNamesGeneric, "MbioDataset", function(object) return(unname(getCollectionNames(object@collections)))) -metadataVarNamesGeneric <- getGeneric("getMetadataVariableNames", "veupathUtils") +metadataVarNamesGeneric <- getGeneric("getMetadataVariableNames", "mbioUtils") #' Get Variable Names of Metadata #' #' Get the names of the metadata variables in an MbioDataset. @@ -21,10 +21,10 @@ metadataVarNamesGeneric <- getGeneric("getMetadataVariableNames", "veupathUtils" #' @param object An MbioDataset #' @return a character vector of metadata variable names #' @export -#' @importFrom veupathUtils getMetadataVariableNames +#' @importFrom mbioUtils getMetadataVariableNames setMethod(metadataVarNamesGeneric, "MbioDataset", function(object) return(names(object@metadata@data))) -metadataVarSummaryGeneric <- getGeneric("getMetadataVariableSummary", "veupathUtils") +metadataVarSummaryGeneric <- getGeneric("getMetadataVariableSummary", "mbioUtils") #' Get Summary of Metadata Variables #' #' Get a summary of the requested metadata variable in an MbioDataset. @@ -37,7 +37,7 @@ metadataVarSummaryGeneric <- getGeneric("getMetadataVariableSummary", "veupathUt #' @param variable A character vector representing the name of the metadata variable to summarize #' @return a table summarizing the values of the requested metadata variable #' @export -#' @importFrom veupathUtils getMetadataVariableSummary +#' @importFrom mbioUtils getMetadataVariableSummary setMethod(metadataVarSummaryGeneric, "MbioDataset", function(object, variable) { if (!variable %in% getMetadataVariableNames(object)) { stop("Variable ", variable, " not found in sample metadata. Available variables: ", paste(getMetadataVariableNames(object), collapse = ", ")) @@ -54,7 +54,7 @@ setMethod(metadataVarSummaryGeneric, "MbioDataset", function(object, variable) { } }) -sampleMetadataGeneric <- getGeneric("getSampleMetadata", "veupathUtils") +sampleMetadataGeneric <- getGeneric("getSampleMetadata", "mbioUtils") #' Get data.table of sample metadata from MbioDataset #' #' Returns a data.table of sample metadata @@ -69,13 +69,13 @@ sampleMetadataGeneric <- getGeneric("getSampleMetadata", "veupathUtils") #' @return data.table of sample metadata #' @export setMethod(sampleMetadataGeneric, "MbioDataset", function(object, asCopy = c(TRUE, FALSE), includeIds = c(TRUE, FALSE), metadataVariables = NULL) { - asCopy <- veupathUtils::matchArg(asCopy) - includeIds <- veupathUtils::matchArg(includeIds) + asCopy <- mbioUtils::matchArg(asCopy) + includeIds <- mbioUtils::matchArg(includeIds) if (!length(object@metadata@data)) return(NULL) dt <- object@metadata@data - allIdColumns <- veupathUtils::getSampleMetadataIdColumns(object) + allIdColumns <- mbioUtils::getSampleMetadataIdColumns(object) # Check that incoming dt meets requirements if (!inherits(dt, 'data.table')) { @@ -97,13 +97,13 @@ setMethod(sampleMetadataGeneric, "MbioDataset", function(object, asCopy = c(TRUE return(dt) }) -metadataIdColsGeneric <- getGeneric("getSampleMetadataIdColumns", "veupathUtils") +metadataIdColsGeneric <- getGeneric("getSampleMetadataIdColumns", "mbioUtils") #' Get Sample Metadata Id Column Names #' #' Get the names of the record and ancestor id columns in the sample metadata of an MbioDataset object. #' @param object MbioDataset #' @return a character vector of id column names -setMethod(metadataIdColsGeneric, "MbioDataset", function(object) veupathUtils::getIdColumns(object@metadata)) +setMethod(metadataIdColsGeneric, "MbioDataset", function(object) mbioUtils::getIdColumns(object@metadata)) #' Update Microbiome Dataset Collection Name @@ -175,8 +175,8 @@ setGeneric("getCollection", function(object, collectionName, format = c("Abundan #' @rdname getCollection #' @aliases getCollection,MbioDataset,character-method setMethod("getCollection", "MbioDataset", function(object, collectionName = character(0), format = c("AbundanceData", "phyloseq", "Collection"), continuousMetadataOnly = c(FALSE, TRUE)) { - format <- veupathUtils::matchArg(format) - continuousMetadataOnly <- veupathUtils::matchArg(continuousMetadataOnly) + format <- mbioUtils::matchArg(format) + continuousMetadataOnly <- mbioUtils::matchArg(continuousMetadataOnly) if (length(collectionName) == 0) { stop("Must specify a collection name") @@ -240,7 +240,7 @@ setMethod("getCollection", "MbioDataset", function(object, collectionName = char collectionDataDT <- collectionDT[, -collectionIdColumns, with = FALSE] if (all(collectionDataDT == round(collectionDataDT), na.rm = TRUE)) { - veupathUtils::logWithTime("Integer values detected. Converting collection to AbsoluteAbundanceData", verbose = TRUE) + mbioUtils::logWithTime("Integer values detected. Converting collection to AbsoluteAbundanceData", verbose = TRUE) abundanceData <- AbsoluteAbundanceData( name = collection@name, data = collectionDT, @@ -292,7 +292,7 @@ setMethod("getCollection", "MbioDataset", function(object, collectionName = char return(abundanceData) }) -collectionVarNamesGeneric <- getGeneric("getCollectionVariableNames", "veupathUtils") +collectionVarNamesGeneric <- getGeneric("getCollectionVariableNames", "mbioUtils") #' Get Microbiome Dataset Collection Variable Names #' #' Get the variable names in a collection in the Microbiome Dataset. @@ -306,9 +306,9 @@ collectionVarNamesGeneric <- getGeneric("getCollectionVariableNames", "veupathUt #' @param collectionName The name of the collection to return the variable names for #' @return a character vector of the variable names in the requested collection #' @export -#' @importFrom veupathUtils getCollectionVariableNames +#' @importFrom mbioUtils getCollectionVariableNames setMethod(collectionVarNamesGeneric, "MbioDataset", function(object, collectionName) { - return(veupathUtils::getCollectionVariableNames(getCollection(object, collectionName))) + return(mbioUtils::getCollectionVariableNames(getCollection(object, collectionName))) }) #' Get Microbiome Dataset Variables @@ -375,11 +375,11 @@ setMethod("getVariables", "MbioDataset", function(object, variables) { if (any(variableNames %in% getCollectionVariableNames(object, collectionName))) { collection <- getCollection(object, collectionName) presentVars <- variableNames[variableNames %in% getCollectionVariableNames(collection)] - if (veupathUtils::isOneToManyWithAncestor(collection)) { + if (mbioUtils::isOneToManyWithAncestor(collection)) { warning("Unable to return the following variables: ", presentVars) return(data.table::data.table()) } - dt <- veupathUtils::getCollectionData(collection, presentVars) + dt <- mbioUtils::getCollectionData(collection, presentVars) if (collectionIndex %in% collectionsWithDupsIndexes) { ## rename variables to prepend the collection name names(dt)[names(dt) %in% presentVars] <- paste(collectionName, presentVars) diff --git a/R/reexports-microbiomeComputations.R b/R/reexports-microbiomeComputations.R index 1b71178..d8beaf2 100644 --- a/R/reexports-microbiomeComputations.R +++ b/R/reexports-microbiomeComputations.R @@ -97,15 +97,15 @@ microbiomeComputations::betaDiv #' @param verbose boolean indicating if timed logging is desired #' @param ... additional parameters #' @return data.frame with correlation coefficients or a ComputeResult object -#' @importFrom veupathUtils correlation +#' @importFrom mbioUtils correlation #' @export #' @rdname correlation-methods -veupathUtils::correlation +mbioUtils::correlation #' Self Correlation #' #' This function returns correlation coefficients for variables in one AbundanceData object against itself. It generally serves as a -#' convenience wrapper around veupathUtils::correlation, with the exception that it additionally supports sparcc. +#' convenience wrapper around mbioUtils::correlation, with the exception that it additionally supports sparcc. #' #' @examples #' correlationDT <- selfCorrelation( @@ -134,8 +134,8 @@ veupathUtils::correlation #' @param verbose boolean indicating if timed logging is desired #' @param ... additional parameters #' @return ComputeResult object -#' @importFrom veupathUtils selfCorrelation +#' @importFrom mbioUtils selfCorrelation #' @importFrom microbiomeComputations selfCorrelation #' @export #' @rdname selfCorrelation-methods -veupathUtils::selfCorrelation +mbioUtils::selfCorrelation diff --git a/man/selfCorrelation-methods.Rd b/man/selfCorrelation-methods.Rd index dcbe45e..80e0d5e 100644 --- a/man/selfCorrelation-methods.Rd +++ b/man/selfCorrelation-methods.Rd @@ -28,7 +28,7 @@ ComputeResult object } \description{ This function returns correlation coefficients for variables in one AbundanceData object against itself. It generally serves as a -convenience wrapper around veupathUtils::correlation, with the exception that it additionally supports sparcc. +convenience wrapper around mbioUtils::correlation, with the exception that it additionally supports sparcc. } \examples{ correlationDT <- selfCorrelation( diff --git a/tests/testthat/test-GetComputeResult.R b/tests/testthat/test-GetComputeResult.R index f670bbb..638ccdd 100644 --- a/tests/testthat/test-GetComputeResult.R +++ b/tests/testthat/test-GetComputeResult.R @@ -13,23 +13,23 @@ test_that("we can get compute results in different formats", { expect_equal(all(grepl('[',names(genus@sampleMetadata@data),fixed=T)), FALSE) # and that that means diff abund works now comparatorVariable <- microbiomeComputations::Comparator( - variable = veupathUtils::VariableMetadata( - variableSpec = veupathUtils::VariableSpec( + variable = mbioUtils::VariableMetadata( + variableSpec = mbioUtils::VariableSpec( variableId = 'delivery_mode', entityId = '' ), - dataShape = veupathUtils::DataShape(value="BINARY") + dataShape = mbioUtils::DataShape(value="BINARY") ), - groupA = veupathUtils::BinList( + groupA = mbioUtils::BinList( S4Vectors::SimpleList( - c(veupathUtils::Bin( + c(mbioUtils::Bin( binLabel="Vaginal" )) ) ), - groupB = veupathUtils::BinList( + groupB = mbioUtils::BinList( S4Vectors::SimpleList( - c(veupathUtils::Bin( + c(mbioUtils::Bin( binLabel="Cesarean" )) ) diff --git a/tests/testthat/test-differentialAbundance.R b/tests/testthat/test-differentialAbundance.R index d0a65a2..bbf9f52 100644 --- a/tests/testthat/test-differentialAbundance.R +++ b/tests/testthat/test-differentialAbundance.R @@ -9,7 +9,7 @@ mbioDataset <- MbioDataset(list(dataFile1, dataFile2), list(metadataFile2, metad genus <- getCollection(mbioDataset, "16S (V4) Genus (Relative taxonomic abundance analysis)") -genusIdCols <- veupathUtils::getIdColumns(genus) +genusIdCols <- mbioUtils::getIdColumns(genus) counts <- round(microbiomeComputations::getAbundances(genus, includeIds=FALSE)*1000) counts <- cbind(genus@data[, genusIdCols, with=FALSE], counts) genusCounts <- AbsoluteAbundanceData( diff --git a/tests/testthat/test-importers-MbioDataset.R b/tests/testthat/test-importers-MbioDataset.R index 93ceee8..2c3a524 100644 --- a/tests/testthat/test-importers-MbioDataset.R +++ b/tests/testthat/test-importers-MbioDataset.R @@ -57,6 +57,8 @@ test_that("buildCollectionFromTreeSE works", { }) test_that("we can get an MbioDataset from a TreeSummarizedExperiment", { + skip_if_not_installed("mia") + data(GlobalPatterns, package="mia") tse <- GlobalPatterns