weaveWeb: Weave an AnansiWeb

View source: R/weaveWeb-methods.R

weaveWebR Documentation

Weave an AnansiWeb

Description

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().

Usage

weaveWeb(x, ...)

## Default S3 method:
weaveWeb(
  x,
  y,
  link = NULL,
  tableX = NULL,
  tableY = NULL,
  metadata = NULL,
  verbose = TRUE,
  ...
)

## S3 method for class 'formula'
weaveWeb(formula, link = NULL, tableX = NULL, tableY = NULL, ...)

weaveKEGG(x, ...)

Arguments

x, y

⁠Character scalar⁠, names of feature types that should be linked. Should be found in the column names of link.

...

further arguments.

link

One of the following:

  • ⁠Character scalar⁠ with value "none".

  • data.frame with two columns

  • list with two such data.frames.

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.

metadata

Optional data.frame of sample metadata, to be included with output. Can be accessed from AnansiWeb generated by weaveWeb() with metadata(output).

verbose

⁠Logical scalar⁠. Whether to print diagnostic information (Default: TRUE).

formula

formula of the form y ~ x, denoting desired output format; assigns y to rows and columns to x. Equivalent to using x and y arguments.

Details

If the link argument is "none", all features will be considered linked. If one or more data.frames, colnames should be as specified in x and y.

Value

an AnansiWeb object, with sparse binary biadjacency matrix with features from y as rows and features from x as columns in dictionary slot.

See Also

  • AnansiWeb: For general constructor and methods.

  • kegg_link(): For examples of input for link argument.

  • getWeb(): For MultiAssayExperiment::MultiAssayExperiment() methods.

Examples

# Setup demo tables
ec2ko <- kegg_link()[["ec2ko"]]
ec2cpd <- kegg_link()[["ec2cpd"]]

# Basic usage
weaveWeb(cpd ~ ko, link = kegg_link())
weaveWeb(x = "ko", y = "ec", link = ec2ko)
weaveWeb(ec ~ cpd, link = ec2cpd)

# A wrapper is available for kegg ko, ec and cpd data
generic <- weaveWeb(cpd ~ ko, link = kegg_link())
kegg_wrapper <- weaveKEGG(cpd ~ ko)

identical(generic, kegg_wrapper)

# The following are equivalent to transposition:
a <- weaveWeb(ko ~ cpd, link = kegg_link()) |> dictionary()
b <- weaveWeb(cpd ~ ko, link = kegg_link()) |> dictionary()

identical(a, Matrix::t(b))


thomazbastiaanssen/anansi documentation built on June 9, 2025, 3:59 p.m.