adj2igraph: Convert adjacency matrix to igraph with annotations.

Description Usage Arguments Details Value See Also Examples

Description

Convert adjacency matrix output from conditional graphical model output (xy, yy) into into an igraph object and optionally layer attributes onto the vertices.

Usage

1
adj2igraph(yy, xy = NULL, yinfo = NULL, xinfo = NULL, weighted = NULL)

Arguments

yy

Adjacency matrix encoding y–y edges of conditional graphical model. Format can be either a sparse matrix (i.e. from Matrix package) or a regular matrix.

xy

Adjacency matrix encoding x–y edges of conditional graphical model. Format can be either a sparse matrix (i.e. from Matrix package) or a regular matrix. If NULL, then a network encoding just y–y edges is made.

yinfo

Data.frame encoding the attributes of the y vertices. If non-null, the column 'id' must exist for labelling vertices with a unique identifier. The order of the rows must match the order of the yy columns/rows. Other attributes in the form of data.frame columns are optional and can have missing data for some of the vertices. See 'Details' for further explanation.

xinfo

Data.frame encoding the attributes of the x vertices. If non-null, the column 'id' must exist for labelling vertices with a unique identifier. The order of the rows must match the order of the xy columns/rows. Other attributes in the form of data.frame columns are optional and can have missing data for some of the vertices. See 'Details' for further explanation.

weighted

Same argument passed to igraph::graph_from_adjacency_matrix. Defaults to NULL.

Details

The annotation parameters xinfo and yinfo are of type 'data.frame', where each row is expected to be ordered according to the rows of xy and yy, respectively. The first column 'id' is always required and must be unique for each node. The second column 'alias' is an optional column that reserves more human-readable labels to be applied to nodes, and can be duplicated. For example, two protein isoforms may have different ID's, but the same gene symbol alias. If gene coordinates are supplied for cis/trans identification, they require at least three variables: 'chr' a character for the chromosome location, 'start' an integer for the beginning of the genomic feature, and 'end' for the end location of the feature. The 'strand' argument is optional. Additional annotations such as 'description' or whatever other annotations are deemed important can be added as node attributes. Note that if any vertex is missing some or all annotations, an 'NA' should be used in its place.

Value

An igraph network object.

See Also

rankHub, cisTrans, reportHubs, xHubEnrich, modEnrich

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#Load BCPLS CNA-protein network output
library(spacemap)
data("bcpls")
#Attach "bcpls" data objects to the R Global Environment
attach(bcpls)

suppressPackageStartupMessages(library(igraph))
#Label y and x nodes with attributes
ig <- spacemap::adj2igraph(yy = net$yy, xy = net$xy, 
                           yinfo = yinfo, xinfo = xinfo)
#Label y with attributes
igy <- spacemap::adj2igraph(yy = net$yy, 
                           yinfo = yinfo)

topherconley/spacemap documentation built on May 31, 2019, 6:36 p.m.