-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx_Visualizations.Rmd
1632 lines (1268 loc) · 69.3 KB
/
x_Visualizations.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
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
---
title: "R Notebook"
output:
html_notebook:
toc: yes
code_folding: hide
fig_width: 8
fig_height: 6
editor_options:
chunk_output_type: inline
---
```{r Loading libraries and data, message=FALSE, warning=FALSE}
suppressPackageStartupMessages({
library(ArchR)
library(knitr)
library(TFBSTools)
library(ComplexHeatmap)
library(ggplot2)
library(ggrepel)
library(qdapTools)
library(parallel)
})
addArchRThreads(threads = 62)
set.seed(1)
projNC <- loadArchRProject(path = "/data/Austin/10XscATAC/ArchR_data_final_thesis/")
projNC@projectMetadata$outputDirectory <- "./Figure_Exports"
projNC <- addImputeWeights(projNC, sampleCells = 10000, nRep = 3, k = 20)
cluster_to_identity <- data.frame(cluster = paste0("C",1:10),
identity = c("C1_Melanocytes","C2_Sensory_Glia","C3_Int_Mesenchyme",
"C4_Multipotent_NC","C5_Hindbrain_Neurons","C6_Somatosensory_Neurons",
"C7_Midbrain_Neurons","C8_Early_Mesenchyme","C9_Sensory_Neurons",
"C10_Late_Mesenchyme"))
projNC$Cell_Identity <- lookup(projNC$Clusters, cluster_to_identity)
```
# Figure 1 - Dimensionality Reduction & Clustering
## A
A picture of a HH16/18 chicken embryo electroporated with the TFAP2aE1 enhancer alongside a schematic of single-cell ATAC-Seq.
## B
A two-dimensional UMAP projection colored by original sample identity (timepoint).
```{r}
p1 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
name = "Sample", plotAs = "points",
pal = ArchRPalettes$bear, size = 0.2, rastr = F)
plotPDF(p1, name = "Plot-UMAP-Sample.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p1
```
## C
A two-dimensional UMAP projection followed by clustering in ArchR.
```{r}
p2 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
name = "Clusters", plotAs = "points", size = 0.2, rastr = F)
plotPDF(p2, name = "Plot-UMAP-Clusters.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p2
p3 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
name = "Cell_Identity", plotAs = "points", size = 0.2, rastr = F)
plotPDF(p3, name = "Plot-UMAP-Cell_Identity.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p3
```
## D
A customized plot of enriched chromVAR motifs in the UMAP projection.
```{r}
motifs <- c("Pou5f1..Sox2","RUNX1","ASCL1","MEIS2","MITF","TWIST1","GRHL2","OTX2")
grey_red <- ArchRPalettes$whiteRed
grey_red[1] <- "grey"
plotting_motifs <- getFeatures(projNC, select = paste(motifs, collapse="|"), useMatrix = "MotifMatrix")
plotting_motifs_z <- paste0("z:",plotting_motifs)
# Problem with threads > 1...
motif_plot_nocutoff <- plotEmbedding(projNC,
embedding = "UMAP",
colorBy = "MotifMatrix",
name = plotting_motifs_z,
plotAs = "points",
sampleCells = NULL,
rastr = F,
keepAxis = F,
threads = 1)
for (plot in seq(length(motif_plot_nocutoff))){
plotPDF(motif_plot_nocutoff[[plot]], name = paste0("Plot-Motif-Zscores-",plot),
addDOC = FALSE, ArchRProj = projNC, width = 5, height = 5)
}
combined <- cowplot::plot_grid(motif_plot_nocutoff[[1]],motif_plot_nocutoff[[2]],
motif_plot_nocutoff[[4]],motif_plot_nocutoff[[3]],
motif_plot_nocutoff[[8]],motif_plot_nocutoff[[7]],
motif_plot_nocutoff[[10]],motif_plot_nocutoff[[9]], nrow = 2)
plotPDF(combined, name = "Plot-Motif-Zscores.pdf", ArchRProj = projNC, addDOC = FALSE, width = 16, height = 16)
combined
```
## E
A UMAP projection of the 'end' of each lineage
```{r}
end1 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
highlightCells = projNC$cellNames[projNC$Cell_Identity == "C2_Sensory_Glia"],
name = "Cell_Identity", plotAs = "points", size = 0.2, rastr = F)
plotPDF(end1, name = "Plot-UMAP-SensoryGlia.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
end1
end2 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
highlightCells = projNC$cellNames[projNC$Cell_Identity == "C9_Sensory_Neurons"],
name = "Cell_Identity", plotAs = "points", size = 0.2, rastr = F)
plotPDF(end2, name = "Plot-UMAP-SensoryNeurons.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
end2
end3 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
highlightCells = projNC$cellNames[projNC$Cell_Identity == "C7_Midbrain_Neurons"],
name = "Cell_Identity", plotAs = "points", size = 0.2, rastr = F)
plotPDF(end3, name = "Plot-UMAP-Midbrain_Neurons.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
end3
end4 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
highlightCells = projNC$cellNames[projNC$Cell_Identity == "C5_Hindbrain_Neurons"],
name = "Cell_Identity", plotAs = "points", size = 0.2, rastr = F)
plotPDF(end4, name = "Plot-UMAP-Hindbrain_Neurons.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
end4
end5 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
highlightCells = projNC$cellNames[projNC$Cell_Identity == "C10_Late_Mesenchyme"],
name = "Cell_Identity", plotAs = "points", size = 0.2, rastr = F)
plotPDF(end5, name = "Plot-UMAP-Late_Mesenchyme.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
end5
end6 <- plotEmbedding(projNC, embedding = "UMAP", colorBy = "cellColData",
highlightCells = projNC$cellNames[projNC$Cell_Identity == "C6_Somatosensory_Neurons"],
name = "Cell_Identity", plotAs = "points", size = 0.2, rastr = F)
plotPDF(end6, name = "Plot-UMAP-Somatosensory_Neurons.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
end6
```
# Figure S1 - QC Metrics
We saved a pre-filtering version of our object, and use it here to show pre-filtering QC.
## Prep
```{r}
library(ArchR)
library(knitr)
library(TFBSTools)
library(ComplexHeatmap)
library(ggplot2)
library(BSgenome.Ggallus.ENSEMBL.galGal6)
library(org.Gg.eg.db)
library(GenomicFeatures)
library(dplyr)
library(qdapTools)
addArchRThreads(threads = 32)
set.seed(1)
HH6_dir <- "/data/Austin/10XscATAC/HH6_10xscATAC_Lane1/outs/"
HH8_dir <- "/data/Austin/10XscATAC/HH8_10xscATAC_Lane1_Lane2/outs/"
HH10_dir <- "/data/Austin/10XscATAC/HH10_10xscATAC_Lane1_Lane2/outs/"
HH12_dir <- "/data/Austin/10XscATAC/HH12_10xscATAC_Lane1_Lane2/outs/"
HH14_dir <- "/data/Austin/10XscATAC/HH14_10xscATAC_Lane1_Lane2/outs/"
HH16_dir <- "/data/Austin/10XscATAC/HH16_10xscATAC_Lane1/outs/"
HH18_dir <- "/data/Austin/10XscATAC/HH18_10xscATAC_Lane1/outs/"
libraries <- c("HH6","HH8","HH10","HH12","HH14","HH16","HH18")
# Genome annotation
arch_gg6 <- createGenomeAnnotation(genome = BSgenome.Ggallus.ENSEMBL.galGal6, filter = F)
# Manually remove noncontigous chromosomes.
arch_gg6$chromSizes <- arch_gg6$chromSizes[1:35]
TxDb_galGal6 <- makeTxDbFromEnsembl(organism = "Gallus gallus", release = 103)
arch_gg6_genes <- createGeneAnnotation(TxDb = TxDb_galGal6, OrgDb = org.Gg.eg.db, annoStyle = "ENSEMBL")
# TODO recover doublets.
doublet_cells <- as.character(read.csv(file = "doublet_cells.csv", row.names = 1)[,1])
projNC_pre <- loadArchRProject(path = "/data/Austin/10XscATAC/ArchR_Prefiltered/")
projNC_pre@projectMetadata$outputDirectory <- "./Figure_Exports"
projNC_pre$DoubletCall <- ifelse(projNC_pre$cellNames %in% doublet_cells,
"Doublet","Singlet")
```
## A
A Fragment-size distribution plot
```{r}
p4 <- plotFragmentSizes(ArchRProj = projNC_pre)
plotPDF(p4, name = "Prefiltered-Plot-Sample-Fragment-Dist.pdf", ArchRProj = projNC_pre,
addDOC = FALSE, width = 8, height = 8)
p4
```
## B
A TSS enrichment plot and FRiP score plot
```{r}
p5 <- plotGroups(
ArchRProj = projNC_pre,
groupBy = "Sample",
colorBy = "cellColData",
name = "TSSEnrichment",
plotAs = "violin",
alpha = 0.4,
addBoxPlot = TRUE,
discreteSet = "bear"
) + geom_hline(linetype = 5, size = 1,show.legend = F, yintercept = 3.5)
plotPDF(p5, name = "Prefiltered-Plot-Sample-TSS.pdf", ArchRProj = projNC_pre, addDOC = FALSE, width = 8, height = 8)
p5
p6 <- plotGroups(
ArchRProj = projNC_pre,
groupBy = "Sample",
colorBy = "cellColData",
name = "FRIP",
plotAs = "violin",
alpha = 0.4,
addBoxPlot = TRUE,
discreteSet = "bear"
) + geom_hline(linetype = 5, size = 1,show.legend = F, yintercept = 0.4)
plotPDF(p6, name = "Prefiltered-Plot-Sample-FRiP.pdf", ArchRProj = projNC_pre, addDOC = FALSE, width = 8, height = 8)
p6
```
## C
Doublet Detection Plot
```{r}
p7 <- plotEmbedding(ArchRProj = projNC_pre, colorBy = "cellColData", name = "DoubletCall", embedding = "UMAP", size = 1, baseSize = 14, plotAs = "points")
plotPDF(p7, name = "Prefiltered-Plot-UMAP-Doublet.pdf", ArchRProj = projNC_pre, addDOC = FALSE, width = 8, height = 8)
p7
```
## D
Depth Plot
```{r}
p8 <- plotGroups(
ArchRProj = projNC_pre,
groupBy = "Sample",
colorBy = "cellColData",
name = "log10(nFrags)",
plotAs = "violin",
alpha = 0.4,
addBoxPlot = TRUE,
discreteSet = "bear"
) + geom_hline(linetype = 5, size = 1,show.legend = F, yintercept = 3.3)
plotPDF(p8, name = "Prefiltered-Plot-Sample-Depth.pdf", ArchRProj = projNC_pre, addDOC = FALSE, width = 8, height = 8)
p8
```
## E
Extra motif plots of markers
```{r}
motifs <- c("YY2","SIX3","TFAP2A","PAX6","FOXD3","NR2F2","RFX3", "ZIC1")
grey_red <- ArchRPalettes$whiteRed
grey_red[1] <- "grey"
plotting_motifs <- getFeatures(projNC, select = paste(motifs, collapse="|"), useMatrix = "MotifMatrix")
plotting_motifs_z <- paste0("z:",plotting_motifs)
# Problem with threads > 1...
motif_plot_supp <- plotEmbedding(projNC,
embedding = "UMAP",
colorBy = "MotifMatrix",
name = plotting_motifs_z,
plotAs = "points",
sampleCells = NULL,
rastr = F,
keepAxis = F,
threads = 1,
randomize = F)
for (plot in seq(length(motif_plot_supp))){
plotPDF(motif_plot_supp[[plot]], name = paste0("Plot-Motif-Zscores-Supp-",plot),
addDOC = FALSE, ArchRProj = projNC, width = 5, height = 5)
}
# Digging into neuronal clusters.
# Class B dILA Neurons
# LHX1/5 PAX2 DRGX LBX2 GBX1 EN1
neuron_motifs <- c("LBX2","TLX2","LHX5","GBX1")
grey_red <- ArchRPalettes$whiteRed
grey_red[1] <- "grey"
plotting_neuron_motifs <- getFeatures(projNC, select = paste(neuron_motifs, collapse="|"), useMatrix = "MotifMatrix")
plotting_neuron_motifs_z <- paste0("z:",plotting_neuron_motifs)
# Problem with threads > 1...
motif_plot_neurons <- plotEmbedding(projNC,
embedding = "UMAP",
colorBy = "MotifMatrix",
name = plotting_neuron_motifs_z,
plotAs = "points",
sampleCells = NULL,
rastr = F,
keepAxis = F,
threads = 1,
randomize = F)
motif_plot_neurons
for (plot in seq(length(motif_plot_neurons))){
plotPDF(motif_plot_neurons[[plot]], name = paste0("Plot-Motif-Zscores-C6-",plot),
addDOC = FALSE, ArchRProj = projNC, width = 5, height = 5)
}
# tbd neural 1
# dopaminergic neurons of substantia nigra?
# OTX2 RFX4 DMBX1 PITX3 RHOXF1
neuron_motifs_2 <- c("DMBX1","RHOXF1","PITX3","Arid3a")
grey_red <- ArchRPalettes$whiteRed
grey_red[1] <- "grey"
plotting_neuron_motifs_2 <- getFeatures(projNC, select = paste(neuron_motifs_2, collapse="|"), useMatrix = "MotifMatrix")
plotting_neuron_motifs_2_z <- paste0("z:",plotting_neuron_motifs_2)
motif_plot_neurons_2 <- plotEmbedding(projNC,
embedding = "UMAP",
colorBy = "MotifMatrix",
name = plotting_neuron_motifs_2_z,
plotAs = "points",
sampleCells = NULL,
rastr = F,
keepAxis = F,
threads = 1,
randomize = F)
motif_plot_neurons_2
for (plot in seq(length(motif_plot_neurons_2))){
plotPDF(motif_plot_neurons_2[[plot]], name = paste0("Plot-Motif-Zscores-C7-",plot),
addDOC = FALSE, ArchRProj = projNC, width = 5, height = 5)
}
# neural 2
# RFX4 PBX1 MEIS2 SOX10
# Check KROX20 genescore for these guys?
neuron_motifs_3 <- c("RFX4","PBX1","PAX3","SOX10")
grey_red <- ArchRPalettes$whiteRed
grey_red[1] <- "grey"
plotting_neuron_motifs_3 <- getFeatures(projNC, select = paste(neuron_motifs_3, collapse="|"), useMatrix = "MotifMatrix")
plotting_neuron_motifs_3_z <- paste0("z:",plotting_neuron_motifs_3)
motif_plot_neurons_3 <- plotEmbedding(projNC,
embedding = "UMAP",
colorBy = "MotifMatrix",
name = plotting_neuron_motifs_3_z,
plotAs = "points",
sampleCells = NULL,
rastr = F,
keepAxis = F,
threads = 1,
randomize = F)
motif_plot_neurons_3
for (plot in seq(length(motif_plot_neurons_3))){
plotPDF(motif_plot_neurons_3[[plot]], name = paste0("Plot-Motif-Zscores-C5-",plot),
addDOC = FALSE, ArchRProj = projNC, width = 5, height = 5)
}
```
## F
A heatmap of the top changing motifs
```{r}
#scales::show_col(unlist(ArchRPalettes))
Cluster_Motifs <- getMarkerFeatures(
ArchRProj = projNC,
useMatrix = "MotifMatrix",
groupBy = "Clusters",
bias = c("log10(nFrags)"),
maxCells = 750,
testMethod = "wilcoxon",
useSeqnames = "z", threads = 1)
Motif_list <- getMarkers(Cluster_Motifs, cutOff = "FDR <= 1e-50")
Motif_df <- as.data.frame(Motif_list)
top_Motifs <- Motif_df %>% dplyr::group_by(group_name) %>% dplyr::top_n(30, wt = -log10(FDR))
# Motifs by cluster mean Z-Score?
temp <- Cluster_Motifs@assays@data$Mean
# Add rownames
rownames(temp) <- Cluster_Motifs@elementMetadata$name
temp_f <- temp[unique(top_Motifs$name),]
temp_f_t <- t(temp_f)
# Who do we want to label?
label_motifs <- c("TWIST1_741", "OTX2_718","SNAI2_729",
"Dmbx1_366","ZEB1_412","ZBTB18_192","Pou5f1..Sox2_38",
"RUNX1_41","ASCL1_594","MEIS2_262","MITF_707","GRHL2_693",
"YY2_744","SIX1_405","TFAP2A_739","PAX6_14","NR2F2_399",
"RFX3_725","SP4_177","FOXD2_604","Atoh1_306","NEUROG2_162",
"SCRT1_727","Rarg_344","PITX2_526","SOX9_20","PHOX2B_720","ETV4_682",
"KLF2_496","ELK1_357","ZIC1_190","PAX3.var.2_525","PBX1_15",
"SOX10_407","TLX2_555","LHX5_500","LBX2_193","GBX1_372",
"PITX3_205","Arid3a_43","RHOXF1_210","MITF_707")
label_index <- which(colnames(temp_f_t) %in% label_motifs)
label_text <- toupper(stringr::str_split(colnames(temp_f_t)[label_index], pattern = "_", simplify = T)[,1])
heatmap1 <- ComplexHeatmap::Heatmap(matrix = temp_f_t,
cluster_rows = T,
cluster_columns = T,
show_row_names = T,
show_column_names = F,
use_raster = F,
col = as.character(ArchRPalettes$blueYellow),
bottom_annotation = HeatmapAnnotation(
names = anno_mark(at = label_index,
labels = label_text, which = "row", labels_rot = 90)))
plotPDF(heatmap1, name = "Plot-Motif-Heatmap.pdf", ArchRProj = projNC, addDOC = FALSE, width = 10, height = 8)
heatmap1
```
# Figure 2 - Pseudotime
## A
A two-dimensional UMAP projection colored by real timepoint-normalized pseudotime projections
```{r}
p9 <- plotTrajectory(projNC, trajectory = "hour_adj_pseudotime",
colorBy = "cellColData", name = "hour_adj_pseudotime",
plotAs = "points", addArrow = F, embedding = "UMAP", rastr = F)
plotPDF(p9[[1]], name = "Plot-UMAP-Pseudotime.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p9[[1]]
# Pseudotime with just certain cells highlighted
# Mesenchyme
p9b <- plotTrajectory(projNC, trajectory = "C10END",
colorBy = "cellColData", name = "hour_adj_pseudotime",
plotAs = "points", addArrow = F, embedding = "UMAP", rastr = F)
plotPDF(p9b[[1]], name = "Plot-UMAP-Pseudotime-C10END.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p9b[[1]]
p9c <- plotTrajectory(projNC, trajectory = "C5END",
colorBy = "cellColData", name = "hour_adj_pseudotime",
plotAs = "points", addArrow = F, embedding = "UMAP", rastr = F)
plotPDF(p9c[[1]], name = "Plot-UMAP-Pseudotime-C5END.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p9c[[1]]
p9d <- plotTrajectory(projNC, trajectory = "C2END",
colorBy = "cellColData", name = "hour_adj_pseudotime",
plotAs = "points", addArrow = F, embedding = "UMAP", rastr = F)
plotPDF(p9d[[1]], name = "Plot-UMAP-Pseudotime-C2END.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p9d[[1]]
p9e <- plotTrajectory(projNC, trajectory = "C9END",
colorBy = "cellColData", name = "hour_adj_pseudotime",
plotAs = "points", addArrow = F, embedding = "UMAP", rastr = F)
plotPDF(p9e[[1]], name = "Plot-UMAP-Pseudotime-C9END.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p9e[[1]]
p9f <- plotTrajectory(projNC, trajectory = "C1END",
colorBy = "cellColData", name = "hour_adj_pseudotime",
plotAs = "points", addArrow = F, embedding = "UMAP", rastr = F)
plotPDF(p9f[[1]], name = "Plot-UMAP-Pseudotime-C1END.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p9f[[1]]
p9g <- plotTrajectory(projNC, trajectory = "C7END",
colorBy = "cellColData", name = "hour_adj_pseudotime",
plotAs = "points", addArrow = F, embedding = "UMAP", rastr = F)
plotPDF(p9g[[1]], name = "Plot-UMAP-Pseudotime-C7END.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p9g[[1]]
p9h <- plotTrajectory(projNC, trajectory = "C6END",
colorBy = "cellColData", name = "hour_adj_pseudotime",
plotAs = "points", addArrow = F, embedding = "UMAP", rastr = F)
plotPDF(p9h[[1]], name = "Plot-UMAP-Pseudotime-C6END.pdf", ArchRProj = projNC, addDOC = FALSE, width = 8, height = 8)
p9h[[1]]
# What is the average age per cluster? Does this match expectations?
avg_age = data.frame(Cluster = c("C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"),
Avg_Pseudotime = c(mean(projNC[projNC$Cell_Identity == "C1_Melanocytes"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C2_Sensory_Glia"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C3_Int_Mesenchyme"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C4_Multipotent_NC"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C5_Hindbrain_Neurons"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C6_Somatosensory_Neurons"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C7_Midbrain_Neurons"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C8_Early_Mesenchyme"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C9_Sensory_Neurons"]$hour_adj_pseudotime),
mean(projNC[projNC$Cell_Identity == "C10_Late_Mesenchyme"]$hour_adj_pseudotime)))
# How many cells for each lineage?
summary(as.factor(projNC$Cell_Identity))
```
## B
Motifs that change over pseudotime.
Highlighting the mesencyhme, midbrain, somatosensory, and hindbrain neurons, sensory ganglia, and sensory neuron lineages.
First we have to isolate the cells of that lineage to perform the analysis on (differentially enriched).
Then, we aggregate transcription factor signal by family to reduce noise.
Finally, we plot a heatmap and label specific transcription factors of interest in each lineage.
```{r Family Aggregation}
matrix_agg_scores <- function(input = sm_mat, transpose = T) {
## A function to aggregate motif scores by family.
if (transpose){
input <- t(input)
}
# Convert to DF
input <- as.data.frame(input)
# Clean up names
colnames(input) <- toupper(colnames(input))
# GRHL
if (any(c("GRHL1","GRHL2","GRHL3") %in% colnames(input))){
print("Collapsing GRHL's")
# Which are present?
select <- c("GRHL1","GRHL2","GRHL3")[c("GRHL1","GRHL2","GRHL3") %in% colnames(input)]
GRHL_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$GRHL_Family <- GRHL_Family
}
# TEAD
if (any(c("TEAD1","TEAD2","TEAD3","TEAD4") %in% colnames(input))){
print("Collapsing TEAD's")
# Which are present?
select <- c("TEAD1","TEAD2","TEAD3","TEAD4")[c("TEAD1","TEAD2","TEAD3","TEAD4") %in% colnames(input)]
TEAD_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$TEAD_Family <- TEAD_Family
}
# TFAP2
if (any(grep(pattern = "TFAP2", colnames(input), value = T) %in% colnames(input))){
print("Collapsing TAFP2's")
select <- grep(pattern = "TFAP2", colnames(input), value = T)[grep(pattern = "TFAP2", colnames(input), value = T) %in% colnames(input)]
TFAP2_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$TFAP2_Family <- TFAP2_Family
}
# SANI
if (any(c("SNAI1", "SNAI2","SNAI3") %in% colnames(input))){
print("Collapsing SANI's")
# Which are present?
select <- c("SNAI1", "SNAI2","SNAI3")[c("SNAI1", "SNAI2","SNAI3") %in% colnames(input)]
SANI_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$SANI_Family <- SANI_Family
}
# SOXB
if (any(c("SOX1", "SOX2","SOX3") %in% colnames(input))){
print("Collapsing SOXB's")
# Which are present?
select <- c("SOX1", "SOX2","SOX3")[c("SOX1", "SOX2","SOX3") %in% colnames(input)]
SOXB_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$SOXB_Family <- SOXB_Family
}
# SOXD
if (any(c("SOX5", "SOX6","SOX13") %in% colnames(input))){
print("Collapsing SOXD's")
# Which are present?
select <- c("SOX5", "SOX6","SOX13")[c("SOX5", "SOX6","SOX13") %in% colnames(input)]
SOXD_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$SOXD_Family <- SOXD_Family
}
# SOXE
if (any(c("SOX8", "SOX9","SOX10") %in% colnames(input))){
print("Collapsing SOXE's")
# Which are present?
select <- c("SOX8", "SOX9","SOX10")[c("SOX8", "SOX9","SOX10") %in% colnames(input)]
SOXE_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$SOXE_Family <- SOXE_Family
}
# SOXF
if (any(c("SOX7", "SOX17","SOX18") %in% colnames(input))){
print("Collapsing SOXF's")
# Which are present?
select <- c("SOX7", "SOX17","SOX18")[c("SOX7", "SOX17","SOX18") %in% colnames(input)]
SOXF_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$SOXF_Family <- SOXF_Family
}
# NR2F
if (any(grep(pattern = "NR2F", colnames(input), value = T) %in% colnames(input))){
print("Collapsing NR2F's")
select <- grep(pattern = "NR2F", colnames(input), value = T)[grep(pattern = "NR2F", colnames(input), value = T) %in% colnames(input)]
NR2F_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$NR2F_Family <- NR2F_Family
}
# SP
if (any(c("SP1", "SP2","SP3","SP4","SP8","SP9") %in% colnames(input))){
print("Collapsing SP's")
# Which are present?
select <- c("SP1", "SP2","SP3","SP4","SP8","SP9")[c("SP1", "SP2","SP3","SP4","SP8","SP9") %in% colnames(input)]
SP_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$SP_Family <- SP_Family
}
# FOX
if (any(grep(pattern = "FOX", colnames(input), value = T) %in% colnames(input))){
print("Collapsing FOX's")
select <- grep(pattern = "FOX", colnames(input), value = T)[grep(pattern = "FOX", colnames(input), value = T) %in% colnames(input)]
FOX_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$FOX_Family <- FOX_Family
}
# KLF
if (any(grep(pattern = "KLF", colnames(input), value = T) %in% colnames(input))){
print("Collapsing KLF's")
select <- grep(pattern = "KLF", colnames(input), value = T)[grep(pattern = "KLF", colnames(input), value = T) %in% colnames(input)]
KLF_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$KLF_Family <- KLF_Family
}
# RFX
if (any(grep(pattern = "RFX", colnames(input), value = T) %in% colnames(input))){
print("Collapsing RFX's")
select <- grep(pattern = "RFX", colnames(input), value = T)[grep(pattern = "RFX", colnames(input), value = T) %in% colnames(input)]
RFX_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$RFX_Family <- RFX_Family
}
# RXR
if (any(grep(pattern = "RFR", colnames(input), value = T) %in% colnames(input))){
print("Collapsing RFR's")
select <- grep(pattern = "RFR", colnames(input), value = T)[grep(pattern = "RFR", colnames(input), value = T) %in% colnames(input)]
RFR_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$RFR_Family <- RFR_Family
}
# SIX
if (any(grep(pattern = "SIX", colnames(input), value = T) %in% colnames(input))){
print("Collapsing SIX's")
select <- grep(pattern = "SIX", colnames(input), value = T)[grep(pattern = "SIX", colnames(input), value = T) %in% colnames(input)]
SIX_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$SIX_Family <- SIX_Family
}
# ETV
if (any(grep(pattern = "ETV", colnames(input), value = T) %in% colnames(input))){
print("Collapsing ETV's")
select <- grep(pattern = "ETV", colnames(input), value = T)[grep(pattern = "ETV", colnames(input), value = T) %in% colnames(input)]
ETV_Family <- Matrix::rowMeans(input[,select])
input <- input[!colnames(input) %in% select]
input$ETV_Family <- ETV_Family
}
return(input)
}
```
```{r Mesenchyme TF over pseudotime}
# Motif scores per cell
motif_mat <- getMatrixFromProject(projNC,
useMatrix = "MotifMatrix",
useSeqnames = "z")
motif_mat_raw <- assay(motif_mat)
motif_mat_impute <- imputeMatrix(mat = motif_mat_raw,
imputeWeights = getImputeWeights(projNC))
# Cell names along mesenchyme trajectory
mes_cells <- projNC$cellNames[projNC$Clusters %in% c("C4","C3","C8","C10")]
which(projNC$cellNames %in% mes_cells)
# Order columns by pseudotime.
mes_cells_df <- data.frame(Name = mes_cells,
Pseudotime = projNC$hour_adj_pseudotime[projNC$Clusters %in% c("C4","C3","C8","C10")])
mes_cells_df <- mes_cells_df[order(mes_cells_df$Pseudotime),]
mes_motif_mat_impute_ord <- as.matrix(motif_mat_impute[,mes_cells_df$Name])
# Collapse by motif family.
rownames(mes_motif_mat_impute_ord) <- stringr::str_split(rownames(mes_motif_mat_impute_ord), pattern = "_", simplify = T)[,1]
mes_motif_mat_impute_ord <- t(matrix_agg_scores(mes_motif_mat_impute_ord))
# Filter to only enriched TF's
mes_Motifs <- getMarkerFeatures(
ArchRProj = projNC,
useMatrix = "MotifMatrix",
groupBy = "Clusters",
useGroups = c("C3","C8","C10"),
bias = c("log10(nFrags)"),
maxCells = 750,
testMethod = "wilcoxon",
useSeqnames = "z", threads = 1)
mes_motif_df <- as.data.frame(getMarkers(mes_Motifs, cutOff = "FDR <= 1e-20 & MeanDiff > 2"))
selected_motifs <- toupper(unique(mes_motif_df$name))
selected_motifs <- stringr::str_split(selected_motifs, pattern = "_", simplify = T)[,1]
# Remove motifs NOT in the family-collapsed matrix.
selected_motifs <- selected_motifs[selected_motifs %in% rownames(mes_motif_mat_impute_ord)]
# Add in the family names
selected_motifs <- c(selected_motifs, grep("_Family", rownames(mes_motif_mat_impute_ord), value = T))
labels <- c("ETS1","RXRG","NR2F_Family","TWIST1",
"ZBTB18","TFAP2_Family","JUNB",
"FOSL1..JUN","FLI1","SOXE_Family")
labels[!labels %in% selected_motifs]
label_index <- which(selected_motifs %in% labels)
heatmap3 <- ComplexHeatmap::Heatmap(
matrix = mes_motif_mat_impute_ord[selected_motifs,],
cluster_rows = T, cluster_columns = F, show_column_names = F,
show_row_names = F, use_raster = F, row_title = "chromVAR z-score",
column_title = "Cells ordered in Pseudotime: Mesenchyme",
col = as.character(ArchRPalettes$blueYellow)) +
rowAnnotation(names = anno_mark(at = label_index, labels = labels))
selected_motifs[row_order(heatmap3)]
plotPDF(heatmap3, name = "Plot-Mesenchyme-Motif-Pseudotime-Heatmap.pdf", ArchRProj = projNC, addDOC = FALSE, width = 6, height = 5)
heatmap3
```
```{r Hindbrain Neurons TF over pseudotime}
# Cell names along Neural 1 trajectory
neural1_cells <- projNC$cellNames[projNC$Clusters %in% c("C4","C5")]
# Order columns by pseudotime.
neural1_cells_df <- data.frame(Name = neural1_cells,
Pseudotime = projNC$hour_adj_pseudotime[projNC$Clusters %in% c("C4","C5")])
neural1_cells_df <- neural1_cells_df[order(neural1_cells_df$Pseudotime),]
ordered_neural1 <- as.matrix(motif_mat_impute[,neural1_cells_df$Name])
# Collapse by motif family.
rownames(ordered_neural1) <- stringr::str_split(rownames(ordered_neural1), pattern = "_", simplify = T)[,1]
ordered_neural1 <- t(matrix_agg_scores(ordered_neural1))
# Filter to only enriched TF's
neural1_Motifs <- getMarkerFeatures(
ArchRProj = projNC,
useMatrix = "MotifMatrix",
groupBy = "Clusters",
useGroups = c("C4","C5"),
bias = c("log10(nFrags)"),
maxCells = 750,
testMethod = "wilcoxon",
useSeqnames = "z", threads = 1)
neural1_motif_df <- as.data.frame(getMarkers(neural1_Motifs, cutOff = "FDR <= 1e-15 & MeanDiff > 1"))
selected_motifs <- toupper(unique(neural1_motif_df$name))
selected_motifs <- stringr::str_split(selected_motifs, pattern = "_", simplify = T)[,1]
# Remove motifs NOT in the family-collapsed matrix.
selected_motifs <- selected_motifs[selected_motifs %in% rownames(ordered_neural1)]
# Add in the family names
selected_motifs <- c(selected_motifs, grep("_Family", rownames(ordered_neural1), value = T))
# Choose which transcription factors to highlight
labels <- c("POU5F1..SOX2","RFX_Family","MEIS1.VAR.2","SOXB_Family",
"PBX1","MEIS2","ZIC_Family","PBX2","MEIS3","PAX3","SOX10",
"POU3F2","RFX3")
# Ensure labels are in selected motifs
labels[!labels %in% selected_motifs]
label_index <- which(selected_motifs %in% labels)
label_text <- toupper(stringr::str_split(rownames(ordered_neural1[selected_motifs,])[label_index], pattern = "_", simplify = T)[,1])
heatmap4 <- ComplexHeatmap::Heatmap(
matrix = ordered_neural1[selected_motifs,],
cluster_rows = T, cluster_columns = F, show_column_names = F,
show_row_names = F, use_raster = F, row_title = "chromVAR z-score",
column_title = "Cells ordered in Pseudotime: Hindbrain Neurons",
col = as.character(ArchRPalettes$blueYellow)) +
rowAnnotation(names = anno_mark(at = label_index, labels = label_text))
unique(neural1_motif_df$name)[row_order(heatmap4)]
plotPDF(heatmap4, name = "Plot-Hindbrain-Neurons-Motif-Pseudotime-Heatmap.pdf", ArchRProj = projNC, addDOC = FALSE, width = 6, height = 5)
heatmap4
```
```{r Midbrain Neurons TF over pseudotime}
# Cell names along Neural 2 trajectory
neural2_cells <- projNC$cellNames[projNC$Clusters %in% c("C4","C7")]
which(projNC$cellNames %in% neural2_cells)
# Order columns by pseudotime.
neural2_cells_df <- data.frame(Name = neural2_cells,
Pseudotime = projNC$hour_adj_pseudotime[projNC$Clusters %in% c("C4","C7")])
neural2_cells_df <- neural2_cells_df[order(neural2_cells_df$Pseudotime),]
ordered_neural2 <- as.matrix(motif_mat_impute[,neural2_cells_df$Name])
# Filter to only enriched TF's
neural2_Motifs <- getMarkerFeatures(
ArchRProj = projNC,
useMatrix = "MotifMatrix",
groupBy = "Clusters",
useGroups = c("C4","C7"),
bias = c("log10(nFrags)"),
maxCells = 750,
testMethod = "wilcoxon",
useSeqnames = "z", threads = 1)
neural2_motif_df <- as.data.frame(getMarkers(neural2_Motifs, cutOff = "FDR <= 1e-15 & MeanDiff > 1.5"))
labels <- c("OTX2_718","Pou5f1..Sox2_38","Dmbx1_366",
"PITX2_526","SOX2_730","Arid3a_43","PHOX2A_204",
"Shox2_211","GBX1_372","GATA1_690",
"PITX3_205","RHOXF1_210")
label_index <- which(unique(neural2_motif_df$name) %in% labels)
label_text <- stringr::str_split(unique(neural2_motif_df$name)[label_index], pattern = "_", simplify = T)[,1]
heatmap5 <- ComplexHeatmap::Heatmap(
matrix = ordered_neural2[unique(neural2_motif_df$name),],
cluster_rows = T, cluster_columns = F, show_column_names = F,
show_row_names = F, use_raster = F, row_title = "chromVAR z-score",
column_title = "Cells ordered in Pseudotime: Midbrain Neurons",
col = as.character(ArchRPalettes$blueYellow)) +
rowAnnotation(names = anno_mark(at = label_index, labels = label_text))
unique(neural2_motif_df$name)[row_order(heatmap5)]
plotPDF(heatmap5, name = "Plot-Midbrain-Neurons-Motif-Pseudotime-Heatmap.pdf", ArchRProj = projNC, addDOC = FALSE, width = 6, height = 5)
heatmap5
```
```{r Sensory glia TF over pseudotime}
# Cell names along sensory glia trajectory
sensory_cells <- projNC$cellNames[projNC$Clusters %in% c("C4","C2")]
which(projNC$cellNames %in% sensory_cells)
# Order columns by pseudotime.
sensory_cells_df <- data.frame(Name = sensory_cells,
Pseudotime = projNC$hour_adj_pseudotime[projNC$Clusters %in% c("C4","C2")])
sensory_cells_df <- sensory_cells_df[order(sensory_cells_df$Pseudotime),]
ordered_sensory <- as.matrix(motif_mat_impute[,sensory_cells_df$Name])
# Filter to only enriched TF's
sensory_Motifs <- getMarkerFeatures(
ArchRProj = projNC,
useMatrix = "MotifMatrix",
groupBy = "Clusters",
useGroups = c("C2"),
bias = c("log10(nFrags)"),
maxCells = 750,
testMethod = "wilcoxon",
useSeqnames = "z", threads = 1)
sensory_motif_df <- as.data.frame(getMarkers(sensory_Motifs, cutOff = "FDR <= 1e-15 & MeanDiff > 1.5"))
labels <- c("GRHL2_693","ASCL1.var.2_639","ZEB1_412",
"SNAI2_729","SIX1_405","DLX5_464",
"MEOX2_196","ISL2_388","TEAD4_738",
"GATA2_390")
label_index <- which(unique(sensory_motif_df$name) %in% labels)
label_text <- stringr::str_split(unique(sensory_motif_df$name)[label_index], pattern = "_", simplify = T)[,1]
heatmap6 <- ComplexHeatmap::Heatmap(
matrix = ordered_sensory[unique(sensory_motif_df$name),],
cluster_rows = T, cluster_columns = F, show_column_names = F,
show_row_names = F, use_raster = F, row_title = "chromVAR z-score",
column_title = "Cells ordered in Pseudotime: Sensory Glia",
col = as.character(ArchRPalettes$blueYellow)) +
rowAnnotation(names = anno_mark(at = label_index, labels = label_text))
unique(sensory_motif_df$name)[row_order(heatmap6)]
plotPDF(heatmap6, name = "Plot-Sensory-Glia-Motif-Pseudotime-Heatmap.pdf", ArchRProj = projNC, addDOC = FALSE, width = 6, height = 5)
heatmap6
```
```{r Sensory neurons TF over pseudotime}
# Cell names along sensory neuron trajectory
sensory_neuron_cells <- projNC$cellNames[projNC$Clusters %in% c("C4","C9")]
which(projNC$cellNames %in% sensory_neuron_cells)
# Order columns by pseudotime.
sensory_neuron_cells_df <- data.frame(Name = sensory_neuron_cells,
Pseudotime = projNC$hour_adj_pseudotime[projNC$Clusters %in% c("C4","C9")])
sensory_neuron_cells_df <- sensory_neuron_cells_df[order(sensory_neuron_cells_df$Pseudotime),]
ordered_sensory_neuron <- as.matrix(motif_mat_impute[,sensory_neuron_cells_df$Name])
# Filter to only enriched TF's
sensory_neuron_Motifs <- getMarkerFeatures(
ArchRProj = projNC,
useMatrix = "MotifMatrix",
groupBy = "Clusters",
useGroups = c("C9"),
bias = c("log10(nFrags)"),
maxCells = 750,
testMethod = "wilcoxon",
useSeqnames = "z", threads = 1)
sensory_neuron_motif_df <- as.data.frame(getMarkers(sensory_neuron_Motifs, cutOff = "FDR <= 1e-15 & MeanDiff > 1.5"))
labels <- c("Foxd3_8","FOXE1_472","FOXO4_334","HAND2_646",
"NEUROG2.var.2_650","ATOH1.var.2_455","NEUROD1_395",
"Ascl2_305","GATA5_605")
label_index <- which(unique(sensory_neuron_motif_df$name) %in% labels)
label_text <- stringr::str_split(unique(sensory_neuron_motif_df$name)[label_index], pattern = "_", simplify = T)[,1]
heatmap7 <- ComplexHeatmap::Heatmap(
matrix = ordered_sensory_neuron[unique(sensory_neuron_motif_df$name),],
cluster_rows = T, cluster_columns = F, show_column_names = F,
show_row_names = F, use_raster = F, row_title = "chromVAR z-score",
column_title = "Cells ordered in Pseudotime: Sensory Neurons",
col = as.character(ArchRPalettes$blueYellow)) +
rowAnnotation(names = anno_mark(at = label_index, labels = label_text))
unique(sensory_neuron_motif_df$name)[row_order(heatmap7)]
plotPDF(heatmap7, name = "Plot-Sensory-neuron-Motif-Pseudotime-Heatmap.pdf", ArchRProj = projNC, addDOC = FALSE, width = 6, height = 5)
heatmap7
```
```{r Somatosensory Neurons TF over pseudotime}
# Cell names along Neural 2 trajectory
neural3_cells <- projNC$cellNames[projNC$Clusters %in% c("C4","C6")]
which(projNC$cellNames %in% neural3_cells)
# Order columns by pseudotime.