Learn R Programming

NetPreProc (version 1.2)

Do.sim.matrix.Pearson: Construction of the Pearson correlation matrix

Description

Function to obtain the Pearson correlation matrix between rows of a given matrix.

Usage

Do.sim.matrix.Pearson(M, cut = TRUE, remove.negatives = TRUE, min.thresh = 0)

Value

a square symmetric matrix of the Pearson correlation coefficients computed between the rows of M

Arguments

M

input matrix

cut

if TRUE (def.) at least one edge is maintained for each node, all the other edges are set to 0. If false no edgeis set to 0.

remove.negatives

if TRUE (def) negative values are replaced with 0 in the correlation matrix

min.thresh

minimum allowed threshold (def. 0). If a threshold lower than min.thresh is selected, thanit is substituted by min.thresh. Warning: setting min.thresh to large values may lead to highly disconneted network

Details

You can also "sparsify" the matrix, by putting to 0 all the weights, by setting a threshold such that at least one edge is maintained for each node. The diagonal values are set to 0.

Examples

Run this code
# a gaussian random matrix
D <- matrix(rnorm(20000),nrow=200);
W <- Do.sim.matrix.Pearson (D);
# the same without default parameters
W2 <- Do.sim.matrix.Pearson (D, cut=FALSE, remove.negatives=FALSE, min.thresh=-20);

Run the code above in your browser using DataLab