getAnansi: anansi wrapper for the MultiAssayExperiment class

getAnansiR Documentation

anansi wrapper for the MultiAssayExperiment class

Description

getAnansi provides a wrapper to execute the anansi pipeline on a MultiAssayExperiment object. It applies the functions weaveWebFromTables, anansi and optionally spinToLong in the given order.

Usage

getAnansi(x, ...)

## S4 method for signature 'MultiAssayExperiment'
getAnansi(
  x,
  experiment1 = 1,
  experiment2 = 2,
  assay.type1 = "counts",
  assay.type2 = "counts",
  return.format = "long",
  ...
)

Arguments

x

a MultiAssayExperiment.

...

additional parameters that can be passed to weaveWebFromTables, anansi, spinToLong or spinToWide.

experiment1

Character scalar or numeric scalar. Selects the experiment 1 from experiments(x) of MultiassayExperiment object. (Default: 1)

experiment2

Character scalar or numeric scalar. Selects the experiment 2 fromexperiments(x) of MultiAssayExperiment object. (Default: 2)

assay.type1

Character scalar. Specifies the name of the assay in experiment 1 to be used. (Default: "counts")

assay.type2

Character scalar. Specifies the name of the assay in experiment 2 to be used. (Default: "counts")

return.format

Character scalar. Should be one of "long", "wide", or "raw". Should the output of anansi be passed to spinToLong or spinToWide for convenient use. (Default: "long")

Details

This wrapper of anansi allows to perform a complete anansi analysis directly on objects of class MultiAssayExperiment. First, the assays specified by assay.type1 and assay.type2 are passed to weaveWebFromTables to produce an anansiWeb object. Next, this object is fed to the main anansi function to compute interactions between the two assays. Finally, the output can be simplified with spinToLong for easy manipulation and visualisation.

Value

If return.format is long (default), a long format data.frame intended to be compatible with ggplot2. If return.format is wide, a wide format data.frame. If return.format is raw, a list of lists containing correlation coefficients, p-values and q-values for all operations.

See Also

weaveWebFromTables anansi spinToLong spinToWide

Examples


# Import libraries
library(mia)
library(TreeSummarizedExperiment)
library(MultiAssayExperiment)

# Load data
data("FMT_data", package = "anansi")
data("dictionary", package = "anansi")

# Convert to (Tree)SummarizedExperiment objects
metab_se <- SummarizedExperiment(assays = SimpleList(conc = as.matrix(FMT_metab)))
KO_tse <- TreeSummarizedExperiment(assays = SimpleList(counts = as.matrix(FMT_KOs)))

# Select functions that are represented in the dictionary
keep <- row.names(KO_tse) %in% sort(unique(unlist(anansi_dic)))
KO_tse <- KO_tse[keep, ]

# Remove features with less than 10% prevalence
KO_tse <- subsetByPrevalent(KO_tse,
  assay.type = "counts",
  prevalence = 0.1
)

# Perform a centered log-ratio transformation on the functional counts assay
KO_tse <- transformAssay(KO_tse,
  assay.type = "counts",
  method = "clr",
  pseudocount = TRUE
)

# Prepare colData
coldata <- FMT_metadata
rownames(coldata) <- coldata$Sample_ID
coldata <- coldata[match(colnames(KO_tse), rownames(coldata)), ]

# Combine experiments into MultiAssayExperiment object
mae <- MultiAssayExperiment(
  experiments = ExperimentList(metabolites = metab_se, functions = KO_tse),
  colData = coldata
)

# Perform anansi analysis
out <- getAnansi(mae,
  experiment1 = "metabolites", experiment2 = "functions",
  assay.type1 = "conc", assay.type2 = "clr",
  formula = ~Legend
)

# Select significant interactions
out <- out[out$model_full_q.values < 0.1, ]

# View subset of results
head(out, 5)


thomazbastiaanssen/anansi documentation built on Feb. 9, 2025, 2:07 p.m.