#Differential Expression Analysis # 2. load seurat object
#Load Seurat Object L7
load("../../../0-IMP-OBJECTS/Harmony_integrated_All_samples_Merged_with_PBMC10x_with_harmony_clustering.Robj")
All_samples_Merged
An object of class Seurat
64169 features across 59355 samples within 6 assays
Active assay: SCT (27417 features, 3000 variable features)
3 layers present: counts, data, scale.data
5 other assays present: RNA, ADT, prediction.score.celltype.l1, prediction.score.celltype.l2, prediction.score.celltype.l3
6 dimensional reductions calculated: integrated_dr, ref.umap, pca, umap, harmony, umap.harmony
DimPlot(All_samples_Merged, reduction = "umap.harmony", group.by = "cell_line",label = T, label.box = T)
DimPlot(All_samples_Merged, reduction = "umap.harmony", group.by = "Harmony_snn_res.0.9",label = T, label.box = T)
#Celltype tables based on cluster
# Create a table of clusters vs. cell types
cluster_celltype_l1_table <- table(All_samples_Merged$Harmony_snn_res.0.9, All_samples_Merged$predicted.celltype.l1)
# View the table
print(cluster_celltype_l1_table)
B CD4 T CD8 T DC Mono NK other other T
0 1 4659 1439 0 0 0 0 15
1 4 5215 1 1 2 0 0 0
2 1 4357 0 0 2 9 54 0
3 0 1910 1 0 0 2373 0 0
4 0 3545 0 3 0 5 703 0
5 4 3580 285 0 1 0 0 31
6 212 3441 13 69 35 8 30 5
7 8 3041 0 5 0 6 751 0
8 0 3277 15 1 9 443 0 0
9 0 3198 0 0 0 218 197 0
10 1 3035 12 0 19 0 2 1
11 18 19 1 194 2627 0 7 0
12 2109 77 5 0 0 1 2 0
13 1 1953 0 0 1 15 0 0
14 2 87 416 0 0 534 5 304
15 19 33 1 0 831 1 1 2
16 1 826 0 0 0 38 1 0
17 18 475 24 1 218 6 2 13
18 0 627 9 0 6 0 6 0
19 15 542 0 6 0 11 38 0
20 5 480 18 0 0 42 7 20
21 7 24 2 2 183 5 0 2
22 7 9 0 72 4 0 2 0
23 1 0 1 0 3 1 37 0
24 0 13 1 0 0 0 5 0
# Save the table as a CSV file
write.csv(cluster_celltype_l1_table, "cluster_celltype_l1_table.csv")
# Load the pheatmap library
library(pheatmap)
# Generate the cluster-cell type table
cluster_celltype_l1_table <- table(All_samples_Merged$Harmony_snn_res.0.9, All_samples_Merged$predicted.celltype.l1)
# Convert the table to a numeric matrix
cluster_celltype_l1_matrix <- as.matrix(cluster_celltype_l1_table)
# Create the heatmap
pheatmap(cluster_celltype_l1_matrix,
cluster_rows = TRUE, # Cluster rows (clusters)
cluster_cols = TRUE, # Cluster columns (cell types)
display_numbers = TRUE, # Display cell counts in the heatmap
color = colorRampPalette(c("white", "red"))(50), # Color gradient
main = "Cluster vs Cell Type (L1) Heatmap")
# Save the heatmap as a PNG
png("cluster_celltype_l1_heatmap.png", width = 800, height = 600)
pheatmap(cluster_celltype_l1_matrix,
cluster_rows = TRUE,
cluster_cols = TRUE,
display_numbers = TRUE,
color = colorRampPalette(c("white", "red"))(50),
main = "Cluster vs Cell Type (l1) Heatmap")
dev.off()
png
3
# Save the heatmap as a PDF
pdf("cluster_celltype_l1_heatmap.pdf", width = 10, height = 8)
pheatmap(cluster_celltype_l1_matrix,
cluster_rows = TRUE,
cluster_cols = TRUE,
display_numbers = TRUE,
color = colorRampPalette(c("white", "red"))(50),
main = "Cluster vs Cell Type (l1) Heatmap")
dev.off()
png
3
##. celltype_l2
# Create a table of clusters vs. cell types
cluster_celltype_l2_table <- table(All_samples_Merged$Harmony_snn_res.0.9, All_samples_Merged$predicted.celltype.l2)
# View the table
print(cluster_celltype_l2_table)
ASDC B intermediate B memory B naive CD14 Mono CD16 Mono CD4 CTL CD4 Naive CD4 Proliferating CD4 TCM CD4 TEM CD8 Naive
0 0 0 1 0 0 0 0 1953 1 2606 6 1315
1 0 0 5 0 1 1 0 0 4409 805 0 0
2 0 0 1 0 2 0 0 0 4338 19 0 0
3 0 0 0 0 0 0 0 0 1901 8 0 0
4 0 0 0 0 0 0 0 0 3476 69 0 0
5 0 1 2 1 1 0 0 35 6 3290 69 15
6 0 0 218 0 38 0 0 0 1977 1458 0 0
7 0 0 7 0 0 0 0 0 2989 52 0 0
8 0 0 0 0 9 0 0 0 2946 331 0 0
9 0 0 0 0 0 0 0 0 3183 15 0 0
10 0 0 0 0 20 0 0 0 402 2643 1 0
11 3 3 3 7 2522 105 0 0 1 18 0 0
12 0 664 260 1170 0 0 0 7 2 65 0 2
13 0 0 1 0 1 0 0 0 1846 107 0 0
14 0 1 0 1 0 0 16 0 1 53 15 1
15 0 17 2 0 812 19 0 0 0 32 0 1
16 0 0 1 0 0 0 0 0 825 1 0 0
17 0 4 5 6 218 0 0 6 28 392 3 18
18 0 0 0 0 6 0 0 0 48 580 0 1
19 0 2 13 0 0 0 0 0 498 44 0 0
20 0 2 1 1 0 0 0 40 133 256 0 17
21 0 0 0 6 183 1 1 1 0 20 0 2
22 0 2 2 0 7 0 0 0 1 3 0 0
23 0 0 1 0 3 0 0 0 0 0 0 1
24 0 0 0 0 0 0 0 1 0 11 0 0
CD8 Proliferating CD8 TCM CD8 TEM cDC1 cDC2 dnT gdT HSPC ILC MAIT NK NK Proliferating NK_CD56bright pDC Plasmablast
0 0 121 5 0 0 7 9 0 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 54 0 0 0 9 0 0 0
3 0 0 1 0 0 0 0 0 0 0 0 2374 0 0 0
4 0 0 0 0 1 0 0 705 0 0 0 5 0 0 0
5 0 237 40 0 0 24 6 0 0 8 0 0 0 0 0
6 2 0 7 5 47 7 0 37 0 0 0 8 0 0 0
7 0 0 0 0 0 0 0 757 0 0 0 6 0 0 0
8 0 9 5 0 1 0 0 0 0 0 0 443 0 0 0
9 0 0 0 0 0 0 0 197 0 0 0 218 0 0 0
10 0 0 0 0 0 1 0 3 0 0 0 0 0 0 0
11 0 0 1 13 122 0 0 6 0 0 0 0 0 56 5
12 0 2 1 0 0 2 0 1 1 0 1 0 0 0 11
13 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0
14 0 92 324 0 0 0 77 1 4 228 518 2 14 0 0
15 0 0 0 0 0 3 0 0 0 0 1 0 0 0 0
16 0 0 0 0 0 0 0 1 0 0 0 38 0 0 0
17 0 6 0 0 0 17 0 3 1 1 1 5 0 0 2
18 0 7 0 0 0 0 0 6 0 0 0 0 0 0 0
19 0 0 0 2 3 0 0 39 0 0 0 11 0 0 0
20 0 1 7 1 0 20 1 7 1 3 7 32 2 0 1
21 0 0 0 0 2 0 0 0 0 2 6 0 0 0 0
22 0 0 0 21 53 0 0 4 0 0 0 0 0 0 0
23 0 0 0 0 0 0 0 7 0 0 0 1 0 0 0
24 0 1 0 0 0 1 0 5 0 0 0 0 0 0 0
Platelet Treg
0 0 90
1 0 0
2 0 0
3 0 0
4 0 0
5 0 166
6 0 9
7 0 0
8 0 1
9 0 0
10 0 0
11 1 0
12 0 5
13 0 0
14 0 0
15 1 0
16 0 0
17 0 41
18 0 0
19 0 0
20 0 39
21 0 1
22 0 1
23 30 0
24 0 0
# Save the table as a CSV file
write.csv(cluster_celltype_l2_table, "cluster_celltype_l2_table.csv")
# Load the pheatmap library
library(pheatmap)
# Generate the cluster-cell type table
cluster_celltype_l2_table <- table(All_samples_Merged$Harmony_snn_res.0.9, All_samples_Merged$predicted.celltype.l2)
# Convert the table to a numeric matrix
cluster_celltype_l2_matrix <- as.matrix(cluster_celltype_l2_table)
# Create the heatmap
pheatmap(cluster_celltype_l2_matrix,
cluster_rows = TRUE, # Cluster rows (clusters)
cluster_cols = TRUE, # Cluster columns (cell types)
display_numbers = TRUE, # Display cell counts in the heatmap
color = colorRampPalette(c("white", "red"))(50), # Color gradient
main = "Cluster vs Cell Type (l2) Heatmap")
# Save the heatmap as a PNG
png("cluster_celltype_l2_heatmap.png", width = 1200, height = 800)
pheatmap(cluster_celltype_l2_matrix,
cluster_rows = TRUE,
cluster_cols = TRUE,
display_numbers = TRUE,
color = colorRampPalette(c("white", "red"))(50),
main = "Cluster vs Cell Type (l2) Heatmap")
dev.off()
png
3
# Save the heatmap as a PDF
pdf("cluster_celltype_l2_heatmap.pdf", width = 16, height = 12)
pheatmap(cluster_celltype_l2_matrix,
cluster_rows = TRUE,
cluster_cols = TRUE,
display_numbers = TRUE,
color = colorRampPalette(c("white", "red"))(50),
main = "Cluster vs Cell Type (l2) Heatmap")
dev.off()
png
3
##. celltype_l3
# Create a table of clusters vs. cell types
cluster_celltype_l3_table <- table(All_samples_Merged$Harmony_snn_res.0.9, All_samples_Merged$predicted.celltype.l3)
# View the table
print(cluster_celltype_l3_table)
ASDC_pDC B intermediate kappa B intermediate lambda B memory kappa B memory lambda B naive kappa B naive lambda CD14 Mono
0 0 0 0 0 1 0 0 0
1 0 0 0 2 1 0 0 1
2 0 0 0 0 1 0 0 2
3 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0
5 0 0 2 0 0 0 1 1
6 0 0 6 84 51 0 0 58
7 0 0 0 2 4 0 0 0
8 0 0 0 0 0 0 0 9
9 0 0 0 0 0 0 0 0
10 0 0 0 0 0 0 0 20
11 3 0 3 1 1 6 2 2523
12 0 127 520 78 200 899 266 0
13 0 0 0 1 0 0 0 1
14 0 0 1 0 0 0 1 0
15 0 0 17 1 1 0 0 813
16 0 0 0 1 0 0 0 0
17 0 0 5 0 1 0 6 218
18 0 0 0 0 0 0 0 6
19 0 0 2 1 5 0 0 0
CD16 Mono CD4 CTL CD4 Naive CD4 Proliferating CD4 TCM_1 CD4 TCM_2 CD4 TCM_3 CD4 TEM_1 CD4 TEM_2 CD4 TEM_3 CD8 Naive
0 0 0 1961 1 2594 6 11 0 4 2 1247
1 1 0 0 4409 0 802 2 0 0 0 0
2 0 0 0 4338 1 18 0 0 0 0 0
3 0 0 0 1901 0 8 0 0 0 0 0
4 0 0 0 3476 0 69 0 0 0 0 0
5 0 0 35 6 2344 364 559 6 22 47 4
6 0 0 0 1977 3 1389 58 0 0 0 0
7 0 0 0 2989 1 51 0 0 0 0 0
8 0 0 0 2946 1 315 12 0 0 0 0
9 0 0 0 3183 0 15 0 0 0 0 0
10 0 0 0 402 1410 527 423 1 0 0 0
11 105 0 0 1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 0 0 0 0
4 0 0 1 0 0 0 705 0 0 5 0 0 0 0 0 0 0
5 1 0 0 23 0 6 0 0 9 0 0 0 0 0 0 0 0
6 57 5 45 7 0 0 40 3 0 8 0 0 0 0 0 0 0
7 1 0 0 0 0 0 757 0 0 6 0 0 0 0 0 0 0
8 0 0 1 0 0 0 0 0 0 443 0 0 0 0 0 0 0
9 0 0 0 0 0 0 197 0 0 218 0 0 0 0 0 0 0
10 0 0 0 1 0 0 3 0 0 0 0 0 0 0 0 0 0
11 13 38 83 0 0 0 6 1 0 0 0 0 0 0 0 56 5
12 0 0 0 2 0 0 1 1 0 0 0 1 0 0 0 0 11
13 0 0 0 0 0 0 0 0 0 15 0 0 0 0 0 0 0
14 0 0 0 0 84 1 1 4 230 2 46 393 42 33 14 0 0
15 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0
16 0 0 0 0 0 0 1 0 0 38 0 0 0 0 0 0 0
17 2 0 0 18 0 0 4 1 1 5 1 0 0 0 0 0 2
18 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0
19 7 0 5 0 0 0 39 0 0 11 0 0 0 0 0 0 0
Platelet Treg Memory Treg Naive
0 0 55 27
1 0 1 0
2 0 0 0
3 0 0 0
4 0 0 0
5 0 175 1
6 0 12 0
7 0 0 0
8 0 3 0
9 0 0 0
10 0 1 0
11 1 1 0
12 0 5 0
13 0 0 0
14 0 0 0
15 1 0 0
16 0 0 0
17 0 51 0
18 0 0 0
19 0 0 0
[ getOption("max.print") est atteint -- 5 lignes omises ]
# Save the table as a CSV file
write.csv(cluster_celltype_l3_table, "cluster_celltype_l3_table.csv")
# Load the pheatmap library
library(pheatmap)
# Generate the cluster-cell type table
cluster_celltype_l3_table <- table(All_samples_Merged$Harmony_snn_res.0.9, All_samples_Merged$predicted.celltype.l3)
# Convert the table to a numeric matrix
cluster_celltype_l3_matrix <- as.matrix(cluster_celltype_l3_table)
# Create the heatmap
pheatmap(cluster_celltype_l3_matrix,
cluster_rows = TRUE, # Cluster rows (clusters)
cluster_cols = TRUE, # Cluster columns (cell types)
display_numbers = TRUE, # Display cell counts in the heatmap
color = colorRampPalette(c("white", "red"))(50), # Color gradient
main = "Cluster vs Cell Type (l3) Heatmap")
# Save the heatmap as a PNG
png("cluster_celltype_l3_heatmap.png", width = 1600, height = 800)
# Create the heatmap
pheatmap(cluster_celltype_l3_matrix,
cluster_rows = TRUE, # Cluster rows (clusters)
cluster_cols = TRUE, # Cluster columns (cell types)
display_numbers = TRUE, # Display cell counts in the heatmap
color = colorRampPalette(c("white", "red"))(50),
main = "Cluster vs Cell Type (l3) Heatmap")
dev.off()
png
3
# Save the heatmap as a PDF
pdf("cluster_celltype_l3_heatmap.pdf", width = 20, height = 16)
pheatmap(cluster_celltype_l3_matrix,
cluster_rows = TRUE,
cluster_cols = TRUE,
display_numbers = TRUE,
color = colorRampPalette(c("white", "red"))(50),
main = "Cluster vs Cell Type (l3) Heatmap")
dev.off()
png
3