-
Notifications
You must be signed in to change notification settings - Fork 0
/
DESeq2.R
242 lines (186 loc) · 9.16 KB
/
DESeq2.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
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
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("DESeq2")
library(DESeq2)
library(ggplot2)
setwd("D:\\setolabo\\DESeq2")
#111111111111111111111111111111111111111111111111111111111111111111111111111
count_data1 <- read.csv("PRJNA956559counts.csv", row.names=1)
sample_data1 <- read.csv("PRJNA956559.csv", row.names=1)
# Create DESeqDataSet object
dds1 <- DESeqDataSetFromMatrix(countData = count_data1,
colData = sample_data1,
design = ~ condition)
# Run DESeq2 pipeline
dds1 <- DESeq(dds1)
# Extract results
results1 <- results(dds1)
# Save results to a file
write.csv(as.data.frame(results1), file = "PRJNA956559_results.csv")
# use rlog transformation (slower, better for smaller datasets)
rld1 <- rlog(dds1, blind=FALSE)
# Extract PCA data with sample labels
pca_data1 <- plotPCA(rld1, intgroup="condition", returnData=TRUE)
# Plot PCA
ggplot(pca_data1, aes(x = PC1, y = PC2, color = condition, label = name)) +
geom_point(size = 3) +
geom_text(aes(label = name), vjust = -1, hjust = 0.5, size = 1.5) + # Add sample labels
labs(title = "PCA Plot", x = paste0("PC1: ", round(100 * attr(pca_data, "percentVar")[1], 1), "% variance"),
y = paste0("PC2: ", round(100 * attr(pca_data, "percentVar")[2], 1), "% variance")) +
theme_minimal() +
theme(
axis.title.x = element_text(size = 16), # Adjust x-axis title font size
axis.title.y = element_text(size = 16), # Adjust y-axis title font size
axis.text = element_text(size = 14), # Adjust axis tick labels font size
plot.title = element_text(size = 10, face = "bold") # Adjust title font size
)
#22222222222222222222222222222222222222222222222222222222222222222222
count_data2 <- read.csv("PRJNA946800counts.csv", row.names=1)
sample_data2 <- read.csv("PRJNA946800.csv", row.names=1)
# Create DESeqDataSet object
dds2 <- DESeqDataSetFromMatrix(countData = count_data2,
colData = sample_data2,
design = ~ condition)
# Run DESeq2 pipeline
dds2 <- DESeq(dds2)
# Extract results
results2 <- results(dds2)
# Save results to a file
write.csv(as.data.frame(results2), file = "PRJNA946800_results.csv")
# use rlog transformation (slower, better for smaller datasets)
rld2 <- rlog(dds2, blind=FALSE)
# Extract PCA data with sample labels
pca_data2 <- plotPCA(rld2, intgroup="condition", returnData=TRUE)
# Plot PCA
ggplot(pca_data2, aes(x = PC1, y = PC2, color = condition, label = name)) +
geom_point(size = 3) +
geom_text(aes(label = name), vjust = -1, hjust = 0.5, size = 1.5) + # Add sample labels
labs(title = "PCA Plot", x = paste0("PC1: ", round(100 * attr(pca_data, "percentVar")[1], 1), "% variance"),
y = paste0("PC2: ", round(100 * attr(pca_data, "percentVar")[2], 1), "% variance")) +
theme_minimal() +
theme(
axis.title.x = element_text(size = 16), # Adjust x-axis title font size
axis.title.y = element_text(size = 16), # Adjust y-axis title font size
axis.text = element_text(size = 14), # Adjust axis tick labels font size
plot.title = element_text(size = 10, face = "bold") # Adjust title font size
)
#3333333333333333333333333333333333333333333333333333333333333333333333333333
count_data3 <- read.csv("PRJNA540915counts.csv", row.names=1)
sample_data3 <- read.csv("PRJNA540915.csv", row.names=1)
# Create DESeqDataSet object
dds3 <- DESeqDataSetFromMatrix(countData = count_data3,
colData = sample_data3,
design = ~ condition)
# Run DESeq2 pipeline
dds3 <- DESeq(dds3)
# Extract results
results3 <- results(dds3)
# Save results to a file
write.csv(as.data.frame(results3), file = "PRJNA540915_results.csv")
# use rlog transformation (slower, better for smaller datasets)
rld3 <- rlog(dds3, blind=FALSE)
# Extract PCA data with sample labels
pca_data3 <- plotPCA(rld3, intgroup="condition", returnData=TRUE)
# Plot PCA
ggplot(pca_data3, aes(x = PC1, y = PC2, color = condition, label = name)) +
geom_point(size = 3) +
geom_text(aes(label = name), vjust = -1, hjust = 0.5, size = 1.5) + # Add sample labels
labs(title = "PCA Plot", x = paste0("PC1: ", round(100 * attr(pca_data, "percentVar")[1], 1), "% variance"),
y = paste0("PC2: ", round(100 * attr(pca_data, "percentVar")[2], 1), "% variance")) +
theme_minimal() +
theme(
axis.title.x = element_text(size = 16), # Adjust x-axis title font size
axis.title.y = element_text(size = 16), # Adjust y-axis title font size
axis.text = element_text(size = 14), # Adjust axis tick labels font size
plot.title = element_text(size = 10, face = "bold") # Adjust title font size
)
#44444444444444444444444444444444444444444444444444444444444444444444444
count_data4 <- read.csv("PRJNA350003counts.csv", row.names=1)
sample_data4 <- read.csv("PRJNA350003.csv", row.names=1)
# Create DESeqDataSet object
dds4 <- DESeqDataSetFromMatrix(countData = count_data4,
colData = sample_data4,
design = ~ condition)
# Run DESeq2 pipeline
dds4 <- DESeq(dds4)
# Extract results
results4 <- results(dds4)
# Save results to a file
write.csv(as.data.frame(results4), file = "PRJNA350003_results.csv")
# use rlog transformation (slower, better for smaller datasets)
rld4 <- rlog(dds4, blind=FALSE)
# Extract PCA data with sample labels
pca_data4 <- plotPCA(rld4, intgroup="condition", returnData=TRUE)
# Plot PCA
ggplot(pca_data4, aes(x = PC1, y = PC2, color = condition, label = name)) +
geom_point(size = 3) +
geom_text(aes(label = name), vjust = -1, hjust = 0.5, size = 1.5) + # Add sample labels
labs(title = "PCA Plot", x = paste0("PC1: ", round(100 * attr(pca_data, "percentVar")[1], 1), "% variance"),
y = paste0("PC2: ", round(100 * attr(pca_data, "percentVar")[2], 1), "% variance")) +
theme_minimal() +
theme(
axis.title.x = element_text(size = 16), # Adjust x-axis title font size
axis.title.y = element_text(size = 16), # Adjust y-axis title font size
axis.text = element_text(size = 14), # Adjust axis tick labels font size
plot.title = element_text(size = 10, face = "bold") # Adjust title font size
)
#55555555555555555555555555555555555555555555555555555555555555555555555
count_data5 <- read.csv("PRJNA347596counts.csv", row.names=1)
sample_data5 <- read.csv("PRJNA347596.csv", row.names=1)
# Create DESeqDataSet object
dds5 <- DESeqDataSetFromMatrix(countData = count_data5,
colData = sample_data5,
design = ~ condition)
# Run DESeq2 pipeline
dds5 <- DESeq(dds5)
# Extract results
results5 <- results(dds5)
# Save results to a file
write.csv(as.data.frame(results5), file = "PRJNA347596_results.csv")
# use rlog transformation (slower, better for smaller datasets)
rld5 <- rlog(dds5, blind=FALSE)
# Extract PCA data with sample labels
pca_data5 <- plotPCA(rld5, intgroup="condition", returnData=TRUE)
# Plot PCA
ggplot(pca_data5, aes(x = PC1, y = PC2, color = condition, label = name)) +
geom_point(size = 3) +
geom_text(aes(label = name), vjust = -1, hjust = 0.5, size = 1.5) + # Add sample labels
labs(title = "PCA Plot", x = paste0("PC1: ", round(100 * attr(pca_data, "percentVar")[1], 1), "% variance"),
y = paste0("PC2: ", round(100 * attr(pca_data, "percentVar")[2], 1), "% variance")) +
theme_minimal() +
theme(
axis.title.x = element_text(size = 16), # Adjust x-axis title font size
axis.title.y = element_text(size = 16), # Adjust y-axis title font size
axis.text = element_text(size = 14), # Adjust axis tick labels font size
plot.title = element_text(size = 10, face = "bold") # Adjust title font size
)
#6666666666666666666666666666666666666666666666666666666666666666666666666
count_data6 <- read.csv("PRJNA866134counts.csv", row.names=1)
sample_data6 <- read.csv("PRJNA866134.csv", row.names=1)
# Create DESeqDataSet object
dds6 <- DESeqDataSetFromMatrix(countData = count_data6,
colData = sample_data6,
design = ~ condition)
# Run DESeq2 pipeline
dds6 <- DESeq(dds6)
# Extract results
results6 <- results(dds6)
# Save results to a file
write.csv(as.data.frame(results6), file = "PRJNA866134_results.csv")
# use rlog transformation (slower, better for smaller datasets)
rld6 <- rlog(dds6, blind=FALSE)
# Extract PCA data with sample labels
pca_data6 <- plotPCA(rld6, intgroup="condition", returnData=TRUE)
# Plot PCA
ggplot(pca_data6, aes(x = PC1, y = PC2, color = condition, label = name)) +
geom_point(size = 3) +
geom_text(aes(label = name), vjust = -1, hjust = 0.5, size = 1.5) + # Add sample labels
labs(title = "PCA Plot", x = paste0("PC1: ", round(100 * attr(pca_data, "percentVar")[1], 1), "% variance"),
y = paste0("PC2: ", round(100 * attr(pca_data, "percentVar")[2], 1), "% variance")) +
theme_minimal() +
theme(
axis.title.x = element_text(size = 16), # Adjust x-axis title font size
axis.title.y = element_text(size = 16), # Adjust y-axis title font size
axis.text = element_text(size = 14), # Adjust axis tick labels font size
plot.title = element_text(size = 10, face = "bold") # Adjust title font size
)