-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code3_r16final2KM_forestplot.rmd
607 lines (481 loc) · 23.5 KB
/
Code3_r16final2KM_forestplot.rmd
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
---
title: " Yaohua Ma, M.S \\\nDivision of Biomedical Statistics and Informatics \\\nMayo Clinic, Jacksonville \\\nExtension 3-0453 \\\nMa.Yaohua@mayo.edu"
subtitle: "Date: 05/04/2020 \\\n From: Yaohua Ma \\\nTo: Dr. Thompson \\\nRe: HALO FinXX re-analysis (ADS#214070)"
output:
word_document:
reference_doc: ~/R/rpgm/rmd_template2.docx
---
```{r setup, include=FALSE , echo = FALSE, warning=FALSE, message=FALSE}
## STUDYADDRESS: /projects/bsi/fl/studies/s214070.Thompson.DSP2/re_analyze_FinXX950/data
## INVESTIGATOR: Dr. Thompson
## STATISTICIAN: Yaohua Ma
knitr::opts_chunk$set(comment = NA)
knitr::opts_chunk$set(echo = F, warning=FALSE, message=FALSE )
#Clear existing data and graphics
rm(list=ls())
graphics.off()
# install.packages("meta")
library(ggplot2)
library(readxl)
library(writexl)
library(tidyverse)
library(dplyr)
library(forestplot)
setwd("/projects/bsi/fl/studies/s214070.Thompson.DSP2")
## 29 protein tumor vs stroma, log2FC
d1 <- read_excel ( "re_analyze_FinXX950/output/report1_FinXX_DSP950_log2FC_r9tumorvsstroma.xlsx", sheet = "Sheet6")
d2 <- read_excel ( "re_analyze_FinXX950/output/report1_FinXX_DSP950_log2FC_r9tumorvsstroma.xlsx", sheet = "Sheet7")
d3 <- read_excel ( "re_analyze_FinXX950/output/report1_FinXX_DSP950_log2FC_r9tumorvsstroma.xlsx", sheet = "Sheet8")
d4 <- read_excel ( "re_analyze_FinXX950/output/report1_FinXX_DSP950_log2FC_r9tumorvsstroma.xlsx", sheet = "Sheet9")
d5 <- read_excel ( "re_analyze_FinXX950/output/report1_FinXX_DSP950_log2FC_r9tumorvsstroma.xlsx", sheet = "Sheet10")
d4_TNBC29 <- read_excel ("DSP756Apr3_2020/output/report1_TNBC_TMA_DSP756_log2FC_r2.xlsx", sheet = "Sheet4")
d5_TNBC29 <- read_excel ( "DSP756Apr3_2020/output/report1_TNBC_TMA_DSP756_log2FC_r2.xlsx", sheet = "Sheet5")
d6_TNBC29 <- read_excel( "DSP756Apr3_2020/output/report1_TNBC_TMA_DSP756_log2FC_r2.xlsx", sheet = "Sheet6")
### ------------------Sheet4 All_seg_tumor_vs_stroma_28protein TGFB1 not in 756 DSP data . so get final 28 proteins
### -----------------Sheet5 Tumor_RFSyes_vs_no_28protein TGFB1 not in 756 DSP data . so get final 28 proteins
### -----------------Sheet6 Stroma_RFSyes_vs_no_28protein TGFB1 not in 756 DSP data . so get final 28 proteins
ProteinName29 <- read_excel ("re_analyze_FinXX950/data/proteinname29ordered.xlsx",sheet = "Sheet1" ) ## used for each function Finxx forest
ProteinName28 <- read_excel ("re_analyze_FinXX950/data/proteinname29ordered.xlsx",sheet = "Protein28" ) ## used for each function TNBC forest
fun_makedataforforest <- function(dat , ProteinName) {
# dat <- as.data.frame(dat)
#count <- dat[which(dat$p_value <= 0.05), ] dat <- d1 head(dat)
dat <- dat %>% arrange(protein_name) ## make proteinname as alphabetical order
dat <- dat[c(2,1,3:29), ] ## make B7H3 to second row, B2M= beta-2-microglobul go to first row
count<- as.data.frame(dat)
label <- ProteinName[,1]
mean <- count[,5]
lower <- count[,6]
upper <- count[,7]
anno <- count[,9]
plot <- data.frame(label, mean, lower, upper, anno)
colnames(plot)<-c("label","mean", "lower", "upper", "anno") # colnames(df) have to be behind df
return(plot)
} ### work for all data-make
```
# Figure 1: Finxx DSP AllTumor vs. AllStroma
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
vignette("forestplot", package="forestplot")
library(forestplot)
own <- fpTxtGp() ## own for all forestplot below ---------
own$ticks$cex <- 1.2
own$xlab$cex <- 1.2
own$title$cex <- 1.5
own$title$just <- "center"
own$title$fontface <- "bold" ## own for all forestplot below ---------make title bold
own$label$fontface <- "bold" ## make tabletext bold
own$ticks$fontface <- "bold" ## make x-axis number bold
own$xlab$fontface <- "bold" ## make x-anno text bold
# ## own for all forestplot below -----make tabletext bold
# library(meta)
library(grid)
library(gridExtra)
library(dplyr)
plot <- fun_makedataforforest(dat=d1, ProteinName= ProteinName29) #################################################### given data --- important---
plot$label<-as.character(plot$label)
plot$anno<-as.character(plot$anno)
tabletext <- c("ProteinName", plot$label) # tabletext <- cbind(c("ProteinName", plot$label), c("Log2FC(95%CI)", plot$anno))
xticks1 <- seq(from=-2.5, to=3, by=0.5)
forestplot(tabletext, graph.pos = 2,
mean=c(NA, plot$mean),
lower=c(NA, plot$lower),
upper=c(NA, plot$upper), zero=0,
cex=1.5, col = fpColors(lines="blue"),
txt_gp = own,
boxsize=0.25,
vertices=TRUE,
xticks=xticks1, xlab="Log2 Fold Change",
title=" ")
# grid.grabExpr(plot1)
# print(plot1)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
# Figure 2: Finxx DSP CD45Stroma vs. CD68Stroma
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
library(meta)
library(grid)
library(gridExtra)
plot <- fun_makedataforforest(dat=d5, ProteinName= ProteinName29) #################################################### given data --- important---
plot$label<-as.character(plot$label)
plot$anno<-as.character(plot$anno)
tabletext <- c("ProteinName", plot$label) # tabletext <- cbind(c("ProteinName", plot$label), c("Log2FC(95%CI)", plot$anno))
xticks1 <- seq(from=-2.5, to=2.5, by=0.5)
forestplot(tabletext, graph.pos = 2,
mean=c(NA, plot$mean),
lower=c(NA, plot$lower),
upper=c(NA, plot$upper), zero=0,
cex=1.5, col = fpColors(lines="blue"),
txt_gp = own,
boxsize=0.25,
vertices=TRUE,
xticks=xticks1, xlab="Log2 Fold Change",
title=" ")
# grid.grabExpr(plot1)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
# Figure 3: Finxx DSP CD45Tumor vs. CD68Tumor
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
library(meta)
library(grid)
library(gridExtra)
plot <- fun_makedataforforest(dat=d2, ProteinName= ProteinName29) #################################################### given data --- important---
plot$label<-as.character(plot$label)
plot$anno<-as.character(plot$anno)
tabletext <- c("ProteinName", plot$label) # tabletext <- cbind(c("ProteinName", plot$label), c("Log2FC(95%CI)", plot$anno))
xticks1 <- seq(from=-2.5, to=2.5, by=0.5)
forestplot(tabletext, graph.pos = 2,
mean=c(NA, plot$mean),
lower=c(NA, plot$lower),
upper=c(NA, plot$upper), zero=0,
cex=1.5, col = fpColors(lines="blue"),
txt_gp = own,
boxsize=0.25,
vertices=TRUE,
xticks=xticks1, xlab="Log2 Fold Change",
title=" ")
# grid.grabExpr(plot1)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
# Figure 4: Finxx DSP CD45Tumor vs. Tumor w/o Stroma
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
library(meta)
library(grid)
library(gridExtra)
plot <- fun_makedataforforest(dat=d3, ProteinName= ProteinName29) #################################################### given data --- important---
plot$label<-as.character(plot$label)
plot$anno<-as.character(plot$anno)
tabletext <- c("ProteinName", plot$label) # tabletext <- cbind(c("ProteinName", plot$label), c("Log2FC(95%CI)", plot$anno))
xticks1 <- seq(from=-0.5, to=2.5, by=0.5)
# plot1 <-
forestplot(tabletext, graph.pos = 2,
mean=c(NA, plot$mean),
lower=c(NA, plot$lower),
upper=c(NA, plot$upper), zero=0,
cex=1.5, col = fpColors(lines="blue"),
txt_gp = own,
boxsize=0.25,
vertices=TRUE,
xticks=xticks1, xlab="Log2 Fold Change",
title=" ")
#grid.grabExpr(plot1)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
# Figure 5: Finxx DSP CD68Tumor vs. Tumor w/o Stroma
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
library(meta)
library(grid)
library(gridExtra)
plot <- fun_makedataforforest(dat=d4, ProteinName= ProteinName29) #################################################### given data --- important---
plot$label<-as.character(plot$label)
plot$anno<-as.character(plot$anno)
tabletext <- c("ProteinName", plot$label) # tabletext <- cbind(c("ProteinName", plot$label), c("Log2FC(95%CI)", plot$anno))
xticks1 <- seq(from=-0.5, to=2, by=0.5)
forestplot(tabletext, graph.pos = 2,
mean=c(NA, plot$mean),
lower=c(NA, plot$lower),
upper=c(NA, plot$upper), zero=0,
cex=1.5, col = fpColors(lines="blue"),
txt_gp = own,
boxsize=0.25,
vertices=TRUE,
xticks=xticks1, xlab="Log2 Fold Change",
title=" ")
#grid.grabExpr(plot1)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
# Figure 6A: TNBC TMA DSP Tumor vs. Stroma
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
fun_makedataforforest <- function(dat, ProteinName ) {
# dat <- as.data.frame(dat)
#count <- dat[which(dat$p_value <= 0.05), ] dat <- d1 head(dat)
dat <- dat %>% arrange(protein_name) ## make proteinname as alphabetical order
dat <- dat[c(2,1,3:28), ] ## make B7H3 to second row, B2M= beta-2-microglobul go to first row
count<- as.data.frame(dat)
label <- ProteinName[,1]
mean <- count[,5]
lower <- count[,6]
upper <- count[,7]
anno <- count[,9]
plot <- data.frame(label, mean, lower, upper, anno)
colnames(plot)<-c("label","mean", "lower", "upper", "anno") # colnames(df) have to be behind df
return(plot)
} ### work for all data-make
library(meta)
library(grid)
library(gridExtra)
plot <- fun_makedataforforest(dat=d4_TNBC29, ProteinName= ProteinName28) ################################### given data --- important---
plot$label<-as.character(plot$label)
plot$anno<-as.character(plot$anno)
tabletext <- c("ProteinName", plot$label) # tabletext <- cbind(c("ProteinName", plot$label), c("Log2FC(95%CI)", plot$anno))
xticks1 <- seq(from=-2, to=4, by=0.5)
#plot1 <-
forestplot(tabletext, graph.pos = 2,
mean=c(NA, plot$mean),
lower=c(NA, plot$lower),
upper=c(NA, plot$upper), zero=0,
cex=1.5, col = fpColors(lines="blue"),
txt_gp = own,
boxsize=0.25,
vertices=TRUE,
xticks=xticks1, xlab="Log2 Fold Change",
title=" ")
#grid.grabExpr(plot1)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
# Figure 6B: TNBC TMA DSP Tumor RFS-yes vs RFS-no
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
library(meta)
library(grid)
library(gridExtra)
dat <- d5_TNBC29
dat <- dat %>% arrange(protein_name) ## make proteinname as alphabetical order
dat <- dat[c(2,1,3:28), ] ## make B7H3 to second row, B2M= beta-2-microglobul go to first row
count<- as.data.frame(dat)
label <- ProteinName28[,1]
mean <- count[,5]
lower <- count[,6]
upper <- count[,7]
anno <- count[,9]
pvalue <- count[,10]
plot <- data.frame(label, mean, lower, upper, anno, pvalue)
## plot <- plot[which(plot$pvalue <= 0.05), ]
colnames(plot)<-c("label","mean", "lower", "upper", "anno", "pvalue") # colnames(df) have to be behind df
################################################### given data --- important---
plot$label<-as.character(plot$label)
plot$anno<-as.character(plot$anno)
tabletext <- c("ProteinName", plot$label) # tabletext <- cbind(c("ProteinName", plot$label), c("Log2FC(95%CI)", plot$anno))
xticks1 <- seq(from=-1, to=1.5, by=0.5)
#plot1 <-
forestplot(tabletext, graph.pos = 2,
mean=c(NA, plot$mean),
lower=c(NA, plot$lower),
upper=c(NA, plot$upper), zero=0,
cex=1.5, col = fpColors(lines="blue"),
txt_gp = own,
boxsize=0.25,
vertices=TRUE,
xticks=xticks1, xlab="Log2 Fold Change",
title=" ")
#grid.grabExpr(plot1)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
# Figure 6C: TNBC TMA DSP Stroma RFS-yes vs RFS-no
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
library(meta)
library(grid)
library(gridExtra)
dat <- d6_TNBC29
dat <- dat %>% arrange(protein_name) ## make proteinname as alphabetical order
dat <- dat[c(2,1,3:28), ] ## make B7H3 to second row, B2M= beta-2-microglobul go to first row
count<- as.data.frame(dat)
label <- ProteinName28[,1]
mean <- count[,5]
lower <- count[,6]
upper <- count[,7]
anno <- count[,9]
pvalue <- count[,10]
plot <- data.frame(label, mean, lower, upper, anno, pvalue)
## plot <- plot[which(plot$pvalue <= 0.05), ]
colnames(plot)<-c("label","mean", "lower", "upper", "anno", "pvalue") # colnames(df) have to be behind df
################################################### given data --- important---
plot$label<-as.character(plot$label)
plot$anno<-as.character(plot$anno)
tabletext <- c("ProteinName", plot$label) # tabletext <- cbind(c("ProteinName", plot$label), c("Log2FC(95%CI)", plot$anno))
xticks1 <- seq(from=-1, to=1, by=0.5)
#plot1 <-
forestplot(tabletext, graph.pos = 2,
mean=c(NA, plot$mean),
lower=c(NA, plot$lower),
upper=c(NA, plot$upper), zero=0,
cex=1.5, col = fpColors(lines="blue"),
txt_gp = own,
boxsize=0.25,
vertices=TRUE,
xticks=xticks1, xlab="Log2 Fold Change",
title=" ")
#grid.grabExpr(plot1)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
# Figure 8: KM curve for relapse free survival by CD45+ Cells/mm2 median
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=6, fig.height=4}
d1 <- read_excel("/projects/bsi/fl/studies/s214070.Thompson.DSP2/re_analyze_FinXX950/data/HALO_FinXX_Cleaneddata_group.xlsx", sheet = "Sheet2") #
d1 <- d1 %>% dplyr::select(Tag, CD45posCKnegCD68neg_per_mm2, CD68posCKneg_per_mm2, gp_CD45posCKnegCD68neg, gp_CD68posCKneg ) %>%
arrange(Tag) %>%
rename(PatientID = Tag, CD45p_mm2 = gp_CD45posCKnegCD68neg, CD68p_mm2 = gp_CD68posCKneg)
d1$CD45p_mm2 <- factor(d1$CD45p_mm2, levels = c("lower", "middle", "upper"), labels = c("Low", "Mid", "High"))
d1$CD68p_mm2 <- factor(d1$CD68p_mm2, levels = c("lower", "middle", "upper"), labels = c("Low", "Mid", "High"))
# colnames(d1) ## check data
# table(d1$CD45p_mm2)
d44RFS <- read_excel("/projects/bsi/fl/studies/s211340_thompson_DSP/DSPsurvivalRFS_Final44sample_45protein_950segment/data/r5_DSP_data_final_44_samples.xlsx")
d44RFS <- d44RFS %>% arrange (PatientID)
# colnames(d44RFS)
d12 <- merge(x=d1, y=d44RFS, by="PatientID", all.x=TRUE)
d12 <- d12 %>% mutate(RFS_c = 1-Censor_RFS )
#head(d12)
med45 <- median(d12$CD45posCKnegCD68neg_per_mm2)
med68 <- median(d12$CD68posCKneg_per_mm2)
d12_med <- d12 %>% mutate(CD45posCKnegCD68neg = case_when(
CD45posCKnegCD68neg_per_mm2 < med45 ~ "Low",
CD45posCKnegCD68neg_per_mm2 >= med45 ~ "High")) %>%
mutate(CD68posCKneg = case_when(
CD68posCKneg_per_mm2 < med68 ~ "Low",
CD68posCKneg_per_mm2 >= med68 ~ "High"))
```
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=8, fig.height=6}
# table(d12_med$CD45posCKnegCD68neg)
# table(d12_med$CD68posCKneg)
library(survminer)
library(survival)
os_fit <- survfit(Surv(time=RFS_years , event=RFS_c) ~ CD45posCKnegCD68neg , data=d12_med)
## Overall Group
os <- ggsurvplot(os_fit,
fun=function(y) y*100,
#fun = function(x) {1 - x},
xlab="RFS years",
ylab="Survival Probability (%)",
linetype = c(1, 1),
palette=c( "black" , "red"),
legend.title="",
legend = c(0.15,0.25),
legend.labs=c( "High" , "Low"),
font.legend = c(16, "bold", "black"),
censor = FALSE,
risk.table = TRUE,
risk.table.title = " Number at Risk",
risk.table.fontsize =9,
risk.table.height =.2,
font.x = c(16, "bold", "black"), ## can be "bold.italic",
font.y = c(16, "bold", "black"), ## can be "red", "darked"
font.tickslab = c(16, "bold", "black"),
break.time.by=2,
xlim=c(0, 10),
pval=TRUE,
ylim=c(0,100),
pval.coord = c(0.25, 2),
pval.size = 7.5,
font.pval = "bold",
title=" ",
tables.theme=theme_cleantable(),
axes.offset=TRUE,
tables.y.text=FALSE)
os$plot <- os$plot + theme(plot.margin = unit(c(5.5, 5.5, 5.5, 50), "points"),
plot.title= element_text(hjust=.5, color="black", size = 12, face="bold"),
axis.text = element_text( color="black", size = 12, face="bold"))+
theme(#legend.position="right",
legend.title = element_text(colour="black", size=16, face="bold") ,
legend.text = element_text(colour="black", size=16, face="bold"))
os$table <- os$table +
theme(plot.title = element_text(size = 16, color = "black", face = "bold", hjust = -0.25), ## hold size of number at risk
plot.margin = unit(c(5.5, 5.5, 5.5, 50), "points"),
legend.text = element_text(colour="black", size=12, face="bold"))
print(os)
```
# Figure 9: KM curve for relapse free survival by CD45+ Cells/mm2 Tertile
```{r echo=FALSE , warning=FALSE, message=FALSE, fig.width=8, fig.height=6}
library(survminer)
library(survival)
os_fit <- survfit(Surv(time=RFS_years , event=RFS_c) ~ CD45p_mm2 , data=d12)
## Overall Group
os <- ggsurvplot(os_fit,
fun=function(y) y*100,
#fun = function(x) {1 - x},
xlab="RFS years",
ylab="Survival Probability (%)",
linetype = c(1, 1, 1),
palette=c("red", "blue", "black"),
legend.title="",
legend = c(0.1,0.3),
legend.labs=c( "Low", "Mid", "High"),
font.legend = c(16, "bold", "black"),
censor = FALSE,
risk.table = TRUE,
risk.table.title = " Number at Risk",
risk.table.fontsize = 9, ## change number font size
risk.table.height =.25,
font.x = c(16, "bold", "black"), ## can be "bold.italic",
font.y = c(16, "bold", "black"), ## can be "red", "darked"
font.tickslab = c(16, "bold", "black"),
break.time.by=2,
xlim=c(0, 10),
pval=TRUE,
ylim=c(0,100),
pval.coord = c(0.1, 1),
pval.size = 7.5,
title=" ",
tables.theme=theme_cleantable(),
axes.offset=TRUE,
tables.y.text=FALSE)
os$plot <- os$plot + theme(plot.margin = unit(c(5.5, 5.5, 5.5, 50), "points"),
plot.title= element_text(hjust=.5,color="black", size = 12, face="bold"),
axis.text = element_text( color="black", size = 16, face="bold"),
legend.title = element_text(colour="black", size=16, face="bold") ,
legend.text = element_text(colour="black", size=16, face="bold")) # chenge high low
# annotate("text", x = 10, y = 15, label = "P-value", vjust=0, hjust = 1.1, face = "bold", fontface=16) ## add some the figure
# legend.position="right",
os$table <- os$table +
theme(plot.margin = unit(c(5.5, 5.5, 5.5, 50), "points"),
plot.title = element_text(size = 16, color = "black", face = "bold", hjust = -0.25),
legend.text = element_text(colour="black", size=16, face="bold"))
print(os)
# ---------------forest 1 done ---------------------tumor vs stroma -----------
```
```{r include=FALSE, echo=FALSE , warning=FALSE, message=FALSE, fig.width=8, fig.height=6}
library(survminer)
library(survival)
os_fit <- survfit(Surv(time=RFS_years , event=RFS_c) ~ CD45p_mm2 , data=d12)
## Overall Group
os <- ggsurvplot(os_fit,
fun=function(y) y*100,
#fun = function(x) {1 - x},
main="main",
submain ="submain",
caption="caption",
xlab="RFS years",
ylab="Survival Probability (%)",
linetype = c(1, 1, 1),
palette=c("red", "blue", "black"),
legend.title="legend.title",
legend = c(0.1,0.3),
legend.labs=c( "Low", "Mid", "High"),
font.legend = c(16, "bold", "black"),
censor = FALSE,
risk.table = TRUE,
risk.table.title = " Number at Risk",
risk.table.fontsize = 9, ## change number font size
risk.table.height =.25,
font.x = c(16, "bold", "black"), ## can be "bold.italic",
font.y = c(16, "bold", "black"), ## can be "red", "darked"
font.tickslab = c(16, "bold", "black"),
break.time.by=2,
xlim=c(0, 10),
pval=TRUE,
ylim=c(0,100),
break.y.by=20,
pval.coord = c(0.1, 1),
pval.size = 7.5,
pval.font = c(26, "bold", "black"),
title="title",
tables.theme=theme_cleantable(),
axes.offset=TRUE,
tables.y.text=FALSE)
print(os)
os <- os + theme_survminer(font.main = c(16, "bold", "black"), font.submain = c(15, "bold", "black"),
font.x = c(14, "bold", "black"), font.y = c(14, "bold", "black"),
font.caption = c(15, "bold", "black"), font.tickslab = c(12, "bold", "black"),
legend= c("bottom") , #legend = c("top", "bottom", "left", "right", "none"), ## bold or plain
font.legend = c(15, "bold", "black") )
print(os)
os$plot <- os$plot + theme(plot.margin = unit(c(5.5, 5.5, 5.5, 50), "points"),
plot.title= element_text(hjust=.5,color="black", size = 12, face="bold"),
axis.text = element_text( color="black", size = 16, face="bold"),
legend.title = element_text(colour="black", size=16, face="bold") ,
legend.text = element_text(colour="black", size=16, face="bold")) # chenge high low
# annotate("text", x = 10, y = 15, label = "P-value", vjust=0, hjust = 1.1, face = "bold", fontface=16) ## add some the figure
# legend.position="right",
os$plot
os$table <- os$table +
theme(plot.margin = unit(c(5.5, 5.5, 5.5, 50), "points"),
plot.title = element_text(size = 16, color = "black", face = "bold", hjust = -0.25),
legend.text = element_text(colour="black", size=16, face="bold"))
os$table
print(os)
```