marioangst / motifr

Motif analysis in multi-level networks
https://marioangst.github.io/motifr/
Other
13 stars 2 forks source link

plot_mnet does not draw graphs without edges #17

Closed tseppelt closed 4 years ago

tseppelt commented 4 years ago

I tried

 show_motif(ml_net, '2,2[IV.A]')

(this is the 4-motif without edges) and got

 Fehler in `vertex.attributes<-`(graph, index = index, value = value) : 
  Invalid attribute value length, must match number of vertices 
9. stop("Invalid attribute value length, must match number of vertices") 
8. `vertex.attributes<-`(graph, index = index, value = value) 
7. `vertex_attr<-`(`*tmp*`, value = node_attr) 
6. network_to_igraph(x) 
5. as_tbl_graph(network_to_igraph(x)) 
4. as_tbl_graph.network(net) 
3. tidygraph::as_tbl_graph(net) at visualize_mnet.R#18
2. integrateR::plot_mnet(subgraph, type_attr = type_attr, ...) at count_motifs.R#224
1. show_motif(ml_net, "2,2[IV.A]") 

The problem is in as_tbl_graph().

tseppelt commented 4 years ago

This bug does not only affect pathological motifs. For example,

show_motif('2,2[VI.A]')

does not work either. This motif contains only one empty level.

marioangst commented 4 years ago

Possibly not very stable fix, but added additional conversion for statnet objects e42f6e918aa369c287838030d1a8cc6d4e617de2