microeco icon indicating copy to clipboard operation
microeco copied to clipboard

No valid result obtained for this network

Open UhP88 opened this issue 1 year ago • 8 comments

Thank you for this helpful package and tutorial... I am trying to construct a network analysis and plot with below steps. However I get an error on the way. Below is the code and warnings/error messages I get. What could be the reason for not getting valid results.

Thank you in advance

dataset <- microtable$new(sample_table = MicroEco_SampleInfo, otu_table = MicroEco_Species_Count) tY <- trans_network$new(dataset = dataset, cor_method = "spearman", filter_thres = 0.001) tY$cal_network(COR_p_thres = 0.01, COR_cut = 0.6) ---------------- 2023-07-18 09:40:16 : Start ---------------- Perform p value adjustment with fdr method ... ---------------- 2023-07-18 09:40:16 : Finish ---------------- The result network is stored in object$res_network ... Warning message: In length(vattrs[[name]]) <- vc : length of NULL cannot be changed tY$cal_module() Totally, 3 modules are idenfified ... Modules are assigned in network with attribute name -- module ... tY$get_node_table() The nodes (6) with NaN in z will be filtered ... Error in private$assign_module_roles(zp) : No valid result obtained for this network! tY$plot_network(method = "ggraph") Run get_node_table function to get or update the node property table ... The nodes (6) with NaN in z will be filtered ... Error in private$assign_module_roles(zp) : No valid result obtained for this network!

UhP88 avatar Jul 18 '23 00:07 UhP88

Hi. Could you please attach your dataset so that I can reproduce your result? Please save your dataset following the tutorial (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function). Please also provide your microeco version. Thanks.

ChiLiubio avatar Jul 18 '23 01:07 ChiLiubio

Thank you so much for your prompt reply. Below attached is the test data file and the micro version is 0.8.0

Thank you again...

On Jul 18, 2023, at 10:59, Chi Liu @.***> wrote:

Hi. Could you please attach your dataset so that I can reproduce your result? Please save your dataset following the tutorial (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function https://chiliubio.github.io/microeco_tutorial/notes.html#save-function). Please also provide your microeco version. Thanks.

— Reply to this email directly, view it on GitHub https://github.com/ChiLiubio/microeco/issues/259#issuecomment-1639163096, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASTKPYUWVTCCUFAF2HJWHSTXQXUX3ANCNFSM6AAAAAA2NU4FWQ. You are receiving this because you authored the thread.

UhP88 avatar Jul 18 '23 14:07 UhP88

Hi. I find nothing in the attachment. Please attach the compressed data in this github issue page. Thanks.

ChiLiubio avatar Jul 19 '23 01:07 ChiLiubio

Sorry for the error.. The data set was not attached previously as I replied through email. dataset_TEST.zip

UhP88 avatar Jul 19 '23 12:07 UhP88

Hi. Please first update your microeco package to v0.20.0 and try again. I have tested your steps with my package v0.20.0. All the steps are ok. Please tell me if the error is still there.

ChiLiubio avatar Jul 20 '23 01:07 ChiLiubio

I updated the package and did the analysis again.. I am getting the same error when using gggraph. But I was able to save the results as an igraph and view through Gephi.. Thank you for your help!!!

UhP88 avatar Jul 20 '23 14:07 UhP88

Hi Chi, I am now using the v1.0.0, and got the similar error when running this line : t1$get_node_table(node_roles = TRUE)

And my network only contained 2 nodes and 1 edge, may I ask for some advice, is it because of my data or the way I preprocessed it (I rarefied to even depth) ?

Here's my code:

> ps <- phy_1wk
> sample_data(ps)$Group <- sample_data(ps)$cs_1y
Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
Also defined by ‘tidytree’
Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
Also defined by ‘tidytree’
Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
Also defined by ‘tidytree’
Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
Also defined by ‘tidytree’
> sample_data(ps)$Group <- relevel(sample_data(ps)$Group, ref = "Low")
Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
Also defined by ‘tidytree’
Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
Also defined by ‘tidytree’
Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
Also defined by ‘tidytree’
Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
Also defined by ‘tidytree’
> otu <- otu_table(ps)
> dim(otu)
[1] 25975   498
> summary(rowSums(otu) == 0)
   Mode   FALSE    TRUE 
logical    1895   24080 
> 
> meco_dataset <- phyloseq2meco(ps)
24080 taxa with 0 abundance are removed from the otu_table ...
> meco_dataset$tax_table %<>% .[grepl("Bacteria|Archaea", .$domain), ]
> meco_dataset$tax_table$Phylum <- meco_dataset$tax_table$phylum
> 
> meco_dataset$tidy_dataset()
> print(meco_dataset)
microtable-class object:
sample_table have 498 rows and 71 columns
otu_table have 1865 rows and 498 columns
tax_table have 1865 rows and 11 columns
phylo_tree have 1865 tips
rep_fasta have 1865 sequences
> 
> meco_dataset$sample_sums() %>% range #2020 197004  -> 2020 2020
[1]   2020 197004
> 
> meco_dataset$rarefy_samples(sample.size = 2020)
652 features are removed because they are no longer present in any sample after random subsampling ...
652 taxa with 0 abundance are removed from the otu_table ...
> # The parameter cor_method in trans_network is used to select correlation calculation method.
> # default pearson or spearman correlation invoke R base cor.test, a little slow
> t1 <- trans_network$new(dataset = meco_dataset, cor_method = "spearman", filter_thres = 0.05)
After filtering, 4 features are remained ...
The correlation result list is stored in object$res_cor_p ...
> # return t1$res_cor_p list, containing two tables: correlation coefficient table and p value table
> 
> t1 <- trans_network$new(dataset = meco_dataset, cor_method = "spearman", use_WGCNA_pearson_spearman = TRUE, filter_thres = 0.05)
After filtering, 4 features are remained ...
The correlation result list is stored in object$res_cor_p ...
> 
> # construct network; require igraph package
> t1$cal_network(COR_p_thres = 0.05, COR_optimization = TRUE)
---------------- 2023-08-02 16:52:45.777463 : Start ----------------
Perform p value adjustment with fdr method ...
Start COR optimizing ...
[1] 0.05
[1] 0.1
[1] 0.2
[1] 0.25
[1] 0.3
[1] 0.35
[1] 0.4
[1] 0.45
[1] 0.5
[1] 0.6
[1] 0.65
[1] 0.7
[1] 0.75
[1] 0.8
The optimized COR threshold: 0.05...

---------------- 2023-08-02 16:52:45.872099 : Finish ----------------
The result network is stored in object$res_network ...
> # use arbitrary coefficient threshold to contruct network
> # t1$cal_network(COR_p_thres = 0.01, COR_cut = 0.7)
> # return t1$res_network
> 
> 
> # invoke igraph cluster_fast_greedy function for this undirected network 
> t1$cal_module(method = "cluster_fast_greedy")
Use cluster_fast_greedy function to partition modules ...
Totally, 2 modules are idenfified ...
Modules are assigned in network with attribute name -- module ...
> 
> library(rgexf)
> # require rgexf package to be installed
> t1$save_network(filepath = "network.gexf")
> 
> # calculate network attributes
> t1$cal_network_attr()
Result is stored in object$res_network_attr ...
> t1$res_network_attr
> 
> # get node properties
> t1$get_node_table(node_roles = TRUE)
Error in private$assign_module_roles(zp) : 
  No valid result obtained for this network!



Thank you for you time !!
Jay

finally-jay avatar Aug 02 '23 14:08 finally-jay

I am now using the v1.4.0, and got the similar error when running this line : soil_amp_network %<>% get_node_table(node_roles = TRUE) %>% get_edge_table, Error in private$assign_module_roles(zp) : No valid result obtained for this network! Thank you for you time !!

xinguo1236 avatar Jan 27 '24 08:01 xinguo1236