-
Notifications
You must be signed in to change notification settings - Fork 6
/
Supplementary code S1 Human scRNAseq.R
3144 lines (2324 loc) · 155 KB
/
Supplementary code S1 Human scRNAseq.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
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Analysis of the single cell RNA-seq data from eight lung transplant donors, eight lung transplant recipients with pulmonary fibrosis,
#and one cryobiopsy specimen from a patient with pulmonary fibrosis early in the disease course.
#Data generation: Nikita Joshi, Alexandra McQuattie-Pimentel, James Walter.
#Analysis: Paul Reyfman, Ziyou Ren, Kishore Anekalla, Scott Budinger, Alexander Misharin.
#Reference: Reyfman et al., AJRCCM, 2018.
#Analysis performed using Seurat 2.3.0.
#Code is based tutorials and vignettes from satijalab.org/seurat.
# Set R Environment ---------------------------------------------------------
# Load necessary packages
library(Seurat)
library(dplyr)
library(Matrix)
library('Cairo')
library(ggplot2)
library(tibble)
library(ggrepel)
library(cowplot)
#First we load and merge all of the donor samples
# donor01 analysis ---------------------------------------------------------
# Load the donor01 dataset
donor01.data <- Read10X(data.dir = "/donor01_tables/")
donor01 <- CreateSeuratObject(raw.data = donor01.data, min.cells = 3, min.genes = 200,
project = "donor01")
# Identify mitochondrial genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = donor01@data), value = TRUE)
# Create meta data column containing percentage of mitochondrial genes for each cell
percent.mito <- Matrix::colSums(donor01@raw.data[mito.genes, ])/Matrix::colSums(donor01@raw.data)
# Add percent.mito to object meta data
donor01 <- AddMetaData(object = donor01, metadata = percent.mito, col.name = "percent.mito")
#Data inspection and basic filtering
VlnPlot(object = donor01, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3)
GenePlot(object = donor01, gene1 = "nUMI", gene2 = "percent.mito")
GenePlot(object = donor01, gene1 = "nUMI", gene2 = "nGene")
donor01 <- FilterCells(object = donor01, subset.names = c("nGene", "percent.mito"),
low.thresholds = c(200, -Inf), high.thresholds = c(5000, 0.2))
#Normalize, find variable genes and scale
donor01 <- NormalizeData(object = donor01, normalization.method = "LogNormalize",
scale.factor = 10000)
donor01 <- FindVariableGenes(object = donor01, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor01@var.genes)
donor01 <- ScaleData(object = donor01, vars.to.regress = c("nUMI", "percent.mito"))
#Perform PCA
donor01 <- RunPCA(object = donor01, pc.genes = donor01@var.genes, do.print = TRUE, pcs.print = 1:5, genes.print = 5, pcs.compute = 40)
PrintPCA(object = donor01, pcs.print = 1:5, genes.print = 5, use.full = FALSE)
VizPCA(object = donor01, pcs.use = 1:2)
PCAPlot(object = donor01, dim.1 = 1, dim.2 = 2)
donor01 <- ProjectPCA(object = donor01, do.print = FALSE)
PCHeatmap(object = donor01, pc.use = 1:12, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor01, pc.use = 13:20, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor01, num.pc = 40)
#Perform clustering using first 13 principal components.
donor01 <- FindClusters(object = donor01, reduction.type = "pca", dims.use = 1:13,
resolution = 0.3, save.SNN = TRUE, print.output = FALSE, force.recalc = T)
PrintFindClustersParams(object = donor01)
donor01 <- RunTSNE(object = donor01, dims.use = 1:13, do.fast = TRUE)
TSNEPlot(object = donor01, do.label = T)
#Construct the cluster tree and merge nodes based on visual inspection
donor01 <- BuildClusterTree(object = donor01, do.reorder = TRUE, reorder.numeric = TRUE, do.plot = T)
donor01 <- MergeNode(donor01, node.use = 16, rebuild.tree = T)
TSNEPlot(object = donor01, do.label = T)
#Subset Cluster 4 (Monocytes and DCs)
donor01.cluster04 <- SubsetData(donor01, ident.use = c(4))
donor01.cluster04 <- ScaleData(object = donor01.cluster04, vars.to.regress = c("nUMI", "percent.mito"))
donor01.cluster04 <- FindVariableGenes(object = donor01.cluster04, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor01.cluster04@var.genes)
donor01.cluster04 <- RunPCA(object = donor01.cluster04, pc.genes = donor01.cluster04@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor01.cluster04 <- ProjectPCA(object = donor01.cluster04, do.print = FALSE)
PCHeatmap(object = donor01.cluster04, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor01.cluster04, num.pc = 12)
#Clustering of Subsetted Cells
donor01.cluster04 <- RunTSNE(object = donor01.cluster04, dims.use = 1:11, do.fast = TRUE)
donor01.cluster04 <- FindClusters(object = donor01.cluster04, reduction.type = "pca", dims.use = 1:11,
resolution = 0.5, save.SNN = TRUE)
TSNEPlot(donor01.cluster04)
#Markers of Subsetted Cell Subclusters
donor01.cluster04.markers <- FindAllMarkers(object = donor01.cluster04, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor01.cluster04.markers %>% group_by(cluster) %>% top_n(2, avg_logFC)
FeaturePlot(object = donor01.cluster04, features.plot = c("HLA-DQA1", "CD1C", "CD14", "S100A8"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor01.dcs <- WhichCells(object = donor01.cluster04, ident = c(0))
donor01.monos <- WhichCells(object = donor01.cluster04, ident = c(1))
#Rename clusters
donor01.ident <- c(1, 2, 3, 4, 5, 6, 7, 8)
donor01.new.ident <- c("Unassigned", "Mast Cells", "Endothelial Cells", "Monocytes and DCs",
"Macrophages", "Unassigned", "AT1 Cells", "AT2 Cells")
donor01@ident <- plyr::mapvalues(x = donor01@ident, from = donor01.ident, to = donor01.new.ident)
donor01 <- SetIdent(object = donor01, cells.use = donor01.dcs, ident.use = "Dendritic Cells")
donor01 <- SetIdent(object = donor01, cells.use = donor01.monos, ident.use = "Monocytes")
donor01@ident <- ordered(donor01@ident,levels = c("Macrophages", "AT2 Cells", "Monocytes", "Dendritic Cells",
"AT1 Cells", "Endothelial Cells", "Mast Cells", "Unassigned"))
#t-SNE Plot (Figure E5)
TSNEPlot(object = donor01, do.label = T)
#Find marker genes for clusters (Table E5)
donor01.markers <- FindAllMarkers(object = donor01, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
write.table(donor01.markers %>% group_by(cluster), file=paste(datadir, "/donor01.markers.txt",sep=""), row.names=FALSE, sep="\t")
#Add Cluster Identity Metadata to Separate Metadata Column
donor01 <- AddMetaData(object = donor01, metadata = donor01@ident, col.name = "indiv.cell.ident")
donor01@meta.data[, "diagnosis"] <- "donor"
donor01@meta.data[, "condition"] <- "donor"
donor01@meta.data$res.0.3 <- NULL
donor01@meta.data$tree.ident <- NULL
#Macrophage Heterogeneity Feature Plots (Figure E7E)
FeaturePlot(object = donor01, features.plot = c("MRC1", "FABP4", "SPP1", "CHI3L1"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), nCol = 1, pt.size = 0.5)
#Save object
save(donor01, file = "/donor01.Robj")
load(file = "/donor01.Robj")
# donor02 analysis ---------------------------------------------------------
# Load the donor02 dataset
donor02.data <- Read10X(data.dir = "/donor02_tables/")
donor02 <- CreateSeuratObject(raw.data = donor02.data, min.cells = 3, min.genes = 200,
project = "donor02")
# Identify mitochondrial genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = donor02@data), value = TRUE)
# Create meta data column containing percentage of mitochondrial genes for each cell
percent.mito <- Matrix::colSums(donor02@raw.data[mito.genes, ])/Matrix::colSums(donor02@raw.data)
# Add percent.mito to object meta data
donor02 <- AddMetaData(object = donor02, metadata = percent.mito, col.name = "percent.mito")
#Data inspection and basic filtering
VlnPlot(object = donor02, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3)
GenePlot(object = donor02, gene1 = "nUMI", gene2 = "percent.mito")
GenePlot(object = donor02, gene1 = "nUMI", gene2 = "nGene")
donor02 <- FilterCells(object = donor02, subset.names = c("nGene", "percent.mito"),
low.thresholds = c(200, -Inf), high.thresholds = c(6000, 0.15))
#Normalize, find variable genes and scale
donor02 <- NormalizeData(object = donor02, normalization.method = "LogNormalize",
scale.factor = 10000)
donor02 <- FindVariableGenes(object = donor02, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor02@var.genes)
donor02 <- ScaleData(object = donor02, vars.to.regress = c("nUMI", "percent.mito"))
#Perform PCA
donor02 <- RunPCA(object = donor02, pc.genes = donor02@var.genes, do.print = TRUE, pcs.print = 1:5, genes.print = 5, pcs.compute = 40)
PrintPCA(object = donor02, pcs.print = 1:5, genes.print = 5, use.full = FALSE)
VizPCA(object = donor02, pcs.use = 1:2)
PCAPlot(object = donor02, dim.1 = 1, dim.2 = 2)
donor02 <- ProjectPCA(object = donor02, do.print = FALSE)
PCHeatmap(object = donor02, pc.use = 1:9, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor02, pc.use = 10:18, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor02, pc.use = 19:27, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor02, num.pc = 40)
#Perform clustering using first 16 principal components.
donor02 <- FindClusters(object = donor02, reduction.type = "pca", dims.use = 1:16,
resolution = 0.3, print.output = 0, save.SNN = TRUE, force.recalc = T)
PrintFindClustersParams(object = donor02)
donor02 <- RunTSNE(object = donor02, dims.use = 1:16, do.fast = TRUE)
TSNEPlot(object = donor02, do.label = T)
#Construct the cluster tree and merge nodes based on visual inspection
donor02 <- BuildClusterTree(object = donor02, do.reorder = TRUE, reorder.numeric = TRUE, do.plot = T)
donor02 <- MergeNode(donor02, node.use = 19, rebuild.tree = T)
TSNEPlot(object = donor02, do.label = T)
#Subset Cluster 1 (Ciliated and Club Cells)
donor02.cluster01 <- SubsetData(donor02, ident.use = c(1))
donor02.cluster01 <- ScaleData(object = donor02.cluster01, vars.to.regress = c("nUMI", "percent.mito"))
donor02.cluster01 <- FindVariableGenes(object = donor02.cluster01, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor02.cluster01@var.genes)
donor02.cluster01 <- RunPCA(object = donor02.cluster01, pc.genes = donor02.cluster01@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor02.cluster01 <- ProjectPCA(object = donor02.cluster01, do.print = FALSE)
PCHeatmap(object = donor02.cluster01, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor02.cluster01, num.pc = 12)
#Clustering of Subsetted Cells
donor02.cluster01 <- RunTSNE(object = donor02.cluster01, dims.use = 1:4, do.fast = TRUE)
donor02.cluster01 <- FindClusters(object = donor02.cluster01, reduction.type = "pca", dims.use = 1:4,
resolution = 0.5, save.SNN = TRUE)
TSNEPlot(donor02.cluster01)
#Markers of Subsetted Cell Subclusters
donor02.cluster01.markers <- FindAllMarkers(object = donor02.cluster01, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor02.cluster01.markers %>% group_by(cluster) %>% top_n(2, avg_logFC)
FeaturePlot(object = donor02.cluster01, features.plot = c("TPPP3", "SCGB3A2"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor02.ciliated <- WhichCells(object = donor02.cluster01, ident = c(0))
donor02.clubs <- WhichCells(object = donor02.cluster01, ident = c(1))
#Rename clusters
donor02.ident <- c(1, 2, 3, 4, 5, 6, 7, 9, 10)
donor02.new.ident <- c("Ciliated and Club Cells", "T/NKT Cells", "Monocytes", "Macrophages",
"Dendritic Cells", "AT1 Cells", "AT2 Cells", "Endothelial Cells", "Fibroblasts")
donor02@ident <- plyr::mapvalues(x = donor02@ident, from = donor02.ident, to = donor02.new.ident)
donor02 <- SetIdent(object = donor02, cells.use = donor02.ciliated, ident.use = "Ciliated Cells")
donor02 <- SetIdent(object = donor02, cells.use = donor02.clubs, ident.use = "Club Cells")
donor02@ident <- ordered(donor02@ident,levels = c("Macrophages", "AT2 Cells", "Monocytes", "Club Cells",
"Dendritic Cells", "T/NKT Cells", "AT1 Cells", "Ciliated Cells",
"Endothelial Cells", "Fibroblasts"))
#t-SNE Plot (Figure E5)
TSNEPlot(object = donor02, do.label = T)
#Find marker genes for clusters (Table E5)
donor02.markers <- FindAllMarkers(object = donor02, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
write.table(donor02.markers %>% group_by(cluster), file= "/donor02.markers.txt", row.names=FALSE, sep="\t")
#Add Cluster Identity Metadata to Separate Metadata Column
donor02 <- AddMetaData(object = donor02, metadata = donor02@ident, col.name = "indiv.cell.ident")
donor02@meta.data[, "diagnosis"] <- "donor"
donor02@meta.data[, "condition"] <- "donor"
donor02@meta.data$res.0.3 <- NULL
donor02@meta.data$tree.ident <- NULL
#Save object
save(donor02, file = "/donor02.Robj")
load(file = "/donor02.Robj")
# donor03 analysis ---------------------------------------------------------
# Load the donor03 dataset
donor03.data <- Read10X(data.dir = "/donor03_tables/")
donor03 <- CreateSeuratObject(raw.data = donor03.data, min.cells = 3, min.genes = 200,
project = "donor03")
# Identify mitochondrial genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = donor03@data), value = TRUE)
# Create meta data column containing percentage of mitochondrial genes for each cell
percent.mito <- Matrix::colSums(donor03@raw.data[mito.genes, ])/Matrix::colSums(donor03@raw.data)
# Add percent.mito to object meta data
donor03 <- AddMetaData(object = donor03, metadata = percent.mito, col.name = "percent.mito")
#Data inspection and basic filtering
VlnPlot(object = donor03, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3)
GenePlot(object = donor03, gene1 = "nUMI", gene2 = "percent.mito")
GenePlot(object = donor03, gene1 = "nUMI", gene2 = "nGene")
donor03 <- FilterCells(object = donor03, subset.names = c("nGene", "percent.mito"),
low.thresholds = c(200, -Inf), high.thresholds = c(5000, 0.1))
#Normalize, find variable genes and scale
donor03 <- NormalizeData(object = donor03, normalization.method = "LogNormalize",
scale.factor = 10000)
donor03 <- FindVariableGenes(object = donor03, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor03@var.genes)
donor03 <- ScaleData(object = donor03, vars.to.regress = c("nUMI", "percent.mito"))
#Perform PCA
donor03 <- RunPCA(object = donor03, pc.genes = donor03@var.genes, do.print = TRUE, pcs.print = 1:5, genes.print = 5, pcs.compute = 40)
PrintPCA(object = donor03, pcs.print = 1:5, genes.print = 5, use.full = FALSE)
VizPCA(object = donor03, pcs.use = 1:2)
PCAPlot(object = donor03, dim.1 = 1, dim.2 = 2)
donor03 <- ProjectPCA(object = donor03, do.print = FALSE)
PCHeatmap(object = donor03, pc.use = 1:9, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor03, pc.use = 10:18, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor03, pc.use = 19:27, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor03, num.pc = 40)
#Perform clustering using first 9 principal components.
donor03 <- FindClusters(object = donor03, reduction.type = "pca", dims.use = 1:9,
resolution = 0.3, print.output = 0, save.SNN = TRUE, force.recalc = T)
PrintFindClustersParams(object = donor03)
donor03 <- RunTSNE(object = donor03, dims.use = 1:9, do.fast = TRUE)
TSNEPlot(object = donor03, do.label = T)
#Construct the cluster tree and merge nodes based on visual inspection
donor03 <- BuildClusterTree(object = donor03, do.reorder = TRUE, reorder.numeric = TRUE, do.plot = T)
donor03 <- MergeNode(donor03, node.use = 19, rebuild.tree = T)
TSNEPlot(object = donor03, do.label = T)
#Subset Cluster 2 (Ciliated and Club Cells)
donor03.cluster02 <- SubsetData(donor03, ident.use = c(2))
donor03.cluster02 <- ScaleData(object = donor03.cluster02, vars.to.regress = c("nUMI", "percent.mito"))
donor03.cluster02 <- FindVariableGenes(object = donor03.cluster02, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor03.cluster02@var.genes)
donor03.cluster02 <- RunPCA(object = donor03.cluster02, pc.genes = donor03.cluster02@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor03.cluster02 <- ProjectPCA(object = donor03.cluster02, do.print = FALSE)
PCHeatmap(object = donor03.cluster02, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor03.cluster02, num.pc = 12)
#Clustering of Subsetted Cells
donor03.cluster02 <- RunTSNE(object = donor03.cluster02, dims.use = 1:2, do.fast = TRUE)
donor03.cluster02 <- FindClusters(object = donor03.cluster02, reduction.type = "pca", dims.use = 1:2,
resolution = 0.2, save.SNN = TRUE)
TSNEPlot(donor03.cluster02)
#Markers of Subsetted Cell Subclusters
donor03.cluster02.markers <- FindAllMarkers(object = donor03.cluster02, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor03.cluster02.markers %>% group_by(cluster) %>% top_n(2, avg_logFC)
FeaturePlot(object = donor03.cluster02, features.plot = c("TPPP3", "SCGB3A2"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor03.ciliated <- WhichCells(object = donor03.cluster02, ident = c(0))
donor03.clubs <- WhichCells(object = donor03.cluster02, ident = c(1))
#Rename clusters
donor03.ident <- c(0, 1, 2, 3, 4, 5, 6, 7, 8)
donor03.new.ident <- c("Macrophages", "AT2 Cells", "Ciliated and Club Cells", "Monocytes", "Plasma Cells",
"AT1 Cells", "Endothelial Cells", "Unassigned", "Fibroblasts")
donor03@ident <- plyr::mapvalues(x = donor03@ident, from = donor03.ident, to = donor03.new.ident)
donor03 <- SetIdent(object = donor03, cells.use = donor03.clubs, ident.use = "Club Cells")
donor03 <- SetIdent(object = donor03, cells.use = donor03.ciliated, ident.use = "Ciliated Cells")
donor03@ident <- ordered(donor03@ident,levels = c("Macrophages", "AT2 Cells", "Monocytes", "Club Cells",
"Plasma Cells", "AT1 Cells", "Ciliated Cells", "Endothelial Cells",
"Fibroblasts", "Unassigned"))
#t-SNE Plot (Figure E5)
TSNEPlot(object = donor03, do.label = T)
#Find marker genes for clusters (Table E5)
donor03.markers <- FindAllMarkers(object = donor03, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
write.table(donor03.markers %>% group_by(cluster), file= "/donor03.markers.txt", row.names=FALSE, sep="\t")
#Add Cluster Identity Metadata to Separate Metadata Column
donor03 <- AddMetaData(object = donor03, metadata = donor03@ident, col.name = "indiv.cell.ident")
donor03@meta.data[, "diagnosis"] <- "donor"
donor03@meta.data[, "condition"] <- "donor"
donor03@meta.data$res.0.3 <- NULL
donor03@meta.data$tree.ident <- NULL
#Save object
save(donor03, file = "/donor03.Robj")
load(file = "/donor03.Robj")
# donor04 analysis ---------------------------------------------------------
# Load the donor04 dataset
donor04.data <- Read10X(data.dir = "/donor04_tables/")
donor04 <- CreateSeuratObject(raw.data = donor04.data, min.cells = 3, min.genes = 200,
project = "donor04")
# Identify mitochondrial genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = donor04@data), value = TRUE)
# Create meta data column containing percentage of mitochondrial genes for each cell
percent.mito <- Matrix::colSums(donor04@raw.data[mito.genes, ])/Matrix::colSums(donor04@raw.data)
# Add percent.mito to object meta data
donor04 <- AddMetaData(object = donor04, metadata = percent.mito, col.name = "percent.mito")
#Data inspection and basic filtering
VlnPlot(object = donor04, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3)
GenePlot(object = donor04, gene1 = "nUMI", gene2 = "percent.mito")
GenePlot(object = donor04, gene1 = "nUMI", gene2 = "nGene")
donor04 <- FilterCells(object = donor04, subset.names = c("nGene", "percent.mito"),
low.thresholds = c(200, -Inf), high.thresholds = c(5000, 0.15))
#Normalize, find variable genes and scale
donor04 <- NormalizeData(object = donor04, normalization.method = "LogNormalize",
scale.factor = 10000)
donor04 <- FindVariableGenes(object = donor04, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor04@var.genes)
donor04 <- ScaleData(object = donor04, vars.to.regress = c("nUMI", "percent.mito"))
#Perform PCA
donor04 <- RunPCA(object = donor04, pc.genes = donor04@var.genes, do.print = TRUE, pcs.print = 1:5, genes.print = 5, pcs.compute = 40)
PrintPCA(object = donor04, pcs.print = 1:5, genes.print = 5, use.full = FALSE)
VizPCA(object = donor04, pcs.use = 1:2)
PCAPlot(object = donor04, dim.1 = 1, dim.2 = 2)
donor04 <- ProjectPCA(object = donor04, do.print = FALSE)
PCHeatmap(object = donor04, pc.use = 1:9, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor04, pc.use = 10:18, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor04, pc.use = 19:27, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor04, num.pc = 40)
#Perform clustering using first 9 principal components.
donor04 <- FindClusters(object = donor04, reduction.type = "pca", dims.use = 1:9,
resolution = 0.3, print.output = 0, save.SNN = TRUE, force.recalc = T)
PrintFindClustersParams(object = donor04)
donor04 <- RunTSNE(object = donor04, dims.use = 1:9, do.fast = TRUE)
TSNEPlot(object = donor04, do.label = T)
#Subset Cluster 4 (Mixed Epithelial Cells)
donor04.cluster04 <- SubsetData(donor04, ident.use = c(4))
donor04.cluster04 <- ScaleData(object = donor04.cluster04, vars.to.regress = c("nUMI", "percent.mito"))
donor04.cluster04 <- FindVariableGenes(object = donor04.cluster04, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor04.cluster04@var.genes)
donor04.cluster04 <- RunPCA(object = donor04.cluster04, pc.genes = donor04.cluster04@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor04.cluster04 <- ProjectPCA(object = donor04.cluster04, do.print = FALSE)
PCHeatmap(object = donor04.cluster04, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor04.cluster04, num.pc = 12)
#Clustering of Subsetted Cells
donor04.cluster04 <- RunTSNE(object = donor04.cluster04, dims.use = 1:4, do.fast = TRUE)
donor04.cluster04 <- FindClusters(object = donor04.cluster04, reduction.type = "pca", dims.use = 1:4,
resolution = .5, save.SNN = TRUE)
TSNEPlot(donor04.cluster04)
#Markers of Subsetted Cell Subclusters
donor04.cluster04.markers <- FindAllMarkers(object = donor04.cluster04, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor04.cluster04.markers %>% group_by(cluster) %>% top_n(2, avg_logFC)
FeaturePlot(object = donor04.cluster04, features.plot = c("SFTPC", "AGER", "SCGB3A2"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor04.at2 <- WhichCells(object = donor04.cluster04, ident = c(0))
donor04.at1 <- WhichCells(object = donor04.cluster04, ident = c(1))
donor04.clubs <- WhichCells(object = donor04.cluster04, ident = c(2))
#Rename clusters
donor04.ident <- c(0, 1, 2, 3, 4, 5, 6, 7)
donor04.new.ident <- c("AT2 Cells", "Macrophages", "AT2 Cells", "Macrophages",
"AT1, AT2, and Club Cells", "Ciliated Cells", "Unassigned", "Plasma Cells")
donor04@ident <- plyr::mapvalues(x = donor04@ident, from = donor04.ident, to = donor04.new.ident)
donor04 <- SetIdent(object = donor04, cells.use = donor04.at2, ident.use = "AT2 Cells")
donor04 <- SetIdent(object = donor04, cells.use = donor04.at1, ident.use = "AT1 Cells")
donor04 <- SetIdent(object = donor04, cells.use = donor04.clubs, ident.use = "Club Cells")
donor04@ident <- ordered(donor04@ident,levels = c("Macrophages", "AT2 Cells", "Club Cells", "Plasma Cells",
"AT1 Cells", "Ciliated Cells", "Unassigned"))
donor04.ident <- c("Macrophages", "AT2 Cells", "Club Cells", "Plasma Cells",
"AT1 Cells", "Ciliated Cells", "Unassigned")
donor04.new.ident <- c("Macrophages", "AT2 Cells", "Club Cells", "Plasma Cells",
"AT1 Cells", "Ciliated Cells", "Unassigned")
donor04@ident <- plyr::mapvalues(x = donor04@ident, from = donor04.ident, to = donor04.new.ident)
#t-SNE Plot (Figure E5)
TSNEPlot(object = donor04, do.label = T)
#Find marker genes for clusters (Table E5)
donor04.markers <- FindAllMarkers(object = donor04, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
write.table(donor04.markers %>% group_by(cluster), file= "/donor04.markers.txt", row.names=FALSE, sep="\t")
#Add Cluster Identity Metadata to Separate Metadata Column
donor04 <- AddMetaData(object = donor04, metadata = donor04@ident, col.name = "indiv.cell.ident")
donor04@meta.data[, "diagnosis"] <- "donor"
donor04@meta.data[, "condition"] <- "donor"
donor04@meta.data$res.0.3 <- NULL
donor04@meta.data$tree.ident <- NULL
#Save object
save(donor04, file = "/donor04.Robj")
load(file = "/donor04.Robj")
# donor05 analysis ---------------------------------------------------------
# Load the donor05 dataset
donor05.data <- Read10X(data.dir = "/donor05_tables/")
donor05 <- CreateSeuratObject(raw.data = donor05.data, min.cells = 3, min.genes = 200,
project = "donor05")
# Identify mitochondrial genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = donor05@data), value = TRUE)
# Create meta data column containing percentage of mitochondrial genes for each cell
percent.mito <- Matrix::colSums(donor05@raw.data[mito.genes, ])/Matrix::colSums(donor05@raw.data)
# Add percent.mito to object meta data
donor05 <- AddMetaData(object = donor05, metadata = percent.mito, col.name = "percent.mito")
#Data inspection and basic filtering
VlnPlot(object = donor05, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3)
GenePlot(object = donor05, gene1 = "nUMI", gene2 = "percent.mito")
GenePlot(object = donor05, gene1 = "nUMI", gene2 = "nGene")
donor05 <- FilterCells(object = donor05, subset.names = c("nGene", "percent.mito"),
low.thresholds = c(200, -Inf), high.thresholds = c(6000, 0.1))
#Normalize, find variable genes and scale
donor05 <- NormalizeData(object = donor05, normalization.method = "LogNormalize",
scale.factor = 10000)
donor05 <- FindVariableGenes(object = donor05, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor05@var.genes)
donor05 <- ScaleData(object = donor05, vars.to.regress = c("nUMI", "percent.mito"))
#Perform PCA
donor05 <- RunPCA(object = donor05, pc.genes = donor05@var.genes, do.print = TRUE, pcs.print = 1:5, genes.print = 5, pcs.compute = 40)
PrintPCA(object = donor05, pcs.print = 1:5, genes.print = 5, use.full = FALSE)
VizPCA(object = donor05, pcs.use = 1:2)
PCAPlot(object = donor05, dim.1 = 1, dim.2 = 2)
donor05 <- ProjectPCA(object = donor05, do.print = FALSE)
PCHeatmap(object = donor05, pc.use = 1:9, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor05, pc.use = 10:18, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor05, pc.use = 19:27, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor05, num.pc = 40)
#Perform clustering using first 27 principal components.
donor05 <- FindClusters(object = donor05, reduction.type = "pca", dims.use = 1:27,
resolution = 0.5, print.output = 0, save.SNN = TRUE, force.recalc = T)
PrintFindClustersParams(object = donor05)
donor05 <- RunTSNE(object = donor05, dims.use = 1:27, do.fast = TRUE)
TSNEPlot(object = donor05, do.label = T)
#Subset Cluster 3 (Epithelial Cells)
donor05.cluster03 <- SubsetData(donor05, ident.use = c(3))
donor05.cluster03 <- ScaleData(object = donor05.cluster03, vars.to.regress = c("nUMI", "percent.mito"))
donor05.cluster03 <- FindVariableGenes(object = donor05.cluster03, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor05.cluster03@var.genes)
donor05.cluster03 <- RunPCA(object = donor05.cluster03, pc.genes = donor05.cluster03@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor05.cluster03 <- ProjectPCA(object = donor05.cluster03, do.print = FALSE)
PCHeatmap(object = donor05.cluster03, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor05.cluster03, num.pc = 12)
#Clustering of Subsetted Cells
donor05.cluster03 <- RunTSNE(object = donor05.cluster03, dims.use = 1:7, do.fast = TRUE)
donor05.cluster03 <- FindClusters(object = donor05.cluster03, reduction.type = "pca", dims.use = 1:7,
resolution = .3, save.SNN = TRUE)
TSNEPlot(donor05.cluster03)
#Markers of Subsetted Cell Subclusters
donor05.cluster03.markers <- FindAllMarkers(object = donor05.cluster03, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor05.cluster03.markers %>% group_by(cluster) %>% top_n(2, avg_logFC)
FeaturePlot(object = donor05.cluster03, features.plot = c("SFTPC", "AGER", "SCGB3A2", "CD68"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor05.at2 <- WhichCells(object = donor05.cluster03, ident = c(0))
donor05.at1 <- WhichCells(object = donor05.cluster03, ident = c(1))
donor05.clubs <- WhichCells(object = donor05.cluster03, ident = c(2))
donor05.cluster03.unassigned <- WhichCells(object = donor05.cluster03, ident = c(3))
#Subset Cluster 5 (Monocytes and DCs)
donor05.cluster05 <- SubsetData(donor05, ident.use = c(5))
donor05.cluster05 <- ScaleData(object = donor05.cluster05, vars.to.regress = c("nUMI", "percent.mito"))
donor05.cluster05 <- FindVariableGenes(object = donor05.cluster05, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor05.cluster05@var.genes)
donor05.cluster05 <- RunPCA(object = donor05.cluster05, pc.genes = donor05.cluster05@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor05.cluster05 <- ProjectPCA(object = donor05.cluster05, do.print = FALSE)
PCHeatmap(object = donor05.cluster05, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor05.cluster05, num.pc = 12)
#Clustering of Subsetted Cells
donor05.cluster05 <- RunTSNE(object = donor05.cluster05, dims.use = 1:5, do.fast = TRUE)
donor05.cluster05 <- FindClusters(object = donor05.cluster05, reduction.type = "pca", dims.use = 1:5,
resolution = .3, save.SNN = TRUE)
TSNEPlot(donor05.cluster05)
#Markers of Subsetted Cell Subclusters
donor05.cluster05.markers <- FindAllMarkers(object = donor05.cluster05, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor05.cluster05.markers %>% group_by(cluster) %>% top_n(2, avg_logFC)
FeaturePlot(object = donor05.cluster05, features.plot = c("HLA-DPB1", "CD14", "CD1D"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor05.dcs <- WhichCells(object = donor05.cluster05, ident = c(0))
donor05.monos <- WhichCells(object = donor05.cluster05, ident = c(1))
donor05.cluster05.unassigned <- WhichCells(object = donor05.cluster05, ident = c(2))
#Rename clusters
donor05.ident <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
donor05.new.ident <- c("Macrophages", "AT2 Cells", "AT2 Cells", "Epithelial Cells",
"AT2 Cells", "Monocytes and DCs", "Unassigned", "Endothelial Cells",
"Fibroblasts", "Plasma Cells", "Ciliated Cells", "Mast Cells")
donor05@ident <- plyr::mapvalues(x = donor05@ident, from = donor05.ident, to = donor05.new.ident)
donor05 <- SetIdent(object = donor05, cells.use = donor05.at2, ident.use = "AT2 Cells")
donor05 <- SetIdent(object = donor05, cells.use = donor05.at1, ident.use = "AT1 Cells")
donor05 <- SetIdent(object = donor05, cells.use = donor05.clubs, ident.use = "Club Cells")
donor05 <- SetIdent(object = donor05, cells.use = donor05.dcs, ident.use = "Dendritic Cells")
donor05 <- SetIdent(object = donor05, cells.use = donor05.monos, ident.use = "Monocytes")
donor05 <- SetIdent(object = donor05, cells.use = donor05.cluster03.unassigned, ident.use = "Unassigned")
donor05 <- SetIdent(object = donor05, cells.use = donor05.cluster05.unassigned, ident.use = "Unassigned")
donor05@ident <- ordered(donor05@ident,levels = c("Macrophages", "AT2 Cells", "Monocytes", "Club Cells",
"Dendritic Cells", "Plasma Cells", "AT1 Cells", "Ciliated Cells",
"Endothelial Cells", "Fibroblasts", "Mast Cells", "Unassigned"))
#t-SNE Plot (Figure E5)
TSNEPlot(object = donor05, do.label = T)
#Find marker genes for clusters (Table E5)
donor05.markers <- FindAllMarkers(object = donor05, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
write.table(donor05.markers %>% group_by(cluster), file= "/donor05.markers.txt", row.names=FALSE, sep="\t")
#Add Cluster Identity Metadata to Separate Metadata Column
donor05 <- AddMetaData(object = donor05, metadata = donor05@ident, col.name = "indiv.cell.ident")
donor05@meta.data[, "diagnosis"] <- "donor"
donor05@meta.data[, "condition"] <- "donor"
donor05@meta.data$res.0.3 <- NULL
donor05@meta.data$tree.ident <- NULL
#Save object
save(donor05, file = "/donor05.Robj")
load(file = "/donor05.Robj")
# donor06 analysis ---------------------------------------------------------
# Load the donor06 dataset
donor06.data <- Read10X(data.dir = "/donor06_tables/")
donor06 <- CreateSeuratObject(raw.data = donor06.data, min.cells = 3, min.genes = 200,
project = "donor06")
# Identify mitochondrial genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = donor06@data), value = TRUE)
# Create meta data column containing percentage of mitochondrial genes for each cell
percent.mito <- Matrix::colSums(donor06@raw.data[mito.genes, ])/Matrix::colSums(donor06@raw.data)
# Add percent.mito to object meta data
donor06 <- AddMetaData(object = donor06, metadata = percent.mito, col.name = "percent.mito")
#Data inspection and basic filtering
VlnPlot(object = donor06, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3)
GenePlot(object = donor06, gene1 = "nUMI", gene2 = "percent.mito")
GenePlot(object = donor06, gene1 = "nUMI", gene2 = "nGene")
donor06 <- FilterCells(object = donor06, subset.names = c("nGene", "percent.mito"),
low.thresholds = c(200, -Inf), high.thresholds = c(6000, 0.1))
#Normalize, find variable genes and scale
donor06 <- NormalizeData(object = donor06, normalization.method = "LogNormalize",
scale.factor = 10000)
donor06 <- FindVariableGenes(object = donor06, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor06@var.genes)
donor06 <- ScaleData(object = donor06, vars.to.regress = c("nUMI", "percent.mito"))
#Perform PCA
donor06 <- RunPCA(object = donor06, pc.genes = donor06@var.genes, do.print = TRUE, pcs.print = 1:5, genes.print = 5, pcs.compute = 40)
PrintPCA(object = donor06, pcs.print = 1:5, genes.print = 5, use.full = FALSE)
VizPCA(object = donor06, pcs.use = 1:2)
PCAPlot(object = donor06, dim.1 = 1, dim.2 = 2)
donor06 <- ProjectPCA(object = donor06, do.print = FALSE)
PCHeatmap(object = donor06, pc.use = 1:9, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor06, pc.use = 10:18, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor06, pc.use = 19:27, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor06, num.pc = 40)
#Perform clustering using first 20 principal components.
donor06 <- FindClusters(object = donor06, reduction.type = "pca", dims.use = 1:20,
resolution = 0.5, print.output = 0, save.SNN = TRUE, force.recalc = T)
PrintFindClustersParams(object = donor06)
donor06 <- RunTSNE(object = donor06, dims.use = 1:20, do.fast = TRUE)
TSNEPlot(object = donor06, do.label = T)
#Subset Cluster 2 (Monocytes and Macrophages)
donor06.cluster02 <- SubsetData(donor06, ident.use = c(2))
donor06.cluster02 <- ScaleData(object = donor06.cluster02, vars.to.regress = c("nUMI", "percent.mito"))
donor06.cluster02 <- FindVariableGenes(object = donor06.cluster02, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor06.cluster02@var.genes)
donor06.cluster02 <- RunPCA(object = donor06.cluster02, pc.genes = donor06.cluster02@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor06.cluster02 <- ProjectPCA(object = donor06.cluster02, do.print = FALSE)
PCHeatmap(object = donor06.cluster02, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor06.cluster02, num.pc = 12)
#Clustering of Subsetted Cells
donor06.cluster02 <- RunTSNE(object = donor06.cluster02, dims.use = 1:6, do.fast = TRUE)
donor06.cluster02 <- FindClusters(object = donor06.cluster02, reduction.type = "pca", dims.use = 1:6,
resolution = .2, save.SNN = TRUE)
TSNEPlot(donor06.cluster02)
#Markers of Subsetted Cell Subclusters
donor06.cluster02.markers <- FindAllMarkers(object = donor06.cluster02, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor06.cluster02.markers %>% group_by(cluster) %>% top_n(2, avg_logFC)
FeaturePlot(object = donor06.cluster02, features.plot = c("FCN1", "MRC1"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor06.monos <- WhichCells(object = donor06.cluster02, ident = c(0))
donor06.macrophages <- WhichCells(object = donor06.cluster02, ident = c(1))
#Subset Cluster 12 (Club and Ciliated Cells)
donor06.cluster12 <- SubsetData(donor06, ident.use = c(12))
donor06.cluster12 <- ScaleData(object = donor06.cluster12, vars.to.regress = c("nUMI", "percent.mito"))
donor06.cluster12 <- FindVariableGenes(object = donor06.cluster12, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor06.cluster12@var.genes)
donor06.cluster12 <- RunPCA(object = donor06.cluster12, pc.genes = donor06.cluster12@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor06.cluster12 <- ProjectPCA(object = donor06.cluster12, do.print = FALSE)
PCHeatmap(object = donor06.cluster12, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor06.cluster12, num.pc = 12)
#Clustering of Subsetted Cells
donor06.cluster12 <- RunTSNE(object = donor06.cluster12, dims.use = 1:8, do.fast = TRUE)
donor06.cluster12 <- FindClusters(object = donor06.cluster12, reduction.type = "pca", dims.use = 1:8,
resolution = 1, save.SNN = TRUE)
TSNEPlot(donor06.cluster12)
#Markers of Subsetted Cell Subclusters
donor06.cluster12.markers <- FindAllMarkers(object = donor06.cluster12, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor06.cluster12.markers %>% group_by(cluster) %>% top_n(2, avg_logFC)
FeaturePlot(object = donor06.cluster12, features.plot = c("SCGB3A2", "TPPP3"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor06.clubs <- WhichCells(object = donor06.cluster12, ident = c(0))
donor06.ciliated <- WhichCells(object = donor06.cluster12, ident = c(1))
#Rename clusters
donor06.ident <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
donor06.new.ident <- c("Macrophages", "AT2 Cells", "Monocytes and Macrophages", "AT2 Cells",
"AT1 Cells", "AT2 Cells", "T/NKT Cells", "Macrophages",
"Dendritic Cells", "Endothelial Cells", "Unassigned", "Plasma Cells",
"Club and Ciliated Cells", "Fibroblasts")
donor06@ident <- plyr::mapvalues(x = donor06@ident, from = donor06.ident, to = donor06.new.ident)
donor06 <- SetIdent(object = donor06, cells.use = donor06.monos, ident.use = "Monocytes")
donor06 <- SetIdent(object = donor06, cells.use = donor06.macrophages, ident.use = "Macrophages")
donor06 <- SetIdent(object = donor06, cells.use = donor06.clubs, ident.use = "Club Cells")
donor06 <- SetIdent(object = donor06, cells.use = donor06.ciliated, ident.use = "Ciliated Cells")
donor06@ident <- ordered(donor06@ident,levels = c("Macrophages", "AT2 Cells", "Monocytes", "Club Cells",
"Dendritic Cells", "Plasma Cells", "T/NKT Cells", "AT1 Cells",
"Ciliated Cells", "Endothelial Cells", "Fibroblasts", "Unassigned"))
#t-SNE Plot (Figure E5)
TSNEPlot(object = donor06, do.label = T)
#Find marker genes for clusters (Table E5)
donor06.markers <- FindAllMarkers(object = donor06, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
write.table(donor06.markers %>% group_by(cluster), file= "/donor06.markers.txt", row.names=FALSE, sep="\t")
#Monocyte Heterogeneity Feature Plots (Figure E6C)
FeaturePlot(object = donor06, features.plot = c("CD14", "FCGR3A", "MRC1"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), nCol = 1, pt.size = 0.5)
#Macrophage Heterogeneity Feature Plots (Figure E7F)
FeaturePlot(object = donor06, features.plot = c("MRC1", "FABP4", "CCL3", "CD14"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), nCol = 1, pt.size = 0.5)
#Add Cluster Identity Metadata to Separate Metadata Column
donor06 <- AddMetaData(object = donor06, metadata = donor06@ident, col.name = "indiv.cell.ident")
donor06@meta.data[, "diagnosis"] <- "donor"
donor06@meta.data[, "condition"] <- "donor"
donor06@meta.data$res.0.3 <- NULL
donor06@meta.data$tree.ident <- NULL
#Save object
save(donor06, file = "/donor06.Robj")
load(file = "/donor06.Robj")
# donor07 analysis ---------------------------------------------------------
# Load the donor07 dataset
donor07.data <- Read10X(data.dir = "/donor07_tables/")
donor07 <- CreateSeuratObject(raw.data = donor07.data, min.cells = 3, min.genes = 200,
project = "donor07")
# Identify mitochondrial genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = donor07@data), value = TRUE)
# Create meta data column containing percentage of mitochondrial genes for each cell
percent.mito <- Matrix::colSums(donor07@raw.data[mito.genes, ])/Matrix::colSums(donor07@raw.data)
# Add percent.mito to object meta data
donor07 <- AddMetaData(object = donor07, metadata = percent.mito, col.name = "percent.mito")
#Data inspection and basic filtering
VlnPlot(object = donor07, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3)
GenePlot(object = donor07, gene1 = "nUMI", gene2 = "percent.mito")
GenePlot(object = donor07, gene1 = "nUMI", gene2 = "nGene")
donor07 <- FilterCells(object = donor07, subset.names = c("nGene", "percent.mito"),
low.thresholds = c(200, -Inf), high.thresholds = c(5000, 0.1))
#Normalize, find variable genes and scale
donor07 <- NormalizeData(object = donor07, normalization.method = "LogNormalize",
scale.factor = 10000)
donor07 <- FindVariableGenes(object = donor07, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor07@var.genes)
donor07 <- ScaleData(object = donor07, vars.to.regress = c("nUMI", "percent.mito"))
#Perform PCA
donor07 <- RunPCA(object = donor07, pc.genes = donor07@var.genes, do.print = TRUE, pcs.print = 1:5, genes.print = 5, pcs.compute = 40)
PrintPCA(object = donor07, pcs.print = 1:5, genes.print = 5, use.full = FALSE)
VizPCA(object = donor07, pcs.use = 1:2)
PCAPlot(object = donor07, dim.1 = 1, dim.2 = 2)
donor07 <- ProjectPCA(object = donor07, do.print = FALSE)
PCHeatmap(object = donor07, pc.use = 1:9, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor07, pc.use = 10:18, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCHeatmap(object = donor07, pc.use = 19:27, cells.use = 500, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor07, num.pc = 40)
#Perform clustering using first 22 principal components.
donor07 <- FindClusters(object = donor07, reduction.type = "pca", dims.use = 1:22,
resolution = 0.3, print.output = 0, save.SNN = TRUE, force.recalc = T)
PrintFindClustersParams(object = donor07)
donor07 <- RunTSNE(object = donor07, dims.use = 1:20, do.fast = TRUE)
TSNEPlot(object = donor07, do.label = T)
#Subset Cluster 06 (Club and Airway Cells)
donor07.cluster06 <- SubsetData(donor07, ident.use = c(6))
donor07.cluster06 <- ScaleData(object = donor07.cluster06, vars.to.regress = c("nUMI", "percent.mito"))
donor07.cluster06 <- FindVariableGenes(object = donor07.cluster06, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 3, y.cutoff = 0.5)
length(x = donor07.cluster06@var.genes)
donor07.cluster06 <- RunPCA(object = donor07.cluster06, pc.genes = donor07.cluster06@var.genes, do.print = TRUE, pcs.print = 1:5,
genes.print = 5)
donor07.cluster06 <- ProjectPCA(object = donor07.cluster06, do.print = FALSE)
PCHeatmap(object = donor07.cluster06, pc.use = 1:12, do.balanced = TRUE,
label.columns = FALSE, use.full = FALSE)
PCElbowPlot(object = donor07.cluster06, num.pc = 12)
#Clustering of Subsetted Cells
donor07.cluster06 <- RunTSNE(object = donor07.cluster06, dims.use = 1:5, do.fast = TRUE)
donor07.cluster06 <- FindClusters(object = donor07.cluster06, reduction.type = "pca", dims.use = 1:5,
resolution = 0.5, save.SNN = TRUE)
TSNEPlot(donor07.cluster06)
#Markers of Subsetted Cell Subclusters
donor07.cluster06.markers <- FindAllMarkers(object = donor07.cluster06, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
donor07.cluster06.markers %>% group_by(cluster) %>% top_n(3, avg_logFC)
FeaturePlot(object = donor07.cluster06, features.plot = c("SCGB3A2", "TPPP3"), min.cutoff = "q9",
cols.use = c("lightgrey", "blue"), pt.size = 1)
#Cell assignment for Subclusters
donor07.ciliated <- WhichCells(object = donor07.cluster06, ident = c(0))
donor07.clubs <- WhichCells(object = donor07.cluster06, ident = c(1))
#Rename clusters