R: Converts an adjacency matrix into edge list representation

getEdgeList {PCIT} | R Documentation

## Converts an adjacency matrix into edge list representation

### Description

Given an adjacency matrix, converts it into edge list representation. This edge list can be written to a file for easy import into other software such as cytoscape.

Only the upper triangle is returned as it is assumed the matrix is symmetric. The edge list is returned as a data frame with 3 columns: 'From', 'To' and 'Weight'.

### Usage

    	getEdgeList(m, rm.zero=TRUE)

### Arguments

`m` | - An adjacency matrix.
`rm.zero` | - A boolean to indicate whether zero weight edges should be excluded from the edge list.

### Author(s)

Nathan S. Watson-Haigh

### Examples

    	data(PCIT)
    	m <- m[1:200,1:200]        # just use a small subset of the data

    	el <- getEdgeList(m)

    	# modify the edge list to include some useful attributes for cytoscape
    	el$sign[el$Weight<0] <- '-'
    	el$sign[el$Weight>0] <- '+'
    	el$Weight <- abs(el$Weight)
    	# write the edge list stuff to a file suitable for import into cytoscape
    	write.table(el, file="el.txt", row.names=FALSE, col.names=TRUE, sep="\t",
    		quote=FALSE)

[Package PCIT version 1.5-3 Index]