stefpeschel / NetCoMi

Network construction, analysis, and comparison for microbial compositional data
GNU General Public License v3.0
146 stars 26 forks source link

Is it possible to input a SpiecEasi network? #63

Closed Valentin-Bio-zz closed 2 years ago

Valentin-Bio-zz commented 2 years ago

Hello previously I've done a spiecEAsi network analysis. and want to know if the output of the network builing process can be the input of the netAnalyze() function.

When I run netAnalyze() over the SPieceasi network I got this message:

netAnalyze(net = oral_AR_net, centrLCC = TRUE, clustMethod ="cluster_fast_greedy", hubPar = "eigenvector", weightDeg = FALSE, normDeg = F ) Error in netAnalyze(net = oral_AR_net, centrLCC = TRUE, clustMethod = "cluster_fast_greedy", : class(x) == "microNet" is not TRUE

stefpeschel commented 2 years ago

Hi, Yes you can construct networks with association matrices produced with SpiecEasi. Just pass the SpiecEasi output to the data argument of netConstruct() and set dataType to "condDependence". Your code won't work because netAnalyze() needs a microNet object returned by netConstruct() as input.

Valentin-Bio-zz commented 2 years ago

Hello Stefanie! thanks for your answer.

This is what I tried:

spieceasi_net <- readRDS("spieceasi_net.RDS")

oral_AR_netcomi <- netConstruct(data = spieceasi_net, dataType = "condDependence")

and I got this error message:

Error in condition_handling(dataType = dataType, assoType = assoType, : Sample size necessary for Student's t-test.`

The student's t-test is used for what purpose ?. My naive attempt to address this error was to add the sampleSIze parameter to the function which is retrieved frpm the respective phyloseq object:

oral_AR_netcomi <- netConstruct(data = spieceasi_net, dataType = "condDependence", 
                                sampleSize = 182)

But I got another error message:

*Sparsify associations via 't-test' ... Error in assoVec sqrt(df) : non-numeric argument to binary operator**

The error is appointing to the sparseMethod argument? if so , I specified it to be "threshold" but again I got the error message regarding to "non-numeric argument"

oral_AR_netcomi <- netConstruct(data = oral_AR_net, dataType = "condDependence", 
                                sampleSize = 182, sparsMethod = "threshold") 

**Sparsify associations via 'threshold' ... Error in abs(assoNew) : non-numeric argument to mathematical function**
stefpeschel commented 2 years ago

Hi Valentin,

Please set the arguments zeroMethod, normMethod, and sparsMethod to "none" because SpiecEasi has already methods for zero handling (pseudo count), normalization (clr transformation), and sparsification (model selection depending on your choice) included.

If you used NetCoMi's inbuilt SpiecEasi approach, the arguments would be set to "none" automatically, but since you use an association matrix for network construction, the function cannot know, which steps have already been done. Then, it's even more important to make familiar with the arguments and set them wisely.

Best, Stefanie

Valentin-Bio-zz commented 2 years ago

Thanks so much for your help Stefanie, besides that, I forgot to correctly input the adjacency matrix to the data = argument using: data = as.matrix(symBeta(getOptBeta(my_net)))