From Distance Matrix To Network
3
2
Entering edit mode
8.8 years ago
SamGG ▴ 20

Hi,

I would like to represent the linkage (or correlation) of some data (let say genes) with Cytoscape. So I would like a way to transform a distance (or so) into a network (one-to-one links). Distance filtering is certainly needed in order to avoid a dense and ugly network graphics.

a/ is there an easy way to do such filtering and conversion with R (or Cytoscape directly)?

b/ is there a tool that allows one to move a cursor in order to change the filtering threshold and to see the resulting network?

Cheers.

distance network cytoscape • 11k views
2
Entering edit mode
3.3 years ago

Just adding knowledge to this old question:

I have a tutorial here on Biostars in which I do this via igraph: Network plot from expression data in R using igraph

library(igraph)

#Create a graph adjacency based on correlation distances between genes in  pairwise fashion.
as.matrix(as.dist(cor(t(estrogenMainEffects), method="pearson"))),
mode="undirected",
weighted=TRUE,
diag=FALSE
) 1
Entering edit mode
8.8 years ago
Leandro Lima ▴ 960

Hello!

An example with a matrix 5x5:

M <- matrix(rnorm(25), nrow=5)
colnames(M) <- letters[1:5]
rownames(M) <- letters[1:5]
edges <- NULL
for (i in 1:nrow(M)) {
for (j in 1:ncol(M)) {
edges <- rbind(edges, c(rownames(M)[i], rownames(M)[j], M[i,j]))
}
}

colnames(edges) <- c('node1', 'node2', 'value')
write.table(edges, 'edges.txt', row.names=FALSE, quote=FALSE, sep='\t')


After this, it is possible to use Cytoscape to load 'edges.txt' and its filters to remove the edges according to a threshold.

1
Entering edit mode
8.8 years ago
Woa ★ 2.9k

I guess you'll be using the distance between the nodes as edge weights. In that case you can filter edges based on their weights which in this case is the distance.