prune_network: prune_network

View source: R/prune_network.R

prune_networkR Documentation

prune_network

Description

Prune a network by upstream and downstream nodes

Usage

prune_network(network, upstream_nodes, downstream_nodes)

Arguments

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.

Details

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.

Value

A dataframe of the pruned network with three columns: source, target, and sign.

Examples

# 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)

saezlab/CARNIVAL documentation built on Jan. 17, 2024, 5:10 p.m.