Reputation: 49
I have a gene co-expression data frame which contains 'from' nodes (Probe_ID1), 'to' nodes (Probe_ID2), and the co-expression parameter (Pearson_correlation). I would like to create an undirected network via cytoscape in R. I have tried going through some tutorials where they show how to use expression matrix or separate data table for nodes and edges to create network using Rcy3 and igraph. No luck so far.(https://bioconductor.github.io/BiocWorkshops/cytoscape-automation-in-r-using-rcy3.html) (http://www.vesnam.com/Rblog/viznets5/)
The data frame looks like below-
When I used
- g <- graph_from_data_frame(df, directed = FALSE)
- plot(g, edge.width = E(g)$Pearson_correlation)
I get a static plot which is not very useful!
My goal is to create a graph like below-
Thank you so much for your help.
df <- structure(list(Probe_ID1 = c("1377847_at", "1377847_at", "1374391_at", "1377847_at", "1374391_at", "1371293_at", "1370349_a_at", "1375043_at", "1377847_at", "1374391_at", "1371293_at", "1367896_at", "1370349_a_at", "1367555_at", "1377847_at", "1374391_at", "1371293_at", "1367896_at", "1371400_at", "1377847_at"), Probe_ID2 = c("1374391_at", "1371293_at", "1371293_at", "1367896_at", "1367896_at", "1367896_at", "1367555_at", "1373759_at", "1371400_at", "1371400_at", "1371400_at", "1371400_at", "1367556_s_at", "1367556_s_at", "1370150_a_at", "1370150_a_at", "1370150_a_at", "1370150_a_at", "1370150_a_at", "1387033_at"), Pearson_correlation = c(0.848285270961176, 0.811387513485743, 0.984665285551617, 0.810053803921012, 0.87996593265479, 0.831296522615296, 0.97896759238534, 0.865015908452676, 0.95200088118552, 0.897979364923317, 0.862952264288276, 0.871551804796571, 0.982470139843159, 0.983102257804976, 0.944065566290634, 0.885963573215256, 0.86195415426524, 0.856926733543681, 0.992345494455764, 0.890033683765388 )), class = "data.frame", row.names = c(NA, -20L))
Upvotes: 1
Views: 576
Reputation: 507
Using RCy3, you can do this a couple different ways.
Given your igraph object 'g', you can simply run
RCy3::createNetworkFromIgraph(g)
As long as you have a local instance of Cytoscape running, this function will open an interactive session with your network. You can then change any aspect of the layout or style using 100s of functions in RCy3.
Given your original dataframe, 'df', you can specify source and target columns (even for undirected networks) and load the network by
colnames(df)[1:2] <- c("source", "target") RCy3::createNetworkFromDataFrames(edges=df)
The output in Cytoscape should be identical. And you can carry on with network analysis and visualization.
Upvotes: 0