I've been trying to plot a network using networkD3 package in R for a week now. The simpleNetwork
function works normally, but it doesn't allow much control over the appearance of the graph. The forceNetwork
function is there for this purpose: display graph with enriched visual features.
The problem I have is pretty much the same exposed in this question. I have carefully read the package documentation, and tried the solution proposed in the above thread, with no luck: all I get is a cloud of nodes with no edges linking them.
Here my data.frame
s:
edg
Gene1 Gene2 Prob
1 22 3
2 22 6
3 22 6
4 22 9
5 22 3
6 22 4
7 22 8
8 22 4
9 22 6
10 22 8
11 22 6
12 22 10
13 22 6
14 22 3
15 22 6
16 22 6
17 22 0
18 22 4
19 22 6
20 22 4
vert
Symbol Chr Expr
1 21 9
2 17 10
3 17 0
4 20 0
5 6 9
6 5 11
7 12 0
8 1 20
9 17 11
10 17 7
11 17 11
12 10 0
13 17 0
14 7 7
15 17 6
16 17 0
17 2 5
18 5 10
19 17 10
20 17 9
21 12 4
22 3 2
Well, this results in the above mentioned cloud of nodes with no edges. Same thing if I change 'Symbol' column with actual labels I'd put on the nodes (respecting the order of Links' table, as required by the package).
Note that the package illustrates the use of this function with this example, and if you open the datsets used (MisLinks, MisNodes), their content is the same as mine, except for the labels of the nodes. Running that very same example works; running with my data does not.
Here is the function I use to plot the network:
forceNetwork( Links = edg, Nodes = vert, Source = "Gene1", Target = "Gene2",
Value = "Prob", NodeID = "Symbol", Group = "Chr", opacity = 0.7,
colourScale = "d3.scale.category20b()", Nodesize = "Expr", zoom = T,
legend = T )
Every other property is correctly displayed (node size, legend, colours), but I keep seeing no edges. There must be a mistake somewhere in my datasets, which I cannot find in any way.