Question: From Distance Matrix To Network
2
SamGG20 wrote:

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.

network cytoscape distance • 7.8k views
modified 22 months ago by Kevin Blighe69k • written 7.4 years ago by SamGG20
1
Leandro Lima960 wrote:

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
Kevin Blighe69k wrote:

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
)
`````` 0
Woa2.8k wrote:

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.