make_state {graphsim} | R Documentation |
Make State Matrix
Description
Functions to compute the matrix of states (1 for activating and -1 for inhibiting)
for link signed correlations, from a vector of edge states to a signed adjacency matrix for use
in generate_expression
. This resolves edge states to determine the sign
of all correlations between nodes in a network. These are computed interally for sigma matrices
as required.
Usage
make_state_matrix(graph, state = NULL)
Arguments
graph |
An |
state |
numeric vector. Vector of length E(graph). Sign used to calculate state matrix,
may be an integer state or inferred directly from expected correlations for each edge. May be
applied a scalar across all edges or as a vector for each edge respectively. May also be
entered as text for "activating" or "inhibiting" or as integers for activating (0,1) or
inhibiting (-1,2). Compatible with inputs for |
Value
An integer matrix indicating the resolved state (activating or inhibiting for each edge or path between nodes)
Author(s)
Tom Kelly tom.kelly@riken.jp
See Also
See also generate_expression
for computing the simulated data,
make_sigma
for computing the Sigma () matrix,
and
make_distance
for computing distance from a graph object.
See also plot_directed
for plotting graphs or
heatmap.2
for plotting matrices.
See also make_laplacian
, make_commonlink
,
or make_adjmatrix
for computing input matrices.
See also igraph
for handling graph objects.
Other graphsim functions:
generate_expression()
,
make_adjmatrix
,
make_commonlink
,
make_distance
,
make_laplacian
,
make_sigma
,
plot_directed()
Other generate simulated expression functions:
generate_expression()
,
make_distance
,
make_sigma
Examples
# construct a synthetic graph module
library("igraph")
graph_test_edges <- rbind(c("A", "B"), c("B", "C"), c("B", "D"))
graph_test <- graph.edgelist(graph_test_edges, directed = TRUE)
# compute state matrix for toy example
state_matrix <- make_state_matrix(graph_test)
# construct a synthetic graph network
graph_structure_edges <- rbind(c("A", "C"), c("B", "C"), c("C", "D"), c("D", "E"),
c("D", "F"), c("F", "G"), c("F", "I"), c("H", "I"))
graph_structure <- graph.edgelist(graph_structure_edges, directed = TRUE)
# compute state matrix for toy network
graph_structure_state_matrix <- make_state_matrix(graph_structure)
graph_structure_state_matrix
# compute state matrix for toy network with inhibitions
edge_state <- c(1, 1, -1, 1, 1, 1, 1, -1)
# edge states are a variable
graph_structure_state_matrix <- make_state_matrix(graph_structure, state = edge_state)
graph_structure_state_matrix
# compute state matrix for toy network with inhibitions
E(graph_structure)$state <- c(1, 1, -1, 1, 1, 1, 1, -1)
# edge states are a graph attribute
graph_structure_state_matrix <- make_state_matrix(graph_structure)
graph_structure_state_matrix
library("igraph")
graph_test_edges <- rbind(c("A", "B"), c("B", "C"), c("B", "D"))
graph_test <- graph.edgelist(graph_test_edges, directed = TRUE)
state_matrix <- make_state_matrix(graph_test)
# import graph from package for reactome pathway
# TGF-\eqn{\Beta} receptor signaling activates SMADs (R-HSA-2173789)
TGFBeta_Smad_graph <- identity(TGFBeta_Smad_graph)
# compute sigma (\eqn{\Sigma}) matrix from geometric distance directly from TGF-\eqn{\Beta} pathway
TFGBeta_Smad_state <- E(TGFBeta_Smad_graph)$state
table(TFGBeta_Smad_state)
# states are edge attributes
state_matrix_TFGBeta_Smad <- make_state_matrix(TGFBeta_Smad_graph)
# visualise matrix
library("gplots")
heatmap.2(state_matrix_TFGBeta_Smad , scale = "none", trace = "none",
dendrogram = "none", Rowv = FALSE, Colv = FALSE,
col = colorpanel(50, "blue", "white", "red"))
# compare the states to the sign of expected correlations in the sigma matrix
sigma_matrix_TFGBeta_Smad_inhib <- make_sigma_mat_dist_graph(TGFBeta_Smad_graph,
cor = 0.8,
absolute = FALSE)
# visualise matrix
heatmap.2(sigma_matrix_TFGBeta_Smad_inhib,
scale = "none", trace = "none",
dendrogram = "none", Rowv = FALSE, Colv = FALSE,
col = colorpanel(50, "blue", "white", "red"))
# compare the states to the sign of final correlations in the simulated matrix
TFGBeta_Smad_data <- generate_expression(100, TGFBeta_Smad_graph, cor = 0.8)
heatmap.2(cor(t(TFGBeta_Smad_data)), scale = "none", trace = "none",
dendrogram = "none", Rowv = FALSE, Colv = FALSE,
col = colorpanel(50, "blue", "white", "red"))