statistical_analysis.R 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. library(moments)
  2. library(readxl)
  3. library(car)
  4. library(irr)
  5. addcol<-function(Table, cols=50){
  6. while(ncol(Table)<cols){
  7. extracol<-rep(NA,21)
  8. Table=cbind(Table, extracol)
  9. }
  10. return(Table)
  11. }
  12. Fredi="/home/user/owncloud/Manual_Rotating_Beam_Analyse/Manual_RotatingBeam_ Analyse_ Fredi.xlsx"
  13. Markus="/home/user/owncloud/Manual_Rotating_Beam_Analyse/Manual_RotatingBeam_ Analyse_ Markus.xlsx"
  14. Sebastian="/home/user/owncloud/Manual_Rotating_Beam_Analyse/Manual_RotatingBeam_ Analyse_ Sebastian.xlsx"
  15. TM=read_xlsx(Markus, col_names = T)
  16. TF=read_xlsx(Fredi, col_names = T)
  17. TS=read_xlsx(Sebastian, col_names = T)
  18. StartM=data.frame()
  19. StartF=data.frame()
  20. StartS=data.frame()
  21. StartTDLC1=data.frame()
  22. EndM=data.frame()
  23. EndF=data.frame()
  24. EndS=data.frame()
  25. EndDLC=data.frame()
  26. SpeedM=data.frame()
  27. SpeedF=data.frame()
  28. SpeedS=data.frame()
  29. SpeedDLC=data.frame()
  30. ICCStart<-data.frame()
  31. ICCEnd<-data.frame()
  32. ICCSpeed<-data.frame()
  33. ICCHLD<-data.frame()
  34. cols<-c(ncol(TM), ncol(TF), ncol(TS), ncol(TDLC1))
  35. TM=addcol(TM, max(cols))
  36. TF=addcol(TF, max(cols))
  37. TS=addcol(TS, max(cols))
  38. TDLC1=addcol(TDLC1, max(cols))
  39. for(i in 1:(nrow(TM)-1)){
  40. StartM[i,1]<-as.numeric(TM$Start[i+1])
  41. StartM[i,2]<-"M"
  42. }
  43. for(i in 1:(nrow(TF)-1)){
  44. StartF[i,1]<-as.numeric(TF$Start[i+1])
  45. StartF[i,2]<-"F"
  46. }
  47. for(i in 1:(nrow(TS)-1)){
  48. StartS[i,1]<-as.numeric(TS$Start[i+1])
  49. StartS[i,2]<-"S"
  50. }
  51. for(i in 1:(nrow(TDLC1)-1)){
  52. StartTDLC1[i,1]<-as.numeric(TDLC1$Start[i+1])
  53. StartTDLC1[i,2]<-"DLC"
  54. }
  55. for(i in 1:(nrow(TM)-1)){
  56. EndM[i,1]<-as.numeric(TM$End[i+1])
  57. EndM[i,2]<-"M"
  58. }
  59. for(i in 1:(nrow(TF)-1)){
  60. EndF[i,1]<-as.numeric(TF$End[i+1])
  61. EndF[i,2]<-"F"
  62. }
  63. for(i in 1:(nrow(TS)-1)){
  64. EndS[i,1]<-as.numeric(TS$End[i+1])
  65. EndS[i,2]<-"S"
  66. }
  67. for(i in 1:(nrow(TS)-1)){
  68. EndDLC[i,1]<-as.numeric(TDLC1$End[i+1])
  69. EndDLC[i,2]<-"DLC"
  70. }
  71. for(i in 1:(nrow(TM)-1)){
  72. SpeedM[i,1]<-as.numeric(TM$Speed[i+1])
  73. SpeedM[i,2]<-"M"
  74. }
  75. for(i in 1:(nrow(TF)-1)){
  76. SpeedF[i,1]<-as.numeric(TF$Speed[i+1])
  77. SpeedF[i,2]<-"F"
  78. }
  79. for(i in 1:(nrow(TS)-1)){
  80. SpeedS[i,1]<-as.numeric(TS$Speed[i+1])
  81. SpeedS[i,2]<-"S"
  82. }
  83. for(i in 1:(nrow(TDLC1)-1)){
  84. SpeedDLC[i,1]<-as.numeric(TDLC1$Speed[i+1])
  85. SpeedDLC[i,2]<-"DLC"
  86. }
  87. Start<-rbind(StartM, StartF, StartS, StartTDLC1)
  88. End<-rbind(EndM, EndF, EndS, EndDLC)
  89. Speed<-rbind(SpeedM, SpeedF, SpeedS, SpeedDLC)
  90. agostino<-data.frame()
  91. colnamesagostino<-c("Rater", "Start", "End", "Speed", "HLD")
  92. for(i in colnamesagostino){agostino[[i]]<-as.character()}
  93. for(i in 1:length(Rater)){agostino[i,1]=Rater[i]}
  94. agostino[1,2]=round(agostino.test(as.numeric(TM$Start[2:nrow(TM)]))$p.value, digits = 4)
  95. agostino[2,2]=round(agostino.test(as.numeric(TF$Start[2:nrow(TF)]))$p.value, digits = 4)
  96. agostino[3,2]=round(agostino.test(as.numeric(TS$Start[2:nrow(TS)]))$p.value, digits = 4)
  97. agostino[4,2]=round(agostino.test(as.numeric(TDLC1$Start[2:nrow(TDLC1)]))$p.value, digits = 4)
  98. agostino[1,3]=round(agostino.test(as.numeric(TM$End[2:nrow(TM)]))$p.value, digits = 4)
  99. agostino[2,3]=round(agostino.test(as.numeric(TF$End[2:nrow(TF)]))$p.value, digits = 4)
  100. agostino[3,3]=round(agostino.test(as.numeric(TS$End[2:nrow(TS)]))$p.value, digits = 4)
  101. agostino[4,3]=round(agostino.test(as.numeric(TDLC1$End[2:nrow(TDLC1)]))$p.value, digits = 4)
  102. agostino[1,4]=round(agostino.test(as.numeric(TM$Speed[2:nrow(TM)]))$p.value, digits = 4)
  103. agostino[2,4]=round(agostino.test(as.numeric(TF$Speed[2:nrow(TF)]))$p.value, digits = 4)
  104. agostino[3,4]=round(agostino.test(as.numeric(TS$Speed[2:nrow(TS)]))$p.value, digits = 4)
  105. agostino[4,4]=round(agostino.test(as.numeric(TDLC1$Speed[2:nrow(TDLC1)]))$p.value, digits = 4)
  106. agostino[1,5]=round(agostino.test(as.numeric(HLDM[,1]))$p.value, digits = 4)
  107. agostino[2,5]=round(agostino.test(as.numeric(HLDF[,1]))$p.value, digits = 4)
  108. agostino[3,5]=round(agostino.test(as.numeric(HLDS[,1]))$p.value, digits = 4)
  109. agostino[4,5]=round(agostino.test(as.numeric(HLDDLC[,1]))$p.value, digits = 4)
  110. png(paste0(PicFolder, "p-values Normality Test D'Agostino"), height = 28*nrow(agostino), width = 50*ncol(agostino))
  111. grid.table(agostino, rows=NULL)
  112. dev.off()
  113. VH<-data.frame()
  114. colnamesVH<-c("Start", "End", "Speed", "HLD")
  115. for(i in colnamesVH){VH[[i]]<-as.character()}
  116. VH[1,1]=round(leveneTest(Start[,1], as.factor(Start[,2]))$`Pr(>F)`[1], digits = 4)
  117. VH[1,2]=round(leveneTest(End[,1], as.factor(End[,2]))$`Pr(>F)`[1], digits = 4)
  118. VH[1,3]=round(bartlett.test(Speed[,1], Speed[,2])$p.value, digits = 4)
  119. VH[1,4]=round(leveneTest(HLD[,1], as.factor(HLD[,2]))$`Pr(>F)`[1], digits = 4)
  120. png(paste0(PicFolder, "p-values Variance Homogeneity"), height = 45*nrow(VH), width = 50*ncol(VH))
  121. grid.table(VH, rows=NULL)
  122. dev.off()
  123. cStartS1=cor.test(StartM$V1, StartF$V1, method="spearman")
  124. cStartS2=cor.test(StartM$V1, StartS$V1, method="spearman")
  125. cStartS3=cor.test(StartM$V1, StartTDLC1$V1, method="spearman")
  126. cStartS4=cor.test(StartF$V1, StartS$V1, method="spearman")
  127. cStartS5=cor.test(StartF$V1, StartTDLC1$V1, method="spearman")
  128. cStartS6=cor.test(StartS$V1, StartTDLC1$V1, method="spearman")
  129. cStartP1=cor.test(StartM$V1, StartF$V1, method="pearson")
  130. cStartP2=cor.test(StartM$V1, StartS$V1, method="pearson")
  131. cStartP3=cor.test(StartM$V1, StartTDLC1$V1, method="pearson")
  132. cStartP4=cor.test(StartF$V1, StartS$V1, method="pearson")
  133. cStartP5=cor.test(StartF$V1, StartTDLC1$V1, method="pearson")
  134. cStartP6=cor.test(StartS$V1, StartTDLC1$V1, method="pearson")
  135. cEndS1=cor.test(EndM$V1, EndF$V1, method="spearman")
  136. cEndS2=cor.test(EndM$V1, EndS$V1, method="spearman")
  137. cEndS3=cor.test(EndM$V1, EndDLC$V1, method="spearman")
  138. cEndS4=cor.test(EndF$V1, EndS$V1, method="spearman")
  139. cEndS5=cor.test(EndF$V1, EndDLC$V1, method="spearman")
  140. cEndS6=cor.test(EndS$V1, EndDLC$V1, method="spearman")
  141. cEndP1=cor.test(EndM$V1, EndF$V1, method="pearson")
  142. cEndP2=cor.test(EndM$V1, EndS$V1, method="pearson")
  143. cEndP3=cor.test(EndM$V1, EndDLC$V1, method="pearson")
  144. cEndP4=cor.test(EndF$V1, EndS$V1, method="pearson")
  145. cEndP5=cor.test(EndF$V1, EndDLC$V1, method="pearson")
  146. cEndP6=cor.test(EndS$V1, EndDLC$V1, method="pearson")
  147. cSpeed1=cor.test(SpeedM$V1, SpeedF$V1, method="pearson")
  148. cSpeed2=cor.test(SpeedM$V1, SpeedS$V1, method="pearson")
  149. cSpeed3=cor.test(SpeedM$V1, SpeedDLC$V1, method="pearson")
  150. cSpeed4=cor.test(SpeedF$V1, SpeedS$V1, method="pearson")
  151. cSpeed5=cor.test(SpeedF$V1, SpeedDLC$V1, method="pearson")
  152. cSpeed6=cor.test(SpeedS$V1, SpeedDLC$V1, method="pearson")
  153. cHLDS1=cor.test(HLDM[,1], HLDF[,1], method="spearman")
  154. cHLDS2=cor.test(HLDM[,1], HLDS[,1], method="spearman")
  155. cHLDS3=cor.test(HLDM[,1], HLDDLC[,1], method="spearman")
  156. cHLDS4=cor.test(HLDF[,1], HLDS[,1], method="spearman")
  157. cHLDS5=cor.test(HLDF[,1], HLDDLC[,1], method="spearman")
  158. cHLDS6=cor.test(HLDS[,1], HLDDLC[,1], method="spearman")
  159. cHLDP1=cor.test(HLDM[,1], HLDF[,1], method="pearson")
  160. cHLDP2=cor.test(HLDM[,1], HLDS[,1], method="pearson")
  161. cHLDP3=cor.test(HLDM[,1], HLDDLC[,1], method="pearson")
  162. cHLDP4=cor.test(HLDF[,1], HLDS[,1], method="pearson")
  163. cHLDP5=cor.test(HLDF[,1], HLDDLC[,1], method="pearson")
  164. cHLDP6=cor.test(HLDS[,1], HLDDLC[,1], method="pearson")
  165. for(i in 1:(nrow(TM)-1)){
  166. ICCStart[i,1]<-as.numeric(TM$Start[i+1])
  167. ICCStart[i,2]<-as.numeric(TF$Start[i+1])
  168. ICCStart[i,3]<-as.numeric(TS$Start[i+1])
  169. ICCStart[i,4]<-as.numeric(TDLC1$Start[i+1])
  170. }
  171. for(i in 1:(nrow(TM)-1)){
  172. ICCEnd[i,1]<-as.numeric(TM$End[i+1])
  173. ICCEnd[i,2]<-as.numeric(TF$End[i+1])
  174. ICCEnd[i,3]<-as.numeric(TS$End[i+1])
  175. ICCEnd[i,4]<-as.numeric(TDLC1$End[i+1])
  176. }
  177. for(i in 1:(nrow(TM)-1)){
  178. ICCSpeed[i,1]<-as.numeric(TM$Speed[i+1])
  179. ICCSpeed[i,2]<-as.numeric(TF$Speed[i+1])
  180. ICCSpeed[i,3]<-as.numeric(TS$Speed[i+1])
  181. ICCSpeed[i,4]<-as.numeric(TDLC1$Speed[i+1])
  182. }
  183. for(i in 1:(nrow(HLDM))){
  184. ICCHLD[i,1]<-as.numeric(HLDM[i,1])
  185. ICCHLD[i,2]<-as.numeric(HLDF[i,1])
  186. ICCHLD[i,3]<-as.numeric(HLDS[i,1])
  187. ICCHLD[i,4]<-as.numeric(HLDDLC[i,1])
  188. }
  189. ICC<-data.frame()
  190. colnamesICC<-c("Start", "End", "Speed", "HLD")
  191. for(i in colnamesICC){ICC[[i]]<-as.character()}
  192. ICC[1,1]=round(icc(ICCStart, model="twoway", type="agreement", unit="single")$value, digits = 4)
  193. ICC[2,1]=round(icc(ICCStart, model="twoway", type="agreement", unit="single")$p.value, digits = 6)
  194. ICC[1,2]=round(icc(ICCEnd, model="twoway", type="agreement", unit="single")$value, digits = 4)
  195. ICC[2,2]=round(icc(ICCEnd, model="twoway", type="agreement", unit="single")$p.value, digits = 6)
  196. ICC[1,3]=round(icc(ICCSpeed, model="twoway", type="agreement", unit="single")$value, digits = 4)
  197. ICC[2,3]=round(icc(ICCSpeed, model="twoway", type="agreement", unit="single")$p.value, digits = 6)
  198. ICC[1,4]=round(icc(ICCHLD, model="twoway", type="agreement", unit="single")$value, digits = 4)
  199. ICC[2,4]=round(icc(ICCHLD, model="twoway", type="agreement", unit="single")$p.value, digits = 6)
  200. png(paste0(PicFolder, "Correlation values ICC"), height = 45*nrow(ICC), width = 50*ncol(ICC))
  201. grid.table(ICC, rows=NULL)
  202. dev.off()
  203. Rater<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  204. Rater2<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  205. RvsRStart<-expand.grid(X=Rater, Y=Rater2)
  206. RvsRStart$value<-c(1, cStartS1$estimate, cStartS2$estimate, cStartS3$estimate, cStartS1$estimate, 1, cStartS4$estimate, cStartS4$estimate, cStartS2$estimate, cStartS4$estimate, 1, cStartS6$estimate, cStartS3$estimate, cStartS5$estimate, cStartS6$estimate, 1)
  207. ggplot(RvsRStart, aes(X, Y, fill= value)) +
  208. geom_tile(aes(fill = value))+
  209. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  210. scale_colour_manual(values=c("gray100"))+
  211. scale_fill_gradient(limits=c(0,1))+
  212. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  213. ggsave(paste0(PicFolder, "Spearman_Correlation_Start.png"))
  214. StartSp<-data.frame()
  215. Rater_1<-c(1, round(cStartS1$p.value, digits=5), round(cStartS2$p.value, digits=5), round(cStartS3$p.value, digits=5))
  216. Rater_2<-c(0,1, round(cStartS4$p.value, digits=5), round(cStartS5$p.value, digits=5))
  217. Rater_3<-c(0,0,1, round(cStartS5$p.value, digits=5))
  218. DLC<-c(0,0,0,1)
  219. StartSp<-rbind(StartSp, Rater_1, Rater_2, Rater_3, DLC)
  220. StartSp=`row.names<-`(StartSp, Rater)
  221. colnames(StartSp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  222. png(paste0(PicFolder, "Start_Spearman_p-values.png"), height = 30*nrow(StartSp), width = 70*ncol(StartSp))
  223. grid.table(StartSp, rows=NULL)
  224. dev.off()
  225. RvsRStart<-expand.grid(X=Rater, Y=Rater2)
  226. RvsRStart$value<-c(1, cStartP1$estimate, cStartP2$estimate, cStartP3$estimate, cStartP1$estimate, 1, cStartP4$estimate, cStartP5$estimate, cStartP2$estimate, cStartP4$estimate, 1, cStartP6$estimate, cStartP3$estimate, cStartP5$estimate, cStartP6$estimate, 1)
  227. ggplot(RvsRStart, aes(X, Y, fill= value)) +
  228. geom_tile(aes(fill = value))+
  229. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  230. scale_colour_manual(values=c("gray100"))+
  231. scale_fill_gradient(limits=c(0,1))+
  232. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  233. ggsave(paste0(PicFolder, "Pearson_Correlation_Start.png"))
  234. StartPp<-data.frame()
  235. Rater_1<-c(1, round(cStartP1$p.value, digits=5), round(cStartP2$p.value, digits=5), round(cStartP3$p.value, digits=5))
  236. Rater_2<-c(0,1, round(cStartP4$p.value, digits=5), round(cStartP5$p.value, digits=5))
  237. Rater_3<-c(0,0,1, round(cStartP5$p.value, digits=5))
  238. DLC<-c(0,0,0,1)
  239. StartPp<-rbind(StartPp, Rater_1, Rater_2, Rater_3, DLC)
  240. StartPp=`row.names<-`(StartPp, Rater)
  241. colnames(StartPp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  242. png(paste0(PicFolder, "Start_Pearson_p-values.png"), height = 30*nrow(StartPp), width = 70*ncol(StartPp))
  243. grid.table(StartPp, rows=NULL)
  244. dev.off()
  245. RvsREnd<-expand.grid(X=Rater, Y=Rater2)
  246. RvsREnd$value<-c(1, cEndS1$estimate, cEndS2$estimate, cEndS3$estimate, cEndS1$estimate, 1, cEndS4$estimate, cEndS5$estimate, cEndS2$estimate, cEndS4$estimate, 1, cEndS6$estimate, cEndS3$estimate, cEndS5$estimate, cEndS6$estimate, 1)
  247. ggplot(RvsREnd, aes(X, Y, fill= value))+
  248. geom_tile(aes(fill = value))+
  249. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  250. scale_colour_manual(values=c("gray100"))+
  251. scale_fill_gradient(limits=c(0,1))+
  252. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  253. ggsave(paste0(PicFolder, "Spearman_Correlation_End.png"))
  254. EndSp<-data.frame()
  255. Rater_1<-c(1, round(cEndS1$p.value, digits=5), round(cEndS2$p.value, digits=5), round(cEndS3$p.value, digits=5))
  256. Rater_2<-c(0,1, round(cEndS4$p.value, digits=5), round(cEndS5$p.value, digits=5))
  257. Rater_3<-c(0,0,1, round(cEndS5$p.value, digits=5))
  258. DLC<-c(0,0,0,1)
  259. EndSp<-rbind(EndSp, Rater_1, Rater_2, Rater_3, DLC)
  260. EndSp=`row.names<-`(EndSp, Rater)
  261. colnames(EndSp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  262. png(paste0(PicFolder, "End_Spearman_p-values.png"), height = 30*nrow(EndSp), width = 70*ncol(EndSp))
  263. grid.table(EndSp, rows=NULL)
  264. dev.off()
  265. RvsREnd<-expand.grid(X=Rater, Y=Rater2)
  266. RvsREnd$value<-c(1, cEndP1$estimate, cEndP2$estimate, cEndP3$estimate, cEndP1$estimate, 1, cEndP4$estimate, cEndP5$estimate, cEndP2$estimate, cEndP4$estimate, 1, cEndP6$estimate, cEndP3$estimate, cEndP5$estimate, cEndP6$estimate, 1)
  267. ggplot(RvsREnd, aes(X, Y, fill= value))+
  268. geom_tile(aes(fill = value))+
  269. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  270. scale_colour_manual(values=c("gray100"))+
  271. scale_fill_gradient(limits=c(0,1))+
  272. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  273. ggsave(paste0(PicFolder, "Pearson_Correlation_End.png"))
  274. EndPp<-data.frame()
  275. Rater_1<-c(1, round(cEndP1$p.value, digits=5), round(cEndP2$p.value, digits=5), round(cEndP3$p.value, digits=5))
  276. Rater_2<-c(0,1, round(cEndP4$p.value, digits=5), round(cEndP5$p.value, digits=5))
  277. Rater_3<-c(0,0,1, round(cEndP5$p.value, digits=5))
  278. DLC<-c(0,0,0,1)
  279. EndPp<-rbind(EndPp, Rater_1, Rater_2, Rater_3, DLC)
  280. EndPp=`row.names<-`(EndPp, Rater)
  281. colnames(EndPp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  282. png(paste0(PicFolder, "End_Pearson_p-values.png"), height = 30*nrow(EndPp), width = 70*ncol(EndPp))
  283. grid.table(EndPp, rows=NULL)
  284. dev.off()
  285. RvsRSpeed<-expand.grid(X=Rater, Y=Rater2)
  286. RvsRSpeed$value<-c(1, cSpeed1$estimate, cSpeed2$estimate, cSpeed3$estimate, cSpeed1$estimate, 1, cSpeed4$estimate, cSpeed5$estimate, cSpeed2$estimate, cSpeed4$estimate, 1, cSpeed6$estimate, cSpeed3$estimate, cSpeed5$estimate, cSpeed6$estimate, 1)
  287. ggplot(RvsRSpeed, aes(X, Y, fill= value))+
  288. geom_tile(aes(fill = value))+
  289. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  290. scale_colour_manual(values=c("gray100"))+
  291. scale_fill_gradient(limits=c(0,1))+
  292. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  293. ggsave(paste0(PicFolder, "Pearson_Correlation_Speed.png"))
  294. Speedp<-data.frame()
  295. Rater_1<-c(1, round(cSpeed1$p.value, digits=5), round(cSpeed2$p.value, digits=5), round(cSpeed3$p.value, digits=5))
  296. Rater_2<-c(0,1, round(cSpeed4$p.value, digits=5), round(cSpeed5$p.value, digits=5))
  297. Rater_3<-c(0,0,1, round(cSpeed5$p.value, digits=5))
  298. DLC<-c(0,0,0,1)
  299. Speedp<-rbind(Speedp, Rater_1, Rater_2, Rater_3, DLC)
  300. Speedp=`row.names<-`(Speedp, Rater)
  301. colnames(Speedp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  302. png(paste0(PicFolder, "Speed_Pearson_p-values.png"), height = 30*nrow(Speedp), width = 70*ncol(Speedp))
  303. grid.table(Speedp, rows=NULL)
  304. dev.off()
  305. HLD<-data.frame()
  306. HLDM<-data.frame()
  307. HLDF<-data.frame()
  308. HLDS<-data.frame()
  309. HLDDLC<-data.frame()
  310. for(i in 1:(nrow(TM)-1)){
  311. for(j in seq(8, max(cols), 2)){
  312. hld<-list(as.numeric(TM[i+1,j]), "M")
  313. HLDM=rbind(HLDM, hld)
  314. }
  315. }
  316. for(i in 1:(nrow(TF)-1)){
  317. for(j in seq(8, max(cols), 2)){
  318. hld<-list(as.numeric(TF[i+1,j]), "F")
  319. HLDF=rbind(HLDF, hld)
  320. }
  321. }
  322. for(i in 1:(nrow(TS)-1)){
  323. for(j in seq(8, max(cols), 2)){
  324. hld<-list(as.numeric(TS[i+1,j]), "S")
  325. HLDS=rbind(HLDS, hld)
  326. }
  327. }
  328. for(i in 2:(nrow(TDLC1))){
  329. for(j in 8:(8+((max(cols)-8)/2))){
  330. hld<-list(as.numeric(TDLC1[i,j]), "DLC")
  331. HLDDLC=rbind(HLDDLC, hld)
  332. }
  333. }
  334. colnames(HLDM)<-c(1,2)
  335. colnames(HLDF)<-c(1,2)
  336. colnames(HLDS)<-c(1,2)
  337. colnames(HLDDLC)<-c(1,2)
  338. HLD<-rbind(HLDM, HLDF, HLDS, HLDDLC)
  339. cHLDS1=cor.test(HLDM[,1], HLDF[,1], method="spearman")
  340. cHLDS2=cor.test(HLDM[,1], HLDS[,1], method="spearman")
  341. cHLDS3=cor.test(HLDM[,1], HLDDLC[,1], method="spearman")
  342. cHLDS4=cor.test(HLDF[,1], HLDS[,1], method="spearman")
  343. cHLDS5=cor.test(HLDF[,1], HLDDLC[,1], method="spearman")
  344. cHLDS6=cor.test(HLDS[,1], HLDDLC[,1], method="spearman")
  345. cHLDP1=cor.test(HLDM[,1], HLDF[,1], method="pearson")
  346. cHLDP2=cor.test(HLDM[,1], HLDS[,1], method="pearson")
  347. cHLDP3=cor.test(HLDM[,1], HLDDLC[,1], method="pearson")
  348. cHLDP4=cor.test(HLDF[,1], HLDS[,1], method="pearson")
  349. cHLDP5=cor.test(HLDF[,1], HLDDLC[,1], method="pearson")
  350. cHLDP6=cor.test(HLDS[,1], HLDDLC[,1], method="pearson")
  351. RvsRHLD<-expand.grid(X=Rater, Y=Rater2)
  352. RvsRHLD$value<-c(1, cHLDS1$estimate, cHLDS2$estimate, cHLDS3$estimate, cHLDS1$estimate, 1, cHLDS4$estimate, cHLDS5$estimate, cHLDS2$estimate, cHLDS4$estimate, 1, cHLDS6$estimate, cHLDS3$estimate, cHLDS5$estimate, cHLDS6$estimate, 1)
  353. ggplot(RvsRHLD, aes(X, Y, fill= value))+
  354. geom_tile(aes(fill = value))+
  355. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  356. scale_colour_manual(values=c("gray100"))+
  357. scale_fill_gradient(limits=c(0,1))+
  358. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  359. ggsave(paste0(PicFolder, "Spearman_Correlation_HLD1.png"))
  360. HLDSp<-data.frame()
  361. Rater_1<-c(1, round(cHLDS1$p.value, digits=5), round(cHLDS2$p.value, digits=5), round(cHLDS3$p.value, digits=5))
  362. Rater_2<-c(0,1, round(cHLDS4$p.value, digits=5), round(cHLDS5$p.value, digits=5))
  363. Rater_3<-c(0,0,1, round(cHLDS5$p.value, digits=5))
  364. DLC<-c(0,0,0,1)
  365. HLDSp<-rbind(HLDSp, Rater_1, Rater_2, Rater_3, DLC)
  366. HLDSp=`row.names<-`(HLDSp, Rater)
  367. colnames(HLDSp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  368. png(paste0(PicFolder, "HLD_Spearman_p-values_1.png"), height = 30*nrow(HLDSp), width = 70*ncol(HLDSp))
  369. grid.table(HLDSp, rows=NULL)
  370. dev.off()
  371. RvsRHLD<-expand.grid(X=Rater, Y=Rater2)
  372. RvsRHLD$value<-c(1, cHLDP1$estimate, cHLDP2$estimate, cHLDP3$estimate, cHLDP1$estimate, 1, cHLDP4$estimate, cHLDP5$estimate, cHLDP2$estimate, cHLDP4$estimate, 1, cHLDP6$estimate, cHLDP3$estimate, cHLDP5$estimate, cHLDP6$estimate, 1)
  373. ggplot(RvsRHLD, aes(X, Y, fill= value))+
  374. geom_tile(aes(fill = value))+
  375. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  376. scale_colour_manual(values=c("gray100"))+
  377. scale_fill_gradient(limits=c(0,1))+
  378. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  379. ggsave(paste0(PicFolder, "Pearson_Correlation_HLD1.png"))
  380. HLDPp<-data.frame()
  381. Rater_1<-c(1, round(cHLDP1$p.value, digits=5), round(cHLDP2$p.value, digits=5), round(cHLDP3$p.value, digits=5))
  382. Rater_2<-c(0,1, round(cHLDP4$p.value, digits=5), round(cHLDP5$p.value, digits=5))
  383. Rater_3<-c(0,0,1, round(cHLDP5$p.value, digits=5))
  384. DLC<-c(0,0,0,1)
  385. HLDPp<-rbind(HLDPp, Rater_1, Rater_2, Rater_3, DLC)
  386. HLDPp=`row.names<-`(HLDPp, Rater)
  387. colnames(HLDPp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  388. png(paste0(PicFolder, "HLD_Pearson_p-values_1.png"), height = 30*nrow(HLDPp), width = 70*ncol(HLDPp))
  389. grid.table(HLDPp, rows=NULL)
  390. dev.off()
  391. HLD<-data.frame()
  392. HLDM<-data.frame()
  393. HLDF<-data.frame()
  394. HLDS<-data.frame()
  395. HLDDLC<-data.frame()
  396. for(i in 1:(nrow(TM)-1)){
  397. for(j in seq(8, max(cols), 2)){
  398. hld<-list(as.numeric(TM[i+1,j]), "M")
  399. HLDM=rbind(HLDM, hld)
  400. }
  401. }
  402. for(i in 1:(nrow(TF)-1)){
  403. for(j in seq(8, max(cols), 2)){
  404. hld<-list(as.numeric(TF[i+1,j]), "F")
  405. HLDF=rbind(HLDF, hld)
  406. }
  407. }
  408. for(i in 1:(nrow(TS)-1)){
  409. for(j in seq(8, max(cols), 2)){
  410. hld<-list(as.numeric(TS[i+1,j]), "S")
  411. HLDS=rbind(HLDS, hld)
  412. }
  413. }
  414. for(i in 2:(nrow(TDLC1))){
  415. for(j in 8:(8+((max(cols)-8)/2))){
  416. hld<-list(as.numeric(TDLC1[i,j]), "DLC")
  417. HLDDLC=rbind(HLDDLC, hld)
  418. }
  419. }
  420. colnames(HLDM)<-c(1,2)
  421. colnames(HLDF)<-c(1,2)
  422. colnames(HLDS)<-c(1,2)
  423. colnames(HLDDLC)<-c(1,2)
  424. HLDRater<-list(HLDM, HLDF, HLDS, HLDDLC)
  425. lengthmean<-c()
  426. for(e in 1:length(DLCnames)){
  427. lengthmean[e]=nrow(DLCnames[[e]])
  428. }
  429. for(g in 1:length(HLDRater)){
  430. for(h in 1:nrow(HLDRater[[g]])){
  431. for(f in 1:length(HLDRater)){
  432. if(is.na(HLDRater[[g]][h,1])==F && is.na(HLDRater[[f]][h,1])==T){
  433. HLDRater[[f]][h,1]<-0
  434. }
  435. }
  436. }
  437. }
  438. HLDM<-HLDRater[[1]]
  439. HLDF<-HLDRater[[2]]
  440. HLDS<-HLDRater[[3]]
  441. HLDDLC<-HLDRater[[4]]
  442. HLD<-rbind(HLDM, HLDF, HLDS, HLDDLC)
  443. cHLDS1=cor.test(HLDM[,1], HLDF[,1], method="spearman")
  444. cHLDS2=cor.test(HLDM[,1], HLDS[,1], method="spearman")
  445. cHLDS3=cor.test(HLDM[,1], HLDDLC[,1], method="spearman")
  446. cHLDS4=cor.test(HLDF[,1], HLDS[,1], method="spearman")
  447. cHLDS5=cor.test(HLDF[,1], HLDDLC[,1], method="spearman")
  448. cHLDS6=cor.test(HLDS[,1], HLDDLC[,1], method="spearman")
  449. cHLDP1=cor.test(HLDM[,1], HLDF[,1], method="pearson")
  450. cHLDP2=cor.test(HLDM[,1], HLDS[,1], method="pearson")
  451. cHLDP3=cor.test(HLDM[,1], HLDDLC[,1], method="pearson")
  452. cHLDP4=cor.test(HLDF[,1], HLDS[,1], method="pearson")
  453. cHLDP5=cor.test(HLDF[,1], HLDDLC[,1], method="pearson")
  454. cHLDP6=cor.test(HLDS[,1], HLDDLC[,1], method="pearson")
  455. RvsRHLD<-expand.grid(X=Rater, Y=Rater2)
  456. RvsRHLD$value<-c(1, cHLDS1$estimate, cHLDS2$estimate, cHLDS3$estimate, cHLDS1$estimate, 1, cHLDS4$estimate, cHLDS5$estimate, cHLDS2$estimate, cHLDS4$estimate, 1, cHLDS6$estimate, cHLDS3$estimate, cHLDS5$estimate, cHLDS6$estimate, 1)
  457. ggplot(RvsRHLD, aes(X, Y, fill= value))+
  458. geom_tile(aes(fill = value))+
  459. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  460. scale_colour_manual(values=c("gray100"))+
  461. scale_fill_gradient(limits=c(0,1))+
  462. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  463. ggsave(paste0(PicFolder, "Spearman_Correlation_HLD2.png"))
  464. HLDSp<-data.frame()
  465. Rater_1<-c(1, round(cHLDS1$p.value, digits=5), round(cHLDS2$p.value, digits=5), round(cHLDS3$p.value, digits=5))
  466. Rater_2<-c(0,1, round(cHLDS4$p.value, digits=5), round(cHLDS5$p.value, digits=5))
  467. Rater_3<-c(0,0,1, round(cHLDS5$p.value, digits=5))
  468. DLC<-c(0,0,0,1)
  469. HLDSp<-rbind(HLDSp, Rater_1, Rater_2, Rater_3, DLC)
  470. HLDSp=`row.names<-`(HLDSp, Rater)
  471. colnames(HLDSp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  472. png(paste0(PicFolder, "HLD_Spearman_p-values_2.png"), height = 30*nrow(HLDSp), width = 70*ncol(HLDSp))
  473. grid.table(HLDSp, rows=NULL)
  474. dev.off()
  475. RvsRHLD<-expand.grid(X=Rater, Y=Rater2)
  476. RvsRHLD$value<-c(1, cHLDP1$estimate, cHLDP2$estimate, cHLDP3$estimate, cHLDP1$estimate, 1, cHLDP4$estimate, cHLDP5$estimate, cHLDP2$estimate, cHLDP4$estimate, 1, cHLDP6$estimate, cHLDP3$estimate, cHLDP5$estimate, cHLDP6$estimate, 1)
  477. ggplot(RvsRHLD, aes(X, Y, fill= value))+
  478. geom_tile(aes(fill = value))+
  479. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  480. scale_colour_manual(values=c("gray100"))+
  481. scale_fill_gradient(limits=c(0,1))+
  482. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  483. ggsave(paste0(PicFolder, "Pearson_Correlation_HLD2.png"))
  484. HLDPp<-data.frame()
  485. Rater_1<-c(1, round(cHLDP1$p.value, digits=5), round(cHLDP2$p.value, digits=5), round(cHLDP3$p.value, digits=5))
  486. Rater_2<-c(0,1, round(cHLDP4$p.value, digits=5), round(cHLDP5$p.value, digits=5))
  487. Rater_3<-c(0,0,1, round(cHLDP5$p.value, digits=5))
  488. DLC<-c(0,0,0,1)
  489. HLDPp<-rbind(HLDPp, Rater_1, Rater_2, Rater_3, DLC)
  490. HLDPp=`row.names<-`(HLDPp, Rater)
  491. colnames(HLDPp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  492. png(paste0(PicFolder, "HLD_Pearson_p-values_2.png"), height = 30*nrow(HLDPp), width = 70*ncol(HLDPp))
  493. grid.table(HLDPp, rows=NULL)
  494. dev.off()
  495. HLD<-data.frame()
  496. HLDM<-data.frame()
  497. HLDF<-data.frame()
  498. HLDS<-data.frame()
  499. HLDDLC<-data.frame()
  500. for(i in 1:(nrow(TM)-1)){
  501. for(j in seq(8, max(cols), 2)){
  502. hld<-list(as.numeric(TM[i+1,j]), "M")
  503. HLDM=rbind(HLDM, hld)
  504. }
  505. }
  506. for(i in 1:(nrow(TF)-1)){
  507. for(j in seq(8, max(cols), 2)){
  508. hld<-list(as.numeric(TF[i+1,j]), "F")
  509. HLDF=rbind(HLDF, hld)
  510. }
  511. }
  512. for(i in 1:(nrow(TS)-1)){
  513. for(j in seq(8, max(cols), 2)){
  514. hld<-list(as.numeric(TS[i+1,j]), "S")
  515. HLDS=rbind(HLDS, hld)
  516. }
  517. }
  518. for(i in 2:(nrow(TDLC1))){
  519. for(j in 8:(8+((max(cols)-8)/2))){
  520. hld<-list(as.numeric(TDLC1[i,j]), "DLC")
  521. HLDDLC=rbind(HLDDLC, hld)
  522. }
  523. }
  524. colnames(HLDM)<-c(1,2)
  525. colnames(HLDF)<-c(1,2)
  526. colnames(HLDS)<-c(1,2)
  527. colnames(HLDDLC)<-c(1,2)
  528. HLDRater<-list(HLDM, HLDF, HLDS, HLDDLC)
  529. lengthmean<-c()
  530. for(e in 1:length(DLCnames)){
  531. lengthmean[e]=nrow(DLCnames[[e]])
  532. }
  533. for(g in 1:length(HLDRater)){
  534. for(h in 1:nrow(HLDRater[[g]])){
  535. for(f in 1:length(HLDRater)){
  536. if(is.na(HLDRater[[g]][h,1])==F && is.na(HLDRater[[f]][h,1])==T){
  537. HLDRater[[f]][h,1]<-mean(lengthmean)
  538. }
  539. }
  540. }
  541. }
  542. HLDM<-HLDRater[[1]]
  543. HLDF<-HLDRater[[2]]
  544. HLDS<-HLDRater[[3]]
  545. HLDDLC<-HLDRater[[4]]
  546. HLD<-rbind(HLDM, HLDF, HLDS, HLDDLC)
  547. cHLDS1=cor.test(HLDM[,1], HLDF[,1], method="spearman")
  548. cHLDS2=cor.test(HLDM[,1], HLDS[,1], method="spearman")
  549. cHLDS3=cor.test(HLDM[,1], HLDDLC[,1], method="spearman")
  550. cHLDS4=cor.test(HLDF[,1], HLDS[,1], method="spearman")
  551. cHLDS5=cor.test(HLDF[,1], HLDDLC[,1], method="spearman")
  552. cHLDS6=cor.test(HLDS[,1], HLDDLC[,1], method="spearman")
  553. cHLDP1=cor.test(HLDM[,1], HLDF[,1], method="pearson")
  554. cHLDP2=cor.test(HLDM[,1], HLDS[,1], method="pearson")
  555. cHLDP3=cor.test(HLDM[,1], HLDDLC[,1], method="pearson")
  556. cHLDP4=cor.test(HLDF[,1], HLDS[,1], method="pearson")
  557. cHLDP5=cor.test(HLDF[,1], HLDDLC[,1], method="pearson")
  558. cHLDP6=cor.test(HLDS[,1], HLDDLC[,1], method="pearson")
  559. RvsRHLD<-expand.grid(X=Rater, Y=Rater2)
  560. RvsRHLD$value<-c(1, cHLDS1$estimate, cHLDS2$estimate, cHLDS3$estimate, cHLDS1$estimate, 1, cHLDS4$estimate, cHLDS5$estimate, cHLDS2$estimate, cHLDS4$estimate, 1, cHLDS6$estimate, cHLDS3$estimate, cHLDS5$estimate, cHLDS6$estimate, 1)
  561. ggplot(RvsRHLD, aes(X, Y, fill= value))+
  562. geom_tile(aes(fill = value))+
  563. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  564. scale_colour_manual(values=c("gray100"))+
  565. scale_fill_gradient(limits=c(0,1))+
  566. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  567. ggsave(paste0(PicFolder, "Spearman_Correlation_HLD3.png"))
  568. HLDSp<-data.frame()
  569. Rater_1<-c(1, round(cHLDS1$p.value, digits=5), round(cHLDS2$p.value, digits=5), round(cHLDS3$p.value, digits=5))
  570. Rater_2<-c(0,1, round(cHLDS4$p.value, digits=5), round(cHLDS5$p.value, digits=5))
  571. Rater_3<-c(0,0,1, round(cHLDS5$p.value, digits=5))
  572. DLC<-c(0,0,0,1)
  573. HLDSp<-rbind(HLDSp, Rater_1, Rater_2, Rater_3, DLC)
  574. HLDSp=`row.names<-`(HLDSp, Rater)
  575. colnames(HLDSp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  576. png(paste0(PicFolder, "HLD_Spearman_p-values_3.png"), height = 30*nrow(HLDSp), width = 70*ncol(HLDSp))
  577. grid.table(HLDSp, rows=NULL)
  578. dev.off()
  579. RvsRHLD<-expand.grid(X=Rater, Y=Rater2)
  580. RvsRHLD$value<-c(1, cHLDP1$estimate, cHLDP2$estimate, cHLDP3$estimate, cHLDP1$estimate, 1, cHLDP4$estimate, cHLDP5$estimate, cHLDP2$estimate, cHLDP4$estimate, 1, cHLDP6$estimate, cHLDP3$estimate, cHLDP5$estimate, cHLDP6$estimate, 1)
  581. ggplot(RvsRHLD, aes(X, Y, fill= value))+
  582. geom_tile(aes(fill = value))+
  583. geom_text(aes(label = round(value, 3)), colour=("gray100"), size=9)+
  584. scale_colour_manual(values=c("gray100"))+
  585. scale_fill_gradient(limits=c(0,1))+
  586. theme(panel.background = element_blank(), axis.title=element_blank(), legend.position="none", text = element_text(size=25))
  587. ggsave(paste0(PicFolder, "Pearson_Correlation_HLD3.png"))
  588. HLDPp<-data.frame()
  589. Rater_1<-c(1, round(cHLDP1$p.value, digits=5), round(cHLDP2$p.value, digits=5), round(cHLDP3$p.value, digits=5))
  590. Rater_2<-c(0,1, round(cHLDP4$p.value, digits=5), round(cHLDP5$p.value, digits=5))
  591. Rater_3<-c(0,0,1, round(cHLDP5$p.value, digits=5))
  592. DLC<-c(0,0,0,1)
  593. HLDPp<-rbind(HLDPp, Rater_1, Rater_2, Rater_3, DLC)
  594. HLDPp=`row.names<-`(HLDPp, Rater)
  595. colnames(HLDPp)<-c("Rater_1", "Rater_2", "Rater_3", "DLC")
  596. png(paste0(PicFolder, "HLD_Pearson_p-values_3.png"), height = 30*nrow(HLDPp), width = 70*ncol(HLDPp))
  597. grid.table(HLDPp, rows=NULL)
  598. dev.off()