Generate a biadjacency matrix, linking the features between two tables.
Return an AnansiWeb
object which contains all three.
weaveWeb()
is for general use and has flexible default settings.
weaveKEGG()
is a wrapper that sets link
to kegg_link()
.
All variants are special cases of weaveWeb()
.
Arguments
- x, y
Character scalar
, names of feature types that should be linked. Should be found in the column names oflink
.- link
One of the following:
Character scalar
with value"none"
.data.frame
with two columnslist
with two suchdata.frame
s.
- tableY, tableX
A table containing features of interest. Rows should be samples and columns should be features. Y and X refer to the position of the features in a formula: Y ~ X.
< For Bioconductor S4 objects >Character scalar
ornumeric scalar
. Selects experiment corresponding totableY
andtableX
fromexperiments(x)
ofMultiAssayExperiment
object by name or index, name is recommended. (Default slots:Y = 1L
,X = 2L
).- metadata
Optional
data.frame
of sample metadata, to be included with output. Can be accessed fromAnansiWeb
generated byweaveWeb()
withoutput@metadata
.- verbose
Logical scalar
. Whether to print diagnostic information (Default:TRUE
).#' @param force_newboolean
If x already has a dictionaryMatrix
in metadata, ignore it and generate a new object anyway? (Default: FALSE).- typeY, typeX
Character scalar
ornumeric scalar
. Selects assay from experiments totableY
andtableX
fromexperiments(x)
. (Default:1L
- the first assay in that experiment).- experiment1, experiment2
synonymous args to
tableY,tableX
for compatibility withmia
argument style.- assay.type1, assay.type2
synonymous args to
typeY,typeX
for compatibility withmia
argument style.
Value
an AnansiWeb
object, with sparse binary biadjacency matrix
with features from y
as rows and features from x
as columns in
dictionary
slot.
Details
If the link
argument is "none"
, all features will be considered
linked. If one or more data.frame
s, colnames should be as specified in
x
and y
.
See also
AnansiWeb: For general constructor and methods.
kegg_link()
: For examples of input for link argument.
Examples
# Setup demo tables, see first vignette.
data(FMT_data)
t1 <- t(FMT_metab)
t2 <- t(FMT_KOs)
# Input objects and syntax:
## define `x` and `y` as characters
web <- weaveWeb(
x = "ko", y = "cpd", link = kegg_link(),
tableX = t2, tableY = t1,
metadata = NULL, verbose = TRUE
)
#> Dropped features in tableX: 2476 remain.
#> Warning: Argument `metadata` not provided; Please validate sample ID order.
## define `x` and `y` with a formula
web2 <- weaveWeb(
x = cpd ~ ko, link = kegg_link(),
tableX = t2, tableY = t1,
metadata = NULL, verbose = TRUE
)
#> Dropped features in tableX: 2476 remain.
#> Warning: Argument `metadata` not provided; Please validate sample ID order.
identical(web, web2)
#> [1] TRUE
# Method for MultiAssayExperiment S4 object
mae <- asMAE(web)
weaveWeb(
x = mae, link = kegg_link(),
tableY = "cpd", tableX = "ko",
force_new = FALSE
)
#> Warning: Argument `metadata` not provided; Please validate sample ID order.
#> anansi::AnansiWeb S7_object with 36 observations:
#> tableY: cpd (3 features)
#> tableX: ko (2476 features)
#> Use @ to access: tableX, tableY, dictionary, metadata.
# Method for TreeSummarizedExperiment S4 object
tse <- asTSE(web)
weaveWeb(
x = tse, link = kegg_link(),
tableY = "cpd", tableX = "ko",
force_new = FALSE
)
#> Warning: Argument `metadata` not provided; Please validate sample ID order.
#> anansi::AnansiWeb S7_object with 36 observations:
#> tableY: cpd (3 features)
#> tableX: ko (2476 features)
#> Use @ to access: tableX, tableY, dictionary, metadata.