A novel clustering algorithm and toolkit to accurately identify various cell types using single cell RNA sequencing data from a complex tissue. This algorithm considers both local similarity and global similarity among the cells to discern the subtle differences among cells of the same type as well as larger differences among cells of different types. This algorithm uses Spearman’s rank correlations of a cell’s expression vector with those of other cells to measure its global similarity, and learns neighbour representation of a cell as its local similarity. The overall similarity of a cell to other cells is a linear combination of its global similarity and local similarity. See Mei et. al. (2021)
RCSL is an R toolkit for single-cell clustering and trajectory analysis using single-cell RNA-seq data.
This package can be installed through devtools in R:
$ R
> library("devtools")
> devtools::install_github("QinglinMei/RCSL")
Now RCSL can be loaded in R:
> library(RCSL)
The input of RCSL is a normalized data matrix with columns being cells and rows being genes in log(CPM+1), log(RPKM+1), log(TPM+1) or log(FPKM+1) format; or a data file in RDS format.
We provide an example script to run RCSL in demo_RCSL.R.
The nine functions of RCSL can also be run independently.
| Function | Description |
|---|---|
GenesFilter |
Perform genes filtering. |
SimS |
Calculate the initial similarity matrix S. |
NeigRepresent |
Calculate the neighbor representation of cells. |
EstClusters |
Estimate the optimal number of clusters C. |
BDSM |
Learn the block-diagonal matrix B. |
PlotMST |
Construct MST based on clustering results from RCSL. |
PlotPseudoTime |
Infer the pseudo-temporal ordering of cells. |
getLineage |
Infer the lineage based on the clustering results and the starting cell. |
PlotTrajectory |
Plot the developmental trajectory based on the clustering results and the starting cell. |
Load packages:
> library(RCSL)
> library(SingleCellExperiment)
> library(ggplot2)
> library(igraph)
Load Yan dataset:
> origData <- yan
> data <- logcounts(origData+1)
> label <- origData$cell_type1
> DataName <- "Yan"
Generating clustering result:
> res_RCSL <- RCSL(data)
Calculating Adjusted Rand Index:
> ARI_RCSL <- igraph::compare(res_RCSL$y, label, method = "adjusted.rand")
Trajectory analysis:
> label <- origData$cell_type1
> res_TrajecAnalysis <- TrajectoryAnalysis(res_RCSL$gfData, res_RCSL$drData, res_RCSL$S,
clustRes = res_RCSL$y, TrueLabel = label, startPoint = 1,
dataName = DataName)
Display the plot of constructed MST:
> res_TrajecAnalysis$MSTPlot
Display the plot of the pseudo-temporal ordering
> res_TrajecAnalysis$PseudoTimePlot
Display the plot of the inferred developmental trajectory
> res_TrajecAnalysis$TrajectoryPlot
A vignette in R Notebook format is available here
Please feel free to contact us if you have problems running our tool at [email protected].