## ----setup, include = FALSE----------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(NetworkUtils)
## ---- eval = FALSE-------------------------------------------------------
# n = 10
# x = seq(from=0, to=1, by=0.1)
# setname = "_env"
# wdir="insertfilepath" # Needs to be supplied for the other sections of code to restore your filepath
# setwd(wdir)
#
# allklemm = NetworkUtils::generateKlemms(10, 100, 10, 0.05) # the generateKlemms function has two outputs:
# klemms = allklemm[[1]] # a matrix with interaction strengths, used to generate datasets
# klemmadj=allklemm[[2]] # an adjacency matrix, used to evaluate inferred networks
#
# # This function generates the datasets, and stores all values generated by the envGrowthChanges function
# envdata = generateSets(n=n, klemms=klemms, species=100, samples=80, x=x, mode="env", name=set1)
#
# # We ran CoNet and SparCC from a VM; make sure you set the working directory correctly before using writeSets or writeFeatures
# writeSets(n, x, envdata)
# # CoNet can use these features in network construction. This is analogous to measuring the pH or temperature and including it as features in CoNet's network inference.
# edges = readRDS("_env_replication_envfactors.rds")
# writeFeatures(n, x, edges)
## ---- eval = FALSE-------------------------------------------------------
# # This function runs network inference and analyses the inferred networks
# callTools(envdata, klemmadj, toolnames=c("SpiecEasi GL", "SpiecEasi MB", "gCoda", "Spearman"), setname, x, n, absolute = TRUE, mode="env")
#
# # After running bashscript_CoNet.bash, this function can be used to parse the CoNet output
# readCoNet(name="brown", x=x, n=n, alldata=envdata, setname, tool="CoNet Brown", klemmadj=klemmadj, wdir=wdir, absolute=TRUE)
# # The factors add 2 columns and rows to the adjacency matrix, which need to be stripped
# conetbrown <- readRDS("C:/Users/u0118219/Box Sync/Simulation/params/CoNet_brown_env_networks.rds")
# for (i in 1:11){
# for (j in 1:10){
# conetbrown[[i]][[j]] = conetbrown[[i]][[j]][1:100,1:100]
# }
# }
# # The stripped networks can be supplied to analyseOutput
# analyseOutput(conetbrown, klemmadj, tool="brown", setname, x, n, absolute = TRUE, alldata=envdata)
# # SparCC also needs to be read into an adjacency matrix
# readSpar(n=n, x=x, alldata=envdata, mode="env", setname, klemmadj, wdir=wdir)
#
## ---- fig.width=7, fig.height=6------------------------------------------
library("ggplot2")
library("NetworkUtils")
library("SuperExactTest")
library("viridis")
col1 = viridis(8)
col1[4] = "#A437EE"
col1[1] = "#000000"
col2 = c(col1[1:3], col1[5:8])
col1 = c(col1[1:3], col1[5:8], col1[4])
col3 = c("#A437EE", col2)
n = 10
x = seq(from=0, to=1, by=0.1)
spiecmb = readRDS("../data/Environmental factor networks/SPIEC-EASI MB_env_results.rds")
spiecgl = readRDS("../data/Environmental factor networks/SPIEC-EASI GL_env_results.rds")
spear = readRDS("../data/Environmental factor networks/Spearman_env_results.rds")
spar = readRDS("../data/Environmental factor networks/SparCC_env_results.rds")
coda = readRDS("../data/Environmental factor networks/gCoda_env_results.rds")
fisher = readRDS("../data/Environmental factor networks/CoNet Fisher_env_results.rds")
brown = readRDS("../data/Environmental factor networks/CoNet Brown_env_results.rds")
klemmspecs = readRDS("../data/klemmspecs.rds")
results = list(brown, fisher, coda, spar, spear, spiecgl, spiecmb)
tools = c("CoNet Brown", "CoNet Fisher", "gCoda","SparCC", "Spearman", "SPIEC-EASI GL", "SPIEC-EASI MB")
plotPrecisionvsRecall(results, tools, x, colours=col2, mode="env")
plotSeries(results, klemmspecs, tools, x, "Degree", axis="Strength", mode="quadratic", colours = col1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.