extractSubgraphs: Creating objects of the class "Graph" for subgraphs of a...

View source: R/func__networkAnalyser__extractSubgraphs.R

extractSubgraphsR Documentation

Creating objects of the class "Graph" for subgraphs of a large graph

Description

This is a generator function used for creating objects of subgraphs. Particularly in this package, a subgraph refers to a connected graph component in a linkage network.

Usage

extractSubgraphs(V, E, clusters)

Arguments

V

A data frame where the first column contains vertex names and the other columns (optional) are vertex attributes.

E

A data frame consisting of all edges of an overall graph. The first and second columns are considered as "from" and "to" vertices of directed edges. Other columns are treated as weights of edges.

clusters

A data frame of three columns for cluster IDs (the first column), "from" vertices (the second column) and "to" vertices (the third column). Recommend to name columns of clusters by c("cluster", "from", "to") for convenience of understanding, although column names are not used in this function. Notice for overlapping clusters, some edges may belong to multiple clusters. Cluster IDs will be treated as characters in this function.

Value

An object of the class "Graph", which has two slots: V: A data frame for vertices and vertex attributes. E: A data frame for edges and edge attributes. Method getV(object, cluster.id, sorted = TRUE), which extracts vertex names of the cluster 'cluster.id' from a Graph object. The names are sorted in an ascending order alphabetically if sorted = TRUE.

Note

vertices in V are not necessarily the same as those in E. The idea to set a slot V is to keep vertex attributes vertices as well as to deal with singleton.

Author(s)

Yu Wan (wanyuac@126.com)

Examples

g <- extractSubgraphs(V = nodes, E = edges, clusters = c)


wanyuac/GeneMates documentation built on Aug. 12, 2022, 7:37 a.m.