if (!requireNamespace("remotes")) install.packages("remotes")
::install_github("GfellerLab/SuperCell") remotes
library(SuperCell)
library(velocyto.R)
We show an example of how SuperCell can be used prior to velocyto.R to compute RNA velocity.
We use a built-in pancreas dataset from Bastidas-Ponce et al. (2019) For RNA velocity, we need spliced and un-spliced count matrices.
data("pancreas")
<- SCimplify_for_velocity(
SC_pancreas $emat,
pancreas$nmat,
pancreasgamma = 10)
<- supercell_estimate_velocity(SC_pancreas$emat, SC_pancreas$nmat) Vel
# Assign clusters to metacells based on the given single clustering
<- supercell_assign(pancreas$meta$clusters, SC_pancreas$membership) clusters
# Set up the color scheme
<- length(unique(clusters))
N.clusters <- setNames(colorRampPalette(RColorBrewer::brewer.pal(8, name= "Set1"))(N.clusters),
pal as.character(unique(clusters)))
<- setNames(pal[as.character(clusters)], names(clusters))
color
<- c('Ngn3 low EP', 'Alpha', 'Delta', 'Beta', 'Pre-endocrine', 'Ngn3 high EP', 'Ductal', 'Epsilon') map_cluster_to_cluster_name
<- sqrt(1+table(SC_pancreas$membership))/sqrt(2)/2
size set.seed(3)
<- tSNE.velocity.plot(Vel,
tsne10 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)