read_simple_graphs: Read all graphs in a directory, simplifying as requested

View source: R/orca_interface.R

read_simple_graphsR Documentation

Read all graphs in a directory, simplifying as requested

Description

Reads graph data from all files in a directory matching the specified filename pattern. From each file, an a igraph graph object is constructed and the requested subset of the following simplifications is made in the following order: 1. Makes the graph undirected 2. Removes loops (where both endpoints of an edge are the same vertex) 3. Removes multiple edges (i.e. ensuring only one edge exists for each pair of endpoints) 4. Removes isolated vertices (i.e. vertices with no edges after the previous alterations)

Usage

read_simple_graphs(
  source_dir,
  format = "ncol",
  pattern = "*",
  as_undirected = TRUE,
  remove_loops = TRUE,
  remove_multiple = TRUE,
  remove_isolates = TRUE
)

Arguments

source_dir

Path to directory containing files with graph data

format

Format of graph data. Any format supported by igraph::read_graph can be used.

pattern

Pattern to use to filter filenames. Any pattern supported by dir can be used.

as_undirected

If TRUE make graph edges undirected

remove_loops

If TRUE, remove edgeds that connect a vertex to itself

remove_multiple

If TRUE remove multiple edges connencting the same pair of vertices

remove_isolates

If TRUE, remove vertices with no edges after the previous alterations have been made

Value

A named list of simplified igraph graph object, with the name of each graph set to the name of the file it was read from.

Examples

# Set source directory for Virus protein-protein interaction edge files stored in the netdist package.
source_dir <- system.file(file.path("extdata", "VRPINS"), package = "netdist")
print(source_dir) 
# Load query graphs as igraph objects
graph_1 <- read_simple_graph(file.path(source_dir, "EBV.txt"), format = "ncol")
graph_1

alan-turing-institute/network-comparison documentation built on June 7, 2022, 10:41 p.m.