The computeTransitionProbability
function computes transition probabilities for edges in a list of igraph objects based on adjacency and edge attributes. This function allows for the computation of transition probabilities and offers the option to adjust transition probability matrices for paths originating from a target node or using a recursive adjustment method.
Usage
computeTransitionProbability(
igraph_list,
attr_name,
attr_rownames,
target_node = NULL,
pass_through = FALSE,
mgraph
)
Arguments
- igraph_list
A list of igraph objects for which transition probabilities are to be computed.
- attr_name
A character string specifying the name of the edge attribute in the graph that contains transition probabilities.
- attr_rownames
A character string specifying the name of the edge attribute that provides row names for the transition probability matrix.
- target_node
An optional character string specifying the target node from which paths are considered. Defaults to NULL.
- pass_through
A logical value indicating whether to compute transition probabilities with an additional step (recursive adjustment). Defaults to FALSE.
- mgraph
TODOTODO
Value
A matrix of computed transition probabilities. Rows correspond to edge attributes specified by attr_rownames
, and columns correspond to the igraph objects in igraph_list
(samples).
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 list of sample igraph objects
library(igraph)
g1 <- make_ring(10)
g2 <- make_ring(10)
E(g1)$`miriam.kegg.reaction` <- sample(letters[1:5], 10, replace = TRUE)
E(g2)$`miriam.kegg.reaction` <- sample(letters[1:5], 10, replace = TRUE)
igraph_list <- list(g1, g2)
# Compute transition probabilities
transition_probs <-
computeTransitionProbability(igraph_list, attr_name = "weight",
attr_rownames = "miriam.kegg.reaction")
#> Error in get.adjacency.dense(graph, type = type, attr = attr, weights = NULL, names = names, loops = "once"): no such edge attribute