Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
Expand All @@ -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,
Expand Down
38 changes: 19 additions & 19 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
2 changes: 1 addition & 1 deletion R/class-MbioDataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
136 changes: 68 additions & 68 deletions R/constructors-MbioDataset.R

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions R/importers-MbioDataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,7 +66,7 @@ buildCollectionFromTreeSE <- function(
collectionName <- paste0(collectionName, " (", normalizationMethod, " normalized)")
}

collection <- veupathUtils::Collection(
collection <- mbioUtils::Collection(
data = dt,
recordIdColumn = recordIdColumn,
ancestorIdColumns = ancestorIdColumns,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -182,7 +182,7 @@ importTreeSummarizedExperiment <- function(data, normalizationMethod = c("TSS",

collectionsList <- c(rawCollectionsList, normalizedCollectionsList)
} else {
collectionsList <- veupathUtils::Collections()
collectionsList <- mbioUtils::Collections()
}


Expand Down
46 changes: 23 additions & 23 deletions R/method-differentialAbundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")) {
Expand All @@ -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")
Expand All @@ -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")) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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))
}

Expand Down
26 changes: 13 additions & 13 deletions R/methods-ComputeResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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, ...))
Expand All @@ -41,15 +41,15 @@ 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
#' @param pValueThreshold threshold to filter edges by p-value. Edges with p-values above this threshold will be removed. Default is .05
#' @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)

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
Loading
Loading