stefpeschel / NetCoMi

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

Error message when using netConstruct (measure=ccrepe) #50

Closed charlene003 closed 2 years ago

charlene003 commented 2 years ago

Hi Stefanie,

Thank you for creating this really cool useful package. I would like to create a microbiome network analysis of relative abundance OTUs and compare them between high and low values of Variable X.

I tried the following code:

net_single <- netConstruct(highVariableX, measure = "ccrepe" ) But the error message followed:

_Infos about changed arguments: Measure 'ccrepe' needs fractions as input. 'normMethod' changed to 'fractions'.

Samples with NAs removed. Error in netConstruct(highVariableX, measure = "ccrepe") : No samples remaining after filtering._

However when I try using the ccrepe package, it manages to run with this code and produces a dataframe of p value, zstat, simscore, and q values, and the below warning messages:

testoutput <- ccrepe(x=highVariableX, iterations=20, min.subj=10)

_Warning message: In preprocessdata(CA) : Excluding subject(s) 8, 120, 130, 226, 263, 280 from x because they have missing values.

Question:

  1. What am I doing wrong in the netConstruct?
  2. How can i then visualise my output from the ccrepe package in the next step of the NetCoMi package as it is not a microNet file?

(I would also like to confess that I am a very novice R user and apologies in advance if the solution is obvious) Thanks much! charlene

stefpeschel commented 2 years ago

Hey Charlene,

Thanks for using NetCoMi.

As the error says, there are no samples remaining after the filter step, so it is not related to the association measure you are using. Please ensure that your count matrices have row and column names. This is a common issue leading to your error, which I have already fixed on develop branch. Unfortunately, it still occurs with the current version on main branch.

You can follow my tutorial "TUTORIAL_cross-domain_associations" for an example on how to pass a pre-computed association matrix to netConstruct().

In principle, you just have to pass the association matrix, computed with ccrepe, to the data and data2 arguments and set the dataType argument appropriately. Then, follow the usual workflow:

assoMat1 <- ccrepe(...)$sim.score
assoMat2 <- ccrepe(...)$sim.score

diag(assoMat1) <- diag(assoMat2) <- 1

net <- netConstruct(data = assoMat1, 
                    data2 = assoMat2, 
                    dataType = "correlation",
                    ...)

netprops <- netAnalyze(net, ...)

Let me know if the error persits.

Best, Stefanie

charlene003 commented 2 years ago

Thanks so much Stefanie for the really prompt response!

I checked that the rows/columns had names but still got the same error. It's probably me making a R error rather than the package, and I will try it out again and let you know if the error persists.

I tested out importing the pre-computed association matrix with the tutorial and the example code you shared and it works, thanks!