netDiff: Network Difference

Description Usage Arguments Details Value Author(s) Examples

View source: R/netDiff.R

Description

Returns the difference of the input matrices. Output object is an adjacency matrix where edges present in matrix1 but not matrix2 are returned. The edge value is maintained provided cutoff = NULL. Edges in both graphs failing to meet the cutoff, if provided, are set to zero before taking the graph difference.

Usage

1
netDiff(matrix1, matrix2, cutoff=NULL, ...)

Arguments

matrix1

Square matrix (e.g. correlation or adjacency) containing row/column labels

matrix2

Square matrix (e.g. correlation or adjacency) containing row/column labels

cutoff

The cutoff value. Edges less than this value (absolute value considered)are converted to zero.

...

Other parameters.

Details

Matrices must be square and have row and column labels. Output adjacency matrix can be used directly for creating a graph object.

Value

netDiff returns an adjacency matrix containing edges present in matrix1 that are not present in matrix2. Edges below cutoff are set to zero.

Author(s)

Shannon M. Bell

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 #using the state.x77 and USArrest datasets
 #remove data from states for illustration
 ssArrest<-subset(t(USArrests), select=-c(Alabama,Colorado,Delaware))
 ssState<-subset(t(state.x77), select=-c(Alabama, Arizona, Iowa))
 arrestCor<-cor(ssArrest)
 stateCor<-cor(ssState)
 dataDiff<-netDiff(stateCor, arrestCor)
 dataDiff[1:15,1:5]
 #Setting a cutoff to remove any edges that are below 0.6 
 dataDiff.6<-netDiff(stateCor, arrestCor, cutoff=0.6)
 dataDiff.6[1:15,1:5]

NetComp documentation built on May 2, 2019, 8:15 a.m.

Related to netDiff in NetComp...