getAnansi | R Documentation |
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.
getAnansi(x, ...)
## S4 method for signature 'MultiAssayExperiment'
getAnansi(
x,
experiment1 = 1,
experiment2 = 2,
assay.type1 = "counts",
assay.type2 = "counts",
return.format = "long",
...
)
x |
a
|
... |
additional parameters that can be passed to
|
experiment1 |
|
experiment2 |
|
assay.type1 |
|
assay.type2 |
|
return.format |
|
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.
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.
weaveWebFromTables
anansi
spinToLong
spinToWide
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.