microeco icon indicating copy to clipboard operation
microeco copied to clipboard

Convert module to microtable object (trans_comm)

Open anabelvonjackowski opened this issue 1 year ago • 6 comments

Dear microeco team,

What an incredible package you have built!

I am trying to construct a network with the end goal of running the plot_spe_func_perc. section Explainable-class of the tutorial (v1.4.0)

My code is as follows:

micro <- phyloseq2meco(all_data) otu_table_16S <- micro$otu_table taxonomy_table_16S <- micro$tax_table taxonomy_table_16S_tidy <- taxonomy_table_16S %>% tidy_taxonomy sample_info_16S <- micro$sample_table[,c(1:11)] env_data_16S <-micro$sample_table[,-c(1:11)]

dataset <- microtable$new(sample_table = sample_info_16S, otu_table = otu_table_16S, tax_table = taxonomy_table_16S) dataset$filter_pollution(taxa = c("mitochondria", "chloroplast"))

use tidy_dataset() to make OTUs and samples information consistent across files dataset$tidy_dataset()

create trans_network object t1 <- trans_network$new(dataset = dataset, cal_cor = "base", taxa_level = "OTU", filter_thres = 0.000001, cor_method = "spearman")

create correlation network t1$cal_network(p_thres = 0.01, COR_cut = 0.7) t1$res_network

add modules t1$cal_module() t1$res_network convert module info to microtable object meco_module <- t1$trans_comm(use_col = "module")

running the trans_comm, I get the following error "Run get_node_table function to get the node property table ... Error in get(as.character(FUN), mode = "function", envir = envir) : object 'FUN' of mode 'function' was not found"

but when I run get_node_table(node_roles = TRUE) I receive the same error: Error in get(as.character(FUN), mode = "function", envir = envir) : object 'FUN' of mode 'function' was not found

I have been searching through trans_network.R for the longest time and cant figure out what my mistake is. Would you happen to know?

Thanks and best regards, Anabel

anabelvonjackowski avatar Feb 08 '24 19:02 anabelvonjackowski

Hi. Could you please attach your t1 so that I can reproduce your issue? To save it, please follow the steps in the tutorial (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function) and attach the compressed object.

Best, Chi

ChiLiubio avatar Feb 09 '24 02:02 ChiLiubio

Dear Chi, The t1 is attached- Thanks for your help :-) vonjackowski_t1_test.RData.zip

anabelvonjackowski avatar Feb 10 '24 08:02 anabelvonjackowski

Hi. I run those steps and find it is ok. Could you please recreate an R project and try to run these steps again?

library(microeco)
load("vonjackowski_t1_test.RData")
t1$cal_module()
t1$get_node_table()
meco_module <- t1$trans_comm(use_col = "module")

ChiLiubio avatar Feb 13 '24 03:02 ChiLiubio

Hi Chi,

I did. After the trans_comm(use_col = "module") function I get the following error: "No sample_table provided, automatically use colnames in otu_table to create one ...", which is weird cause I do have t1$sample_table, right?

vonjackowski_t1_test_v2.zip

anabelvonjackowski avatar Feb 13 '24 10:02 anabelvonjackowski

Hi. This is a message, not an error. The message is inside the microtable class and invoked when no sample_table is provided. The sample_table in t1 is for samples, but the sample names in created microtable is each module name, not the sample names. So the following analysis will do not need metadata.

ChiLiubio avatar Feb 14 '24 07:02 ChiLiubio

So you can view the automatically created sample_table in the result, i.e. View(meco_module$sample_table).

ChiLiubio avatar Feb 14 '24 07:02 ChiLiubio