-
Notifications
You must be signed in to change notification settings - Fork 1
/
HCV_model_exe2.R
112 lines (106 loc) · 4.42 KB
/
HCV_model_exe2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#############Executable file ######################################
#########################################
### Scenario: We need to choose the treatment scenario that we want to apply
### Simulation starts at time of HCV infection
### This file include all the required packages, and call all the required sources
### In this file the Cohort Size and the duration of simulation are defined.
#####################################################################
cat("\014")
cat('\n')
cat('***********************************************************\n')
cat('Mathematical Modeling of Hepatitis C Virus Progression Disease\n')
cat('\t \t 2017')
cat('\n')
cat ('\n \t Version: 10')
cat('\n Requires files: \n')
cat('simulate_cohort.r: To do the simulation \n')
cat('baseline.r: Identify the baseline chracteristics \n')
cat('hazard_fun.r: Calls file specifying the hazard functions \n')
cat('params_cov.r: To choose parameters file \n')
cat('scenario_treatFx.r: To choose the treatment scenario \n')
cat('simulate_cohort.r: To do the simulation \n')
cat('TransitionTime.r: Shows all the possible transitions\n')
cat('***********************************************************\n')
#############################################################
setwd("~/HCV_project_2017/hcv_git/hcv_modeling")
rm(list = ls())
wd = getwd()
######################### Required Packages #################
require(MASS)
require(msm)
require(mstate)
require(survival)
require(splines)
require(plyr)
require(gems)
#########################################################
start.time<-Sys.time()
########################################################
cohortSize <- 50 # specify how many patients to simulate
maxTime<-100 # specify duration of simulation in years
setwd("../Required_Data")
data <- read.table("baseline_data.txt", header=T)
setwd("~/HCV_project_2017/hcv_git/hcv_modeling")
all_cases = matrix(NA,1,52)
setwd("~/HCV_project_2017/hcv_git/hcv_modeling")
#for (case in 1: nrow(data))
for (case in 219: nrow(data))
{
print(case)
#####################Source Codes ###########################
source("baseline.r") # call file specifying baseline characteristics
setwd("~/HCV_project_2017/hcv_git/hcv_modeling")
cat('***********************************************************\n')
#ans <- readline(prompt="Please enter the treatment scenario you are interested to study: Treating patients in (and after) stage F0, F1, F2, F3, F4 or BL (baseline) \t")
ans <- "F2"
source(sprintf("scenario_treat%s.r",ans))
#source("scenario_treatF3.r")
source("hazard_fun.r") # call file specifying the hazard functions
source("params_cov.r") #choose parameters file
source("TransitionTime.r")
source("sim_cohort.r") # call the cohort simulator
cat('***********************************************************\n')
######################################################
setwd(wd)
setwd("../Tables")
#########################################################
########################################################
write.table([email protected], sprintf("SS_%s",case))
all_cases = rbind(as.matrix(all_cases),as.matrix(read.table(sprintf("SS_%s",case))))
setwd("~/HCV_project_2017/hcv_git/hcv_modeling")
}
#####################################
end.time <- Sys.time()
cat('***********************************************************\n')
print("Required time: ")
print (end.time - start.time)
cat('***********************************************************\n')
cat('You can find all the required data in the Table "all_cases"!! \n')
answer <- readline(prompt = "Do you want to save all_cases in Required_Data folder?")
if (answer == "y")
{
setwd("../Required_Data")
write.table(all_cases, "All_cases")
}
setwd("~/HCV_project_2017/hcv_git/hcv_modeling")
cat('***********************************************************\n')
tt <- readline(prompt="Do you want to save the results as a table for post processing (y/n)?")
if (tt == "y")
{
setwd("../Outcomes")
ans <- readline(prompt="Please Enter a File Name:")
write.table([email protected],ans) # save the cohort
Total = cbind([email protected], bl)
write.table(Total, sprintf("Total_results_%s.txt",ans))
}
print("Do you want to do the post processing?")
print("Do you want to do the post processing?")
answer <- readline(prompt="Do you want to do the post processing(y/n)?")
if (answer == "y")
{
setwd("../Outcomes")
source("outcomes.r")
source("out_bc.R")
source("barPlot.r")
source("out_baseline.r")
}