Tuesday, January 18, 2011

R Convert Correlation Matrix to Gene Pairs

http://tolstoy.newcastle.edu.au/R/help/04/10/5127.html


r <- cor(x) y <- which(lower.tri(r), TRUE) # returns indices of lower triangle of matrix z <- data.frame(row = rownames(r)[y[, 1]], col = colnames(r)[y[, 2]], cor = r[y]) subset(z, abs(cor) > 0.5)

No comments: