Skip to contents

The assignTP function assigns transition probabilities to edges in an input graph based on the specified transition probability data. This function enhances a graph's edges with additional attributes representing transition probabilities associated with specific reactions or entities. It is used within the context of the computeTransitionProbability function.

Usage

assignTP(
  igraph,
  transition_probability,
  column = "miriam.kegg.reaction",
  attr_name = "tp"
)

Arguments

igraph

An igraph object representing the graph to which transition probabilities should be assigned.

transition_probability

A named numeric vector containing transition probabilities for individual reactions or entities. The names of the vector should correspond to the identifiers used in the specified column.

column

A character string specifying the name of the edge attribute in the graph that contains identifiers for reactions or entities. Defaults to "miriam.kegg.reaction".

attr_name

A character string specifying the name of the edge attribute to which the transition probabilities should be assigned. Defaults to "tp".

Value

The input igraph object with the transition probabilities assigned as edge attributes.

Note

The function assumes that the input graph has edge attributes containing identifiers for reactions or entities (default column name: "miriam.kegg.reaction"), and the transition_probability vector contains numeric transition probability values for those identifiers.

Examples

# Create a sample igraph object
library(igraph)
g <- make_ring(10)
E(g)$`miriam.kegg.reaction` <- sample(letters[1:5], 10, replace = TRUE)

# Create a sample transition probability vector
tp <- setNames(runif(5), letters[1:5])

# Assign transition probabilities to graph edges
g_with_tp <- assignTP(g, tp)