anansi | R Documentation |
The anansi package package provides tools to prepare and facilitate integrative association analysis between the features of two data sets that are known to interact.
anansi()
with AnansiWeb()
and MultiFactor()
randomAnansi, kegg_link()
: Generate example input
AnansiWeb, MultiFactor: Handle and manipulate input
getAnansi()
: Compatibility with mia::mia and
MultiAssayExperiment::MultiAssayExperiment
getGraph()
: Compatibility with igraph::igraph
plotAnansi()
: Plot output in the style of miaViz::miaViz
anansi()
functionThe main workspider function in the anansi package is called
anansi
. It manages the individual functionalities of anansi, including
correlation analysis, correlation by group and differential associations.
anansi(
web,
formula,
groups = NULL,
metadata = NULL,
adjust.method = "BH",
verbose = TRUE,
return.format = "table",
...
)
web |
An |
formula |
A formula object. Used to assess differential associations. |
groups |
A vector of the column names of categorical values in the metadata object to control which groups should be assessed for simple correlations. If no argument provided, anansi will let you know and still to regular correlations according to your dictionary. |
metadata |
A vector or data.frame of categorical or continuous value necessary for differential correlations. Typically a state or treatment. If no argument provided, anansi will let you know and still to regular correlations according to your dictionary. |
adjust.method |
Method to adjust p-values for multiple comparisons.
|
verbose |
|
return.format |
|
... |
additional arguments (currently not used). |
A list of lists containing correlation coefficients, p-values and q-values for all operations.
Maintainer: Thomaz Bastiaanssen thomazbastiaanssen@gmail.com (ORCID)
Authors:
Thomas Quinn contacttomquinn@gmail.com (ORCID)
Giulio Benedetti giulio.benedetti@utu.fi (ORCID)
Leo Lahti leo.lahti@utu.fi (ORCID)
Useful links:
Report bugs at https://github.com/thomazbastiaanssen/anansi/issues
# Load example data:
data(FMT_data)
# Make sure that columns are features and rows are samples.
t1 <- t(FMT_metab)
t2 <- t(FMT_KOs)
# Run anansi pipeline.
web <- weaveWeb(
formula = cpd ~ ko,
tableY = t1,
tableX = t2,
link = kegg_link()
)
anansi_out <- anansi(
web = web,
formula = ~Legend,
groups = "Legend",
metadata = FMT_metadata,
adjust.method = "BH",
verbose = TRUE
)
library(tidyr)
# Use tidyr to wrangle the correlation r-values to a single column
anansiLong <- anansi_out |>
pivot_longer(starts_with("All") | contains("FMT")) |>
separate_wider_delim(
name,
delim = "_", names = c("cor_group", "param")
) |>
pivot_wider(names_from = param, values_from = value)
# Only consider interactions where the entire model fits well enough.
library(ggplot2)
anansiLong <- anansiLong[anansiLong$full_p.values < 0.05, ]
ggplot(
data = anansiLong,
aes(
x = r.values,
y = feature_X,
fill = cor_group,
alpha = disjointed_Legend_p.values < 0.05
)
) +
# Make a vertical dashed red line at x = 0
geom_vline(xintercept = 0, linetype = "dashed", colour = "red") +
# Points show raw correlation coefficients
geom_point(shape = 21, size = 3) +
# facet per compound
ggforce::facet_col(~feature_Y, space = "free", scales = "free_y") +
scale_fill_manual(values = c(
"Young yFMT" = "#2166ac",
"Aged oFMT" = "#b2182b",
"Aged yFMT" = "#ef8a62",
"All" = "gray"
)) +
theme_bw()
# Using miaViz style function:
p <- plotAnansi(anansi_out,
association.type = "disjointed",
model.var = "Legend",
fill_by = "group",
signif.threshold = 0.05,
x_lab = "Pearson's rho"
)
p <- p +
scale_fill_manual(values = c(
"Young yFMT" = "#2166ac",
"Aged oFMT" = "#b2182b",
"Aged yFMT" = "#ef8a62",
"All" = "gray"
)) +
theme_bw()
p
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.