Changes between Initial Version and Version 1 of SOP/scRNA-seq/Slingshot


Ignore:
Timestamp:
10/13/20 13:24:27 (4 years ago)
Author:
byuan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SOP/scRNA-seq/Slingshot

    v1 v1  
     1
     2== Making diffusion maps with Slingshot ==
     3
     4You can either assigned cells to clusters based on [https://bioconductor.org/packages/release/bioc/vignettes/slingshot/inst/doc/vignette.html | Slingshot protocol ] or make a single cell object, i.e. from the Seurat object. Example commands for convert to single cell object from Seurat.
     5 
     6  * **Making a single cell object from a Seurat object**
     7{{{
     8library(Seurat)
     9library(SingleCellExperiment)
     10sce <- as.SingleCellExperiment(seuratObject)
     11#this has the cell classification
     12table(sce$ident)
     13}}}
     14
     15== Calculate pseudotime and lineages with Slingshot ==
     16
     17  You can use either PCA/UMAP/TSNE for reduction. Since Slingshot is designed for cases in which cells fall along a continuous trajectory, it's better to use PCA if clearly discrete clusters in UMAP, as mentioned in [https://github.com/kstreet13/slingshot/issues/43 | Slingshot github page]
     18
     19{{{
     20sce <- slingshot(sce, clusterLabels = ident, reducedDim = "PCA",
     21                      allow.breaks = FALSE)
     22# get the lineages:
     23lnes <- getLineages(reducedDim(sce,"PCA"), sce$ident)
     24lnes@lineages
     25
     26}}}
     27
     28If you know the which cluster is the origin ( last cluster), you can assign starting cluster/last cluster:
     29
     30{{{
     31sce <- slingshot(sce, clusterLabels = ident, reducedDim = "PCA",
     32                      allow.breaks = FALSE, start.clus="2")
     33# get the lineages:
     34lnes <- getLineages(reducedDim(sce2,"PCA"),
     35                    sce2$ident, start.clus = "2")
     36lnes@lineages
     37}}}
     38
     39== Visualize the pseudotime or lineages ==
     40
     41 draw plot with first pseudotime as x-axis, and y-axis is the cell type. If you have multiple lineages, cells that were identified as being specific to Lineage 2 will have NA values for slingPseudotime_1 ( [https://github.com/kstreet13/slingshot/issues/42 | slingshot github page] )
     42
     43{{{
     44
     45library(Polychrome)
     46library(ggbeeswarm)
     47library(ggthemes)
     48
     49my_color <- createPalette(length(levels(sce$ident)), c("#010101", "#ff0000"), M=1000)
     50names(my_color) <- unique(as.character(sce$ident))
     51
     52slingshot_df <- data.frame(colData(sce))
     53
     54# re-order y-axis for better figure:
     55slingshot_df$ident = factor(slingshot_df$ident, levels=c(4,2,1,0,3,5,6))
     56
     57ggplot(slingshot_df, aes(x = slingPseudotime_1, y = ident,
     58                              colour = ident)) +
     59    geom_quasirandom(groupOnX = FALSE) + theme_classic() +
     60    xlab("First Slingshot pseudotime") + ylab("cell type") +
     61    ggtitle("Cells ordered by Slingshot pseudotime")+scale_colour_manual(values = my_color)
     62
     63
     64}}}
     65
     66# plot Lineages along the cells in PCAs
     67
     68{{{
     69
     70plot(reducedDims(sce)$PCA, col = my_color[as.character(sce$ident)],
     71     pch=16,
     72     asp = 1)
     73legend("bottomleft",legend = names(my_color[levels(sce$ident)]), 
     74       fill = my_color[levels(sce$ident)])
     75lines(SlingshotDataSet(lnes), lwd=2, type = 'lineages', col = c("black"))
     76
     77}}}
     78