-
Notifications
You must be signed in to change notification settings - Fork 0
/
TIL_CD8_FoxP3_TMB_for_paper.Rmd
158 lines (113 loc) · 4.03 KB
/
TIL_CD8_FoxP3_TMB_for_paper.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
---
title: "J15221 Evanthia TNBC - Correlation TILs, CD8, FoxP3, TMB with response"
author: "Ludmila Danilova & Joseph Tandurella"
date: "`r Sys.Date()`"
output:
html_document:
toc: yes
toc_float: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE,
warning = FALSE)
rm(list = ls())
library(dplyr)
library(ggplot2)
library(ggpubr)
library(ggrepel)
library(data.table)
library("DT")
library(pheatmap)
library(gridExtra)
library(scales)
##Create All Facet for plotting
CreateAllFacet <- function(df, col){
df$facet <- df[[col]]
temp <- df
temp$facet <- "All"
merged <-rbind(temp, df)
# ensure the facet value is a factor
merged[[col]] <- as.factor(merged[[col]])
return(merged)
}
```
Create figures for the clinical paper
All data is coming from tables for the paper
```{r fig.width = 10}
# labels for time points
timeLab = c("Baseline", "Post Run-in", "Week 8")
# set colors
recistCol = c("Non-responder" = "red","Responder" = "blue")
cbrCol = c("CR,PR,SD" = "blue","PD" = "red")
subtypeCol = c("HR+" = "red", "TNBC" = "blue")
timeCol = setNames(c("black", 'grey45', 'grey75'), timeLab)
# set root folder
rootDir = "./"
# Load data patient data
dta_pts = read.csv(paste0(rootDir,"input_tables/table_24patient_info.csv"), row.names = 1)
dta_pts$ID = rownames(dta_pts)
# remove patients with no response
dta_pts = dta_pts %>% filter(Best_Resp != "Unknown")
#==========================
# file with TILs and PDL1 data
dat = read.csv(paste0(rootDir,"input_tables/table_per_sample_values.csv"))
#===========================
# add patient info
dat = cbind(dat, dta_pts[dat$patientID,])
df_Baseline <- dat %>% filter(timePoint == 'Baseline')
df_sampInfo <- CreateAllFacet(dat, "Subtype")
```
## TILs
```{r fig.width = 10}
##by type and RECIST
ggpaired(df_sampInfo %>% filter(!is.na(TILs)), x="timePoint",y="TILs", id = "patientID", line.color = "RECIST", line.size = 0.4,
palette = recistCol, title = "TILs. All Samples", xlab="Time", ylab="TILs") +
scale_x_discrete(labels=timeLab)+
stat_compare_means(comparisons = list(c(timeLab[1],timeLab[2]), c(timeLab[1],timeLab[3]),c(timeLab[2],timeLab[3])))+
# stat_compare_means(label.x=.85, label.y = 50 )
facet_wrap("facet")
```
## CD8
```{r fig.width = 10}
##by type and RECIST
ggpaired(df_sampInfo %>% filter(!is.na(CD8)), x="timePoint",y="CD8", id = "patientID", line.color = "RECIST", line.size = 0.4,
palette = recistCol, title = "CD8. All Samples", xlab="Time", ylab="CD8 Density") +
scale_x_discrete(labels=timeLab)+
scale_y_continuous(trans = "log10") +
stat_compare_means(comparisons = list(c(timeLab[1],timeLab[2]), c(timeLab[1],timeLab[3]),c(timeLab[2],timeLab[3])))+
facet_wrap("facet")
print("A summary table:")
# split by timePoint
dat1 = split(df_sampInfo, df_sampInfo$timePoint)
# get summary
tab = t(sapply(dat1, function(x) summary(x$CD8)))
print(tab)
tab = cbind(timePoint = rownames(tab), tab)
```
## FoxP3
```{r fig.width = 10}
##by type and RECIST
ggpaired(df_sampInfo %>% filter(!is.na(FOXP3)), x="timePoint",y="FOXP3", id = "patientID", line.color = "RECIST", line.size = 0.4,
palette = recistCol, title = "FOXP3. All Samples", xlab="Time", ylab="FOXP3 Density") +
scale_x_discrete(labels=timeLab)+
scale_y_continuous(trans = "log10") +
stat_compare_means(comparisons = list(c(timeLab[1],timeLab[2]), c(timeLab[1],timeLab[3]),c(timeLab[2],timeLab[3])))+
facet_wrap("facet")
```
## CD8/FoxP3
```{r fig.width = 10}
##by type and RECIST
ggpaired(df_sampInfo %>% filter(!is.na(ratio)), x="timePoint",y="ratio", id = "patientID", line.color = "RECIST", line.size = 0.4,
palette = recistCol, title = "CD8/FoxP3 ratio. All Samples", xlab="Time", ylab="CD8/FoxP3 ratio") +
scale_x_discrete(labels=timeLab)+
scale_y_continuous(trans = "log2") +
stat_compare_means(comparisons = list(c(timeLab[1],timeLab[2]), c(timeLab[1],timeLab[3]),c(timeLab[2],timeLab[3])))+
facet_wrap("facet")
```
## TMB
```{r fig.width = 10}
print(summary(df_Baseline$TMB_perMB))
```
```{r}
sessionInfo()
```