ChiLiubio / microeco

An R package for data analysis in microbial community ecology
GNU General Public License v3.0
202 stars 58 forks source link

get_node_table failed to calculate node roles for all taxa #397

Closed scilexenko closed 1 month ago

scilexenko commented 2 months ago

Hello Chi,

Sorry for bothering you again. Your package is really nice, but I still have some issues. This time is for the calculation of the node properties. I was doing all as in your vignette, but strangely I fail to obtain the Zi and Pi scores for all nodes in my networks.

Here is my code :

library(meconetcomp)

  code_network %<>% cal_module("cluster_fast_greedy") #cluster_edge_betweenness
  tmp <- cal_network_attr(code_network)
  tmp
  #Node and edge properties extraction for all networks
  code_network %<>% get_node_table(node_roles = T) %>% get_edge_table

  code_network$CNA$plot_taxa_roles()

Output :


tmp
                                CNA          SNA          SMA          SVA
Vertex                 2.730000e+02 239.00000000 237.00000000 193.00000000
Edge                   1.135000e+03 710.00000000 720.00000000 597.00000000
Average_degree         8.315018e+00   5.94142259   6.07594937   6.18652850
Average_path_length    3.386883e+00   1.01545389   1.10249842   1.02327881
Network_diameter       1.100000e+01   3.00000000   6.00000000   3.00000000
Clustering_coefficient 9.903641e-01   0.99826064   0.99785321   0.99780461
Density                3.056992e-02   0.02496396   0.02574555   0.03222150
Heterogeneity          1.188565e+00   0.97160553   0.93377109   0.94492387
Centralization         8.340067e-02   0.05066629   0.05052564   0.06673683
Modularity             7.522883e-01   0.87776546   0.88047093   0.84427743

head(code_network$CNA$res_node_table, 5, 6)

name degree betweenness_centrality closeness_centrality eigenvector_centrality
JC017                                                       JC017      3                    312          0.003986968           4.933156e-17
Cortinarius                                           Cortinarius      1                      0          0.355142403           1.427876e-17
Burkholderiaceae_A_580492 Family Burkholderiaceae_A_580492 Family      1                      0          1.024390244           2.328749e-17
Steroidobacteraceae Family             Steroidobacteraceae Family      2                      3          0.176932277           6.923129e-17
Agrobacterium                                       Agrobacterium      2                      0          0.003253644           5.307992e-17
                                 Abundance module           z  p       taxa_roles     Kingdom            Phylum                  Class
JC017                            13.604663     M1  0.08904198  0 Peripheral nodes k__Bacteria   p__Bacteroidota         c__Bacteroidia
Cortinarius                       7.035300    M21 -0.57735027  0 Peripheral nodes    k__Fungi  p__Basidiomycota      c__Agaricomycetes
Burkholderiaceae_A_580492 Family  4.219529    M41          NA NA             <NA> k__Bacteria p__Proteobacteria c__Gammaproteobacteria
Steroidobacteraceae Family        2.299310    M14  0.44721360  0 Peripheral nodes k__Bacteria p__Proteobacteria c__Gammaproteobacteria
Agrobacterium                     1.238649     M1 -0.44520992  0 Peripheral nodes k__Bacteria p__Proteobacteria c__Alphaproteobacteria
                                                     Order                       Family                               Genus
JC017                                     o__Bacteroidales         f__Marinilabiliaceae                            g__JC017
Cortinarius                                  o__Agaricales            f__Cortinariaceae                      g__Cortinarius
Burkholderiaceae_A_580492 Family o__Burkholderiales_592524 f__Burkholderiaceae_A_580492 g__Burkholderiaceae_A_580492 Family
Steroidobacteraceae Family           o__Steroidobacterales       f__Steroidobacteraceae       g__Steroidobacteraceae Family
Agrobacterium                      o__Rhizobiales_A_500471     f__Rhizobiaceae_A_500471                    g__Agrobacterium

image

Thanks for your help in advance, Ivan

ChiLiubio commented 2 months ago

Hi. I see only a part of nodes have NA in zi and pi. Is it? If so, it is normal. 图片

Best, Chi

scilexenko commented 2 months ago

Okay.. So according to this, I have only peripheral nodes. And all others are NA. I wonder why is it so, and isn't it suspicious.

ChiLiubio commented 2 months ago

This case is very common. In fact, it is challenging to infer real and direct associations between taxa based on community data. Different methods can yield significantly different networks, and correspondingly, there can be a large difference in Zi and Pi as well. So you can also try to use other method to create networks.