-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.R
More file actions
94 lines (68 loc) · 3.38 KB
/
example.R
File metadata and controls
94 lines (68 loc) · 3.38 KB
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
setwd('C:/Users/hsnutardis/OneDrive - 國立台灣大學/2023 學士班論文/NMA-Robustness-Visualization/')
source("./flow_contribution/R/streamstatistics2.R")
source("./flow_contribution/R/hatmatrix.R")
source("./flow_contribution/R/studycontribution.R")
source("./flow_contribution/R/contributionrow.R")
source("./getflow.R")
source("./getflowplot.R")
source("./robustness.R")
source("./robustnetplot.R")
source("./contrast_robustnetplot.R")
source("./contrast_robustnetplot.R")
library(netmeta)
# install.packages('netmeta')
######
## data example
indata <- read.csv("./example data/diabetes.csv", fileEncoding="UTF-8-BOM")
comparison <- 'ACE:Placebo'
comparison <- 'ACE:ARB'
comparison <- 'BBlocker:CCB'
hatmatrix <- getHatMatrix(indata, type="long_binary", model="random", sm='OR')
##
indata <- read.csv("./example data/hypocalcemia.csv", fileEncoding="UTF-8-BOM")
comparison <- 'Cinacalcet:Placebo'
comparison <- 'Cinacalcet:Parathyroidectomy'
hatmatrix <- getHatMatrix(indata, type="long_binary", model="random", sm='OR')
##
View(get.streams_df(hatmatrix, comparison))
View(get.studies_df(hatmatrix, comparison)$StudyContributionPerFlow)
View(get.studies_df(hatmatrix, comparison)$StudyReport)
getflowplot(indata, hatmatrix, comparison)
View(get.robustness(indata, hatmatrix,comparison)$allvariables)
View(get.robustness(indata, hatmatrix,comparison)$robustness_df)
View(get.robustness(indata, hatmatrix,comparison)$pathrobust)
get.robustness(indata, hatmatrix,comparison)$network_robustness.contrast
get.robustnetworkplot(indata, hatmatrix,comparison)
get.interactive.robustnetworkplot(indata, hatmatrix, comparison, highrisk = F)
get.interactive.robustnetworkplot(indata, hatmatrix, comparison, highrisk = T)
get.contrast_robust(indata, hatmatrix)
get.network_robust(indata, hatmatrix)
get.contrast_robust_plot(indata, hatmatrix)
get.interactive.contrast_robust_plot(indata, hatmatrix, highrisk = F)
get.interactive.contrast_robust_plot(indata, hatmatrix, highrisk = T)
#####################
### to see how the results my function calculates are different from the proportion of rob
proportion.ROB <- get.studies_rob(indata, hatmatrix, comparison)
proportion.ROB$rob_q <- ifelse(proportion.ROB$rob==1, 0.1, ifelse(proportion.ROB$rob==2, 0.5, ifelse(proportion.ROB$rob==3, 0.9, NA)))
proportion.ROB$rob_p <- 1 - proportion.ROB$rob_q
# calculate the proportion of rob for each path
path_flow.df <- unique(subset(proportion.ROB, select=c("path","flow")))
proportion.ROB$pro.rob <- (proportion.ROB$rob_p / 100) * (proportion.ROB$study.cont / proportion.ROB$flow)
proportion.ROB <- aggregate( subset( proportion.ROB, select=c("pro.rob") ), by=list(proportion.ROB$path), FUN=sum)
names(proportion.ROB)[1] <- "path"
# use our function
r <- get.robustness(indata, hatmatrix ,comparison)$pathrobust
compare.robustness <- merge(r, proportion.ROB, by=c("path"))
# visualize the difference
View(compare.robustness)
ggplot(compare.robustness, aes(x=pro.rob, y=path_p)) + geom_point(size=3) +
geom_smooth(method=lm, lwd=2) +
geom_abline(color="red", lwd=2) +
xlim(c(0,1)) + ylim(c(0,1)) +
xlab("Proportion of ROB of a stream") + ylab("Robustness index of a stream")
###
### calculate the proportion of rob for the comparison
proportion.ROB <- merge(proportion.ROB, path_flow.df, by=c("path"), all.X=T)
proportion.ROB_contrast_network <- sum(proportion.ROB$pro.rob * proportion.ROB$flow)
proportion.ROB_contrast_network
###