-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfig.S3_tspo_spi_foldchange_boxplot_script.R
169 lines (133 loc) · 6.4 KB
/
fig.S3_tspo_spi_foldchange_boxplot_script.R
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
library(ggplot2)
library(dplyr)
library(DESeq2)
library(greekLetters)
load("multi_species_tspo_expression/GSE36952_GSE66593_Human_macrophage_RNASeq/GSE36952_dds.RData")
dt <- read.delim("multi_species_tspo_expression/GSE36952_GSE66593_Human_macrophage_RNASeq/GSE36952.foldchnage.IFNgvsCT.txt")
dt %>%
filter(GeneName %in% c("TSPO", "SPI1"))
col_idx <- which(colData(dds)$Treatment %in% c("None", "IFNg"))
row_idx <- which(rownames(dds) %in% c("TSPO"))
counts(dds, normalized = T)[row_idx, col_idx]
tspo <- data.frame(gene_name = "TSPO",
simulation = colData(dds)$Treatment[col_idx],
duration = "24h",
species = "Human",
exprs = log2(counts(dds, normalized = T)[row_idx, col_idx]),
logFC = "logFC=-0.41",
padj = "p.adj=1")
row_idx <- which(rownames(dds) %in% c("SPI1"))
counts(dds, normalized = T)[row_idx, col_idx]
spi1 <- data.frame(gene_name = "SPI1(PU.1)",
simulation = colData(dds)$Treatment[col_idx],
duration = "24h",
species = "Human",
exprs = log2(counts(dds, normalized = T)[row_idx, col_idx]),
logFC = "logFC=0.1",
padj = "p.adj=1")
dt <- rbind(tspo, spi1)
dt <- dt %>%
mutate(treatment = case_when(simulation %in% "None" ~ "Baseline",
simulation %in% "IFNg" ~ paste0("IFN", greek_vector["gamma"]))
)
ann_text <- dt %>%
mutate(label = sprintf("%s \n %s", logFC, padj)) %>%
group_by(gene_name) %>%
mutate(y_val = max(exprs) + 1) %>%
ungroup() %>%
select(-exprs) %>%
distinct()
palette_choice <- paletteer::paletteer_d("ggsci::nrc_npg")
ggplot(dt)+
geom_boxplot(aes(x = gene_name, y = exprs, fill = treatment),
color = "black", outlier.colour = "white")+
geom_point(aes(x = gene_name, y = exprs, fill = treatment),
position = position_jitterdodge(0.1),
shape = 21, size = 3, show.legend = F)+
ylab("Normalized expression")+
xlab("")+
scale_color_manual(name = NULL, values = palette_choice[c(2,1)],
aesthetics = c("colour", "fill")) +
theme_bw() +
theme(axis.text.x = element_text(color = "black", size = 16),
axis.text.y = element_text(color = "black", size = 16),
axis.title = element_text(color = "black", size = 18),
strip.text = element_text(color = "black", size = 18),
legend.text = element_text(color = "black", size = 18),
panel.border = element_rect(color = "black", fill = NA),
panel.grid = element_blank(),
panel.background = element_rect(fill = "transparent"),
plot.background = element_rect(fill = "transparent"),
legend.background = element_rect(fill = "transparent"))
# geom_text(data = ann_text,
# aes(x = gene_name, y = y_val, label = label),
# color = "black", show.legend = F, size = 6) +
# scale_y_continuous(limits = c(NA, max(dt$exprs+2)))
ggsave("manuscript_fig_doc/TSPO_SPI1_boxplot_IFNg.png",
units = "in", width = 6, height = 4, dpi = 300, bg = "transparent")
####
GSE38371 <- read.table("multi_species_tspo_expression/GSE38371_mouse_IFNg_BMDM/GSM940702_IFNg_gene_exp.diff.txt", header = T)
GSE38371 %>%
filter(test_id %in% c("ENSMUSG00000041736"))
mtspo <- data.frame(dataset_id = "GSE38371",
simulation = c("Baseline", "IFNg"),
duration = "4h",
species = "Mouse",
exprs = log2(c(GSE38371 %>%
filter(test_id %in% c("ENSMUSG00000041736")) %>%
pull(value_1),
GSE38371 %>%
filter(test_id %in% c("ENSMUSG00000041736")) %>%
pull(value_2))),
logFC = "logFC=1.28",
padj = "p.adj=0.1982")
col_idx <- which(colData(dds)$Treatment %in% c("None", "IFNg"))
row_idx <- which(rownames(dds) %in% c("TSPO"))
counts(dds, normalized = T)[row_idx, col_idx]
htspo <- data.frame(dataset_id = "GSE36952",
simulation = colData(dds)$Treatment[col_idx],
duration = "24h",
species = "Human",
exprs = log2(counts(dds, normalized = T)[row_idx, col_idx]),
logFC = "logFC=-0.41",
padj = "p.adj=1")
dt <- rbind(htspo, mtspo)
dt <- dt %>%
mutate(treatment = case_when(simulation %in% c("None", "Baseline") ~ "Baseline",
simulation %in% "IFNg" ~ paste0("IFN", greek_vector["gamma"]))
)
ann_text <- dt %>%
mutate(label = sprintf("%s \n %s", logFC, padj)) %>%
group_by(dataset_id) %>%
mutate(y_val = max(exprs) + 1) %>%
ungroup() %>%
select(-c(exprs, simulation)) %>%
distinct()
palette_choice <- paletteer::paletteer_d("ggsci::nrc_npg")
ggplot(dt)+
geom_boxplot(aes(x = species, y = exprs, fill = treatment),
color = "black", outlier.colour = "white")+
geom_point(aes(x = species, y = exprs, fill = treatment),
position = position_jitterdodge(0.1),
shape = 21, size = 3, show.legend = F)+
ylab("Normalized expression")+
xlab("")+
scale_color_manual(name = NULL, values = palette_choice[c(2,1)],
aesthetics = c("colour", "fill")) +
theme_bw() +
theme(axis.text.x = element_text(color = "black", size = 16),
axis.text.y = element_text(color = "black", size = 16),
axis.title = element_text(color = "black", size = 18),
strip.text = element_text(color = "black", size = 18),
legend.text = element_text(color = "black", size = 18),
panel.border = element_rect(color = "black", fill = NA),
panel.grid = element_blank(),
panel.background = element_rect(fill = "transparent"),
plot.background = element_rect(fill = "transparent"),
legend.background = element_rect(fill = "transparent"))
# geom_text(data = ann_text,
# aes(x = species, y = y_val, label = label),
# color = "black", show.legend = F, size = 6) +
# scale_y_continuous(limits = c(NA, max(dt$exprs+2)))
ggsave("manuscript_fig_doc/TSPO_foldchange_IFNg_human_mouse_boxplot.png",
units = "in", width = 6, height = 4, dpi = 300, bg = "transparent")