-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathc_RNAvelocity_for_SuperCell.Rmd
More file actions
90 lines (72 loc) · 2.89 KB
/
c_RNAvelocity_for_SuperCell.Rmd
File metadata and controls
90 lines (72 loc) · 2.89 KB
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
---
title: "RNA-velocity for SuperCell"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{RNA-velocity for SuperCell}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "figures/",
fig.width = 6, fig.height = 6,
eval = FALSE
)
```
## RNA velocity combining with metacells computed with SuperCell
```{r library, warning=FALSE, eval=FALSE}
if (!requireNamespace("remotes")) install.packages("remotes")
remotes::install_github("GfellerLab/SuperCell")
```
```{r load libraries, warning=FALSE}
library(SuperCell)
library(velocyto.R)
```
We show an example of how SuperCell can be used prior to velocyto.R to compute RNA velocity.
### Load data and compute metacells' spliced and un-spliced counts
We use a built-in *pancreas* dataset from [Bastidas-Ponce et al. (2019)](https://journals.biologists.com/dev/article/146/12/dev173849/19483/Comprehensive-single-cell-mRNA-profiling-reveals-a) For RNA velocity, we need spliced and un-spliced count matrices.
```{r load data}
data("pancreas")
```
```{r compute metacells for RNA velocity}
SC_pancreas <- SCimplify_for_velocity(
pancreas$emat,
pancreas$nmat,
gamma = 10)
```
### Compute RNA velocity
```{r compute RNA velocity}
Vel <- supercell_estimate_velocity(SC_pancreas$emat, SC_pancreas$nmat)
```
### Plot RNA velocity on a tSNE's coordinates
```{r plot RNA velocity}
# Assign clusters to metacells based on the given single clustering
clusters <- supercell_assign(pancreas$meta$clusters, SC_pancreas$membership)
```
#### Set up the color scheme
```{r set up the color scheme}
# Set up the color scheme
N.clusters <- length(unique(clusters))
pal <- setNames(colorRampPalette(RColorBrewer::brewer.pal(8, name= "Set1"))(N.clusters),
as.character(unique(clusters)))
color <- setNames(pal[as.character(clusters)], names(clusters))
map_cluster_to_cluster_name <- c('Ngn3 low EP', 'Alpha', 'Delta', 'Beta', 'Pre-endocrine', 'Ngn3 high EP', 'Ductal', 'Epsilon')
```
#### Plot tSNE
```{r Plot tSNE, fig.asp=1, fig.height=5, fig.width=5, fig.ext='pdf'}
size <- sqrt(1+table(SC_pancreas$membership))/sqrt(2)/2
set.seed(3)
tsne10 <- tSNE.velocity.plot(Vel,
cell.colors = ac(color, alpha = 0.6),
scale = "log", do.par = T,
delta.norm = FALSE, nPcs = 15, norm.nPcs = 15 * 10, perplexity = 50,
show.grid.flow = FALSE, grid.n = 20, grid.sd = NULL, min.grid.cell.mass = 1,
pcount = 1, verbose = TRUE, min.arrow.median.ratio = 1/10,
max.arrow.quantile = 0.9, arrow.scale = 1, arrow.lwd = 1,
xlab = "tSNE-x", ylab = "tSNE-y", size.norm = FALSE, cex = size
)
legend("topleft", legend=map_cluster_to_cluster_name,
fill=pal, cex=0.8)
```