View source: R/prune_network.R
prune_network | R Documentation |
Prune a network by upstream and downstream nodes
prune_network(network, upstream_nodes, downstream_nodes)
network |
A dataframe with three columns: source, target, and sign. |
upstream_nodes |
A character vector of upstream node names. |
downstream_nodes |
A character vector of downstream node names. |
This function takes a network in dataframe format with three columns (source, target, and interaction), a set of upstream nodes, and a set of downstream nodes. It returns a pruned network containing only nodes that can be reached downstream of the upstream set of nodes and upstream of the downstream set of nodes.
A dataframe of the pruned network with three columns: source, target, and sign.
# Sample network data
network_data <- data.frame(
source = c("A", "A", "B", "B", "C", "D", "E"),
target = c("B", "C", "C", "D", "E", "F", "F"),
interaction = c(1, -1, 1, -1, 1, 1, -1)
)
# Upstream and downstream node sets
upstream_nodes <- c("A", "B")
downstream_nodes <- c("E", "F")
# Prune the network
pruned_network <- prune_network(network_data, upstream_nodes, downstream_nodes)
print(pruned_network)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.