diff --git a/Main.R b/Main.R index 4b018db..531ebfb 100644 --- a/Main.R +++ b/Main.R @@ -32,7 +32,7 @@ end_time <- Sys.time()-start_time ############################## source("./Rfunction/SensitivityPlot.R") -pl = SensitivityPlot(folder = "SIR_sensitivity/") +pl = SensitivityPlot(folder = "SIR_sensitivity/", scd_folder = "SIR_analysis/") pl$TrajS pl$TrajI @@ -85,9 +85,9 @@ source("Rfunction/ModelAnalysisPlot.R") AnalysisPlot = ModelAnalysisPlot(Stoch = F ,print = F, trace_path = "./SIR_analysis/SIR-analysis-1.trace") -AnalysisPlot$plI +AnalysisPlot$plAll -model_analysis(solver_fname = "Net/SIR.solver", +model.analysis(solver_fname = "Net/SIR.solver", parameters_fname = "Input/Functions_list_ModelAnalysis.csv", solver_type = "SSA", n_run = 500, @@ -98,6 +98,6 @@ model_analysis(solver_fname = "Net/SIR.solver", AnalysisPlot = ModelAnalysisPlot(Stoch = T ,print = F, trace_path = "./SIR_analysis/SIR-analysis-1.trace") -AnalysisPlot$plI -AnalysisPlot$HistI -plS \ No newline at end of file + +AnalysisPlot$plAll +AnalysisPlot$plAllMean \ No newline at end of file diff --git a/Rfunction/FunctionSensitivity.R b/Rfunction/FunctionSensitivity.R index d228824..4e3c84f 100644 --- a/Rfunction/FunctionSensitivity.R +++ b/Rfunction/FunctionSensitivity.R @@ -25,4 +25,4 @@ mse<-function(reference, output) diff.Infect <- 1/length(times_ref)*sum(( Infect - I_ref )^2 ) return(diff.Infect) -} \ No newline at end of file +} diff --git a/Rfunction/SensitivityPlot.R b/Rfunction/SensitivityPlot.R index cc079ba..ffa2591 100644 --- a/Rfunction/SensitivityPlot.R +++ b/Rfunction/SensitivityPlot.R @@ -1,13 +1,14 @@ library(ggplot2) -SensitivityPlot <-function(rank=T,folder){ - load(paste0(folder,"SIR-sensitivity.RData")) +SensitivityPlot <-function(rank=T,folder, scd_folder){ + #Changed the folder in which is contained the .RData file + load(paste0(scd_folder,"SIR-analysis.RData")) # Then, we read all the trajectories generated saving them in a list called # ListTraces. List that will be rewritten as a data frame in order to use ggplot. # ConfigID represents the initial condition associated to each trajectory, # which was generated by using the function implemented in the file Functions.R . - listFile<-list.files(folder, + listFile<-list.files(scd_folder, pattern = ".trace") configID<-t(sapply(1:length(listFile), @@ -32,11 +33,11 @@ SensitivityPlot <-function(rank=T,folder){ ListTraces<-lapply(id.traces, function(x){ trace.tmp=read.csv(paste0( - folder,"/SIR-sensitivity-", + scd_folder,"SIR-analysis-", x, ".trace"), sep = "") trace.tmp=data.frame(trace.tmp,ID= x, - rank = rank[which(rank[,2]==paste0("SIR-sensitivity-", + rank = rank[which(rank[,2]==paste0("SIR-analysis-", x, ".trace")),1]) return(trace.tmp) @@ -46,13 +47,14 @@ SensitivityPlot <-function(rank=T,folder){ function(x){ recovery<-config[[4]][[x]][[3]] infection<-config[[5]][[x]][[3]] - rnk.tmp=data.frame(ID=x,distance = rank[which(rank[,2]==paste0("SIR-sensitivity-", + rnk.tmp=data.frame(ID=x,distance = rank[which(rank[,2]==paste0("SIR-analysis-", x, ".trace")),1], rec_rate=recovery, inf_rate=infection) return(rnk.tmp) }) + rank2 <- do.call("rbind", rank2) traces <- do.call("rbind", ListTraces)