taowenmicro / ggClusterNet

Microbial ecological network visualization clustering
93 stars 44 forks source link

Error in abs(igraph::E(igraph)$weight) when importing SCNIC network #12

Open weedcentipede opened 1 year ago

weedcentipede commented 1 year ago

Hello there ggClusterNet devs,

Currently, I'm trying to analyzed a correlation network generated by q2-SCNIC (https://forum.qiime2.org/t/q2-scnic-a-tool-for-making-correlation-networks-finding-modules-of-observations-and-summarizing-them/6116) with ggClusterNet, specifically to calculate network properties and visualize them in a ZiPiPlot.

To achieve so, I ran the following command lines,

scnic_graph <- read_graph("./network.gml", format = "gml")

and got the following error when running ZiPiPlot and module.roles functions:

> module.roles(scnic_graph)
Error in data.frame(taxa = names(ki), total_links = ki) : 
  arguments imply differing number of rows: 0, 1

> ZiPiPlot(igraph = scnic_graph)
Error in abs(igraph::E(igraph)$weight) : 
  non-numeric argument to mathematical function

Nevertheless, other functions work, such as:

> node_properties(scnic_graph)
        igraph.degree igraph.closeness igraph.betweenness igraph.cen.degree
   [1,]            73        0.2799599       2.586254e+03                73
   [2,]            71        0.2860946       8.256061e+03                71
   [3,]           176        0.2922594       5.437456e+03               176
   [4,]           146        0.2882195       4.574558e+03               146
   [5,]            80        0.2950993       1.695043e+04                80

> net_properties(scnic_graph)
                              value
num.edges                  2.494200e+04
num.pos.edges              0.000000e+00
num.neg.edges              0.000000e+00
num.vertices               1.400000e+03
connectance                2.546921e-02
average.degree             3.563143e+01
average.path.length        3.600548e+00
diameter                   1.000000e+01
edge.connectivity          0.000000e+00
clustering.coefficient     4.773117e-01
no.clusters                2.000000e+00
centralization.degree      1.003349e-01
centralization.betweenness 3.291377e-02
centralization.closeness   1.435062e+00

Is there any recommendation to overcome this issue? Cheers, Luis Alfonso.