stefpeschel / NetCoMi

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

Error on zero treatment #44

Closed chiehchangchen closed 2 years ago

chiehchangchen commented 2 years ago

Hello Stefanie, Thanks for your cool package. I am quite new in network analysis and R. I was trying using netconstruct on my own dataset. However, error developed when I used zeroMethod="multRepl", but not zeroMethod="pseudo" . Would you help me to work out the problem?

The codes ad error messages are the following: "> net <- netConstruct(physeq,

Zero treatment: Execute multRepl() ... Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Column(s) containing all zeros/unobserved values were found (check it out using zPatterns).

stefpeschel commented 2 years ago

Hey,

Apparently, this error occurs if there are samples whose sum of counts is zero, which can't be handled by the multRepl() function of zCompositions package. You can solve this issue by setting NetCoMi's filters appropriately, e.g.:

netConstruct(physeq, 
   filtSamp = "totalReads",
   filtSampPar = list(totalReads = 500),
   measure = "pearson",
   normMethod = "clr", 
   zeroMethod = "multRepl",
   sparsMethod = "threshold", 
   thresh = 0.3,
   verbose = 3)

Please see the help page of netConstruct for possible values.

The next update will include a bug fix to catch samples with an overall sum of zero. But for now, setting filters should solve this issue.

Please reopen this issue, if the error still occurs.

Best, Stefanie