-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTT3.proj.Rmd
350 lines (251 loc) · 7.11 KB
/
TT3.proj.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
---
title: "Biometrics 1 (Bio360) Final Test"
output:
pdf_document: default
html_notebook: default
---
# A case study based on
### Ural, B.B., Caron, D.P., Dogra, P. et al. Inhaled particulate accumulation with age impairs immune function and architecture in human lung lymph nodes. Nat Med 28, 2622–2632 (2022). https://doi.org/10.1038/s41591-022-02073-x
```{r}
library(readr)
library(ggplot2)
library(purrr)
library(dplyr)
```
# Study Part 1
## Lung lymphs nodes (LLNs) accumulate carbon-pollutant particulates and turn black with age, unlike mesenteric lymph nodes (MLNs).
### We make two linear regression models, one for LNNs and one for MLNs.
x = Age
y = Percent Lymph Node showing particulate accumulation
```{r}
A.da <- read_csv("AgeLNdata.csv")
```
```{r}
ggplot(A.da, aes(x=Age, y=Percent, shape=Type, color=Type)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, fullrange=TRUE) +
labs(title= "Age and Lympth Node Particulate Accumulation", y= "% Particulate Accumulation") +
theme_bw() + theme(text = element_text(size =13))
ggsave("AgeVsLNs.pdf")
ggsave("AgeVsLNs.png")
```
Subset data
```{r}
LLN<- A.da[A.da$Type=="LLN",]
MLN <-A.da[A.da$Type=="MLN",]
```
```{r}
mod.LLN <-lm(Age~Percent, data=LLN)
summary(mod.LLN)
```
Check residuals
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(mod.LLN)
par(mfrow=c(1,1))
```
```{r}
mod.MLN <-lm(Age~Percent, data=MLN)
summary(mod.MLN)
```
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(mod.MLN)
par(mfrow=c(1,1))
```
# Part 2
## The CD68+CD169− subset of LN macrophages contain the particulates.
### Use an ANOVA to test if one type of macrophage disproportionately accumulates these pollutant particulates.
Cell Count is # of cells that contain particulates/mm2
```{r}
da2 <- read_csv("part2data.csv")
da2$Macrophage <- as.factor(da2$Macrophage)
```
```{r}
ggplot(da2, aes(x=Macrophage, y=CellCount)) +
geom_boxplot() +
theme_bw() + theme(text = element_text(size = 14))
ggsave("ANOVAboxplot.pdf")
ggsave("ANOVAboxplot.png")
```
Using
```{r}
M.stats <- da2 %>%
split(.$Macrophage) %>%
map(summary)
M.stats
```
```{r}
tapply(da2$CellCount, da2$Macrophage, c(summary, mean)) # Summary by group using tapply
```
```{r}
da2 %>%
select(-Age) %>%
group_by(Macrophage) %>%
summarise(mean=mean(CellCount), sd=sd(CellCount), n=n())
```
```{r}
AnovaMod <- aov(CellCount ~ Macrophage, data=da2)
summary(AnovaMod)
lsr::etaSquared(AnovaMod)
```
```{r}
tukey.res<- TukeyHSD(AnovaMod)
tukey.res
#plotTukeyHSD(tukey.res)
```
```{r}
plot(tukey.res)
```
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(AnovaMod)
par(mfrow=c(1,1))
```
## Regression Models
```{r}
data <- read_csv("regressiondata.csv")
```
```{r}
ggplot(data, aes(x=Age, y=Arginine_IL6, color=Macrophage)) +
geom_point(size=2.5) +
geom_smooth(method=lm, se=FALSE, fullrange=TRUE) +
labs(title= "Regression Model Matching") +
theme_bw() +theme(text = element_text(size = 12))
ggsave("RegModelMatch.pdf")
ggsave("RegModelMatch.png")
```
```{r}
a <- data[data$Macrophage == "CD3. w/particulates",]
mod.a <- lm(Arginine_IL6 ~ Age, data=a)
summary(mod.a)
```
```{r}
b <- data[data$Macrophage == "CD3. w/o particulates",]
mod.b <- lm(Arginine_IL6 ~ Age, data=b)
summary(mod.b)
```
```{r}
c <- data[data$Macrophage == "CD2. w/particulates",]
mod.c <- lm(Arginine_IL6 ~ Age, data=c)
summary(mod.c)
```
```{r}
d <- data[data$Macrophage == "CD2. w/o particulates",]
mod.d <- lm(Arginine_IL6 ~ Age, data=d)
summary(mod.d)
```
# Part 3
## Particulate Accumulation impairs immune function
### "Expression of the key activation markers CD80 and CD86 and the phagocytic marker CD36 decreased with age specifically in CD68+CD169− macrophages in LLNs but not in MLNs. In contrast, CD209 expression was not altered significantly with age in any macrophage subset at either site (Fig. 3e and Extended Data Fig. 4b). These results show that while the frequencies of LN macrophage subsets are largely maintained as age progresses, the expression of functional markers specifically in the CD68+CD169− subset within LLNs decreases with age, suggesting that particulates may have specific effects on macrophage function."
```{r}
part3data <- read_csv("part3data.csv")
part3data$Label <- "X"
part3data[42,6] <- "P3"
part3data[52,6] <- "P4"
part3data[41,6] <- "P1"
part3data[33,6] <- "P2"
part3data$Label <- as.factor(part3data$Label)
part3dataLLN <- part3data[part3data$LNType == "LLN",]
part3dataMLN <- part3data[part3data$LNType == "MLN",]
```
geom_text(data=subset(mtcars, wt > 4 | mpg > 25),
aes(wt,mpg,label=name))
```{r}
ggplot(part3dataLLN, aes(x=Age, y=Percent, shape=Marker, color=Marker, label= Label)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, fullrange=TRUE) +
labs(title= "LLN immunity markers and age", y= "% Marker") +
theme_bw()+
geom_text(data = subset(part3dataLLN,
Label == "P1"| Label == "P2"| Label == "P3" | Label=="P4"), aes(label=Label), hjust=0, vjust=1)
ggsave("LNNmarkers.pdf")
ggsave("LNNmarkers.png")
```
```{r}
da36 <- part3dataLLN[part3dataLLN$Marker == "CD36",]
modCD36LLN <- lm(Percent ~ Age, data=da36)
summary(modCD36LLN)
```
Check residuals
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(modCD36LLN)
par(mfrow=c(1,1))
```
```{r}
da209 <- part3dataLLN[part3dataLLN$Marker == "CD209",]
mod209LLN<- lm(Percent ~ Age, data=da209)
summary(mod209LLN)
```
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(mod209LLN)
par(mfrow=c(1,1))
```
```{r}
da80 <- part3dataLLN[part3dataLLN$Marker == "CD80/86",]
modCD80LLN <- lm(Percent ~ Age, data=da80)
summary(modCD80LLN)
```
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(modCD80LLN)
par(mfrow=c(1,1))
```
```{r}
da209b <- da209[-c(1, 11),]
mod209LLNb<- lm(Percent ~ Age, data=da209b)
summary(mod209LLNb)
```
```{r}
ggplot(da209b, aes(x=Age, y=Percent, shape=Marker, color=Marker)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, fullrange=TRUE) +
labs(title= "LLN immunity markers and age", y= "% Marker") +
theme_bw()
```
```{r}
da36.8086<- part3dataLLN[part3dataLLN$Marker == "CD36" | part3dataLLN$Marker == "CD80/86",]
modcomLLN<- lm(Percent ~ Age, data=da36.8086)
summary(modcomLLN)
```
```{r}
ggplot(part3dataMLN, aes(x=Age, y=Percent, shape=Marker, color=Marker)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, fullrange=TRUE) +
labs(title= "MLN immunity markers and age", y= "% Marker") +
theme_bw()
ggsave("MLNmarkers.pdf")
ggsave("MLNmarkers.png")
```
```{r}
da36M <- part3dataMLN[part3dataMLN$Marker == "CD36",]
modCD36MLN <- lm(Percent ~ Age, data=da36M)
summary(modCD36MLN)
```
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(modCD36MLN)
par(mfrow=c(1,1))
```
```{r}
da209M <- part3dataMLN[part3dataMLN$Marker == "CD209",]
mod209MLN <- lm(Percent ~ Age, data=da209M)
summary(mod209MLN)
```
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(mod209MLN)
par(mfrow=c(1,1))
```
```{r}
da80M <- part3dataMLN[part3dataMLN$Marker == "CD80/86",]
mod80MLN <- lm(Percent ~ Age, data=da80M)
summary(mod80MLN)
```
```{r fig.height=3, fig.width=4.5}
par(mfrow=c(2,2))
plot(mod80MLN)
par(mfrow=c(1,1))
```