To test network inference tools, we first need to build a synthetic dataset.
library(seqtime)
n = 2
x = seq(from=0, to=0.8, by=0.4)
set = "_env"
klemm = NetworkUtils::generateKlemms(10, 100, 10, 0.05)
klemms = allklemm[[1]]
klemmadj = allklemm[[2]]
envdata = generateSets(n=n, klemms=klemms, species=100, samples=80, x=x, mode="env", name=set)
We can now use network inference tools to reconstruct networks from the original dataset. As we decided to run SparCC and CoNet from the original command line implementations, we first need to write .txt files from the networks. We can analyse these networks with a Bash script.
writeSets(n, x, envdata)
writeFeatures(n, x, edges)
For the tools available through R, we made a little convenience wrapper (callTools). This wrapper runs network inference for all your datasets with all chosen tools, and performs the analysis. CoNet and SparCC require a little parsing with readCoNet and readSpar (not shown).
callTools(envdata, klemmadj, toolnames=c("SpiecEasi GL", "SpiecEasi MB", "gCoda", "Spearman"), set, x, n, absolute = TRUE, mode="env")
The final steps make use of the analysis functions in NetworkUtils. plotSeries and plotPrecisionvsRecall help plot network properties, while we can calculate hub species with analyseHubs and plot overlaps with plotSuperSet.