weavePath and weaveComplex build the selected path through the resource graph from the origin to the target features, fetching and combining the necessary resources from several databases.

While weavePath returns a linkmap with all simple links, weaveComplex yields links only for features mapped above a certain coverage threshold, which is useful for pathways or functional modules made of several indispensable components.

weavePath(graph, ...)

weaveComplex(graph, ...)

# S4 method for class 'igraph'
weavePath(
  graph,
  by,
  k = 1,
  include = NULL,
  exclude = NULL,
  res.name = NULL,
  init = NULL,
  prune = TRUE,
  use.names = TRUE,
  verbose = TRUE,
  timeout = 1e+06,
  ...
)

# S4 method for class 'igraph'
weaveComplex(
  graph,
  by,
  k = 1,
  include = NULL,
  exclude = NULL,
  res.name = NULL,
  init = NULL,
  prune = TRUE,
  use.names = TRUE,
  threshold = NULL,
  verbose = TRUE,
  timeout = 1e+06,
  ...
)

Arguments

graph

An igraph object.

...

Additional arguments.

  • batch.size: Numeric scalar. The maximum batch size for SPARQL or API queries. (Default: half the maximum query size)

  • workers: Numeric scalar. Number of workers to use, automatically detected when NULL. (Default: NULL)

  • factor: Numeric scalar. Number of jobs per worker. (Default: 3)

by

A formula specifying the path to weave.

k

Numeric scalar. The kth shortest path to weave. (Default: 1)

include

Character vector. Nodes to cross in the path. (Default: NULL)

exclude

Character vector. Nodes to avoid in the path. (Default: NULL)

res.name

Character vector. Names of resources to include in the graph. (Default: NULL)

init

Character vector. Initial values to prune the first mapping step. (Default: NULL)

prune

Logical scalar. Should the values from each step be used prune the following step. (Default: TRUE)

use.names

Logical scalar. Should feature names be used in the output instead of feature identifiers. either (Default: TRUE)

verbose

Logical scalar. Should messages be printed in the console. (Default: TRUE)

timeout

Numeric scalar. The timeout for downloading resources. (Default: 1e6)

threshold

Numeric scalar. Only for weaveComplex. The coverage threshold above which to include links, between 0 and 1. If NULL, all non-zero links are returned. (Default: NULL)

Value

A two-column data.frame (x-to-y linkmap), with optional names as a third column.

Examples

library(mia)

# Import dataset
data("Tengeler2020", package = "mia")
tse <- Tengeler2020

# Load resource graph
graph <- ariadne()

# Retrieve taxon names
tax.labs <- getTaxonomyLabels(tse, make.unique = FALSE)
tax.labs <- sub("^.+:", "", tax.labs)

# Weave path starting from initial values
tax2bugsig <- weavePath(graph, taxname ~ bugsig, init = tax.labs)
#> taxname -(BugSigDB)-> bugsig
#> Warning: names for 1103 bugsig ids not found.

# Weave 3-rd path
tax2bugsig <- weavePath(graph, taxname ~ bugsig, init = tax.labs, k = 3)
#> taxname -(OTT)-> taxid
#> taxid -(BugSigDB)-> bugsig
#> Warning: names for 1390 bugsig ids not found.

# Weave path including taxid
tax2bugsig <- weavePath(
    graph, taxname ~ bugsig, include = "taxid", init = tax.labs
)
#> taxname -(UniProt)-> taxid
#> taxid -(BugSigDB)-> bugsig
#> Warning: names for 1103 bugsig ids not found.

# Weave simple path from KEGG diseases to gut metabolic modules
dis2gmm <- weavePath(graph, kegg_disease ~ gmm)
#> kegg_disease -(KEGG)-> ko
#> ko -(GM)-> gmm

# Weave complex path from KEGG diseases to gut metabolic modules
dis2gmm <- weaveComplex(graph, kegg_disease ~ gmm)
#> kegg_disease -(KEGG)-> ko
#> ko -(GM)-> gmm

# Specify coverage threshold
dis2gmm <- weaveComplex(graph, kegg_disease ~ gmm, threshold = 0.8)
#> kegg_disease -(KEGG)-> ko
#> ko -(GM)-> gmm