netDiff {NetComp} | R Documentation |
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.
netDiff(matrix1, matrix2, cutoff=NULL, ...)
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. |
Matrices must be square and have row and column labels. Output adjacency matrix can be used directly for creating a graph object.
netDiff
returns an adjacency matrix containing edges present in
matrix1
that are not present in matrix2
. Edges below
cutoff
are set to zero.
Shannon M. Bell
#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]