-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPb_Spz_10X_6.Rmd
106 lines (62 loc) · 2.75 KB
/
Pb_Spz_10X_6.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
---
title: "Pb_Spz_10X_6"
author: "Anthony Ruberto and Caitlin Bourke"
output: html_document
---
i. Load libraries.
```{r load libraries}
suppressPackageStartupMessages({
library(SingleCellExperiment)
library(Seurat)
library(ggpubr)
library(slingshot)
library(tradeSeq)
})
```
ii. Load color palettes
```{r color palette}
palette<-c( '#3cb44b', "#e6194b", '#4363d8','#f58231','#911eb4', 'lightgrey','#ffe119', '#46f0f0', '#800000', '#ffd8b1', '#fabebe', '#008080', '#e6beff', '#9a6324', 'grey60', '#f032e6', '#aaffc3', '#808000', '#bcf60c', '#000075', '#808080', '#ffffff', '#000000')
palette2<-c('#f58231', '#911eb4', '#46f0f0', '#800000', '#008080','grey60', '#f032e6','#808000','red', '#aaffc3', '#bcf60c', '#000075', '#808080', '#ffffff', '#000000','#3cb44b', "#e6194b", '#4363d8','#ffe119','#ffd8b1', '#fabebe' ,'#e6beff', '#9a6324')
```
1. Upload 10X sporozoite data from Pb_Spz_10X_5.rmd.
```{r upload 10X data}
Pb.integrated.10X.only<-readRDS("output/5_Pb_integrated_10X_only.rds")
```
2. Reformat data so that it is compatible with Slingshot.
```{r Seurat to Slingshot}
dimred <- Pb.integrated.10X.only@[email protected]
clustering <- Pb.integrated.10X.only$integrated_snn_res.0.7
# Full gene list - Note: Long processing time. To reproduce output in manuscript, use this matrix.
counts <- as.matrix(Pb.integrated.10X@assays$RNA@counts)
# Variable features only - Drasitically speeds up run time. Run to only output variable transcripts. Note: This will produce a genelist with different statisical outputs.
# counts <- as.matrix(Pb.integrated.10X.only@assays$RNA@counts[Pb.integrated.10X.only@[email protected], ])
```
3. Determine the lineages in the data.
```{r lineage identification}
# Run default Slingshot lineage identification
set.seed(1)
lineages <- getLineages(data = dimred, clusterLabels = clustering)
lineages
```
4. Find principal curves.
```{r find principal curves}
curvesALL <- getCurves(lineages, approx_points = F, allow.breaks = FALSE)
curvesALL
```
5. Plot principal curves on UMAP.
```{r plot Principal curves}
# Figure 4a.
plot(dimred[,c(1,2)], col = palette2[clustering], asp = 1, pch = 16, cex = .5)
lines(curvesALL, lwd = 7, col = c("black","green", "blue", 'red'))
```
6. Fit GAM - takes some time. Grab a coffee.
```{r GAM fitting SG 10X scRNA-seq}
sceALL10Xspz <- fitGAM(counts = counts, sds = curvesALL)
```
Once the GAM fitting is complete, use tradeSEQ [1] on the sceALL10Xspz object to:
1) Assess differential expression pattern between lineages - patternTest().
2) Perform statistical test to check for DE between final stages of every lineage - diffEndTest().
7. Save RDS.
```{r save SCE pseudotime object}
saveRDS(sceALL10Xspz, "output/6_Pb_integrated_10X_only_pseudotime.rds")
```