Performs robust PCA with modified PCs on Seurat objects for scRNA-Seq dimensionality reduction.
You can install scRobustPCA from github with:
# install.packages("devtools")
devtools::install_github("gmstanle/scRobustPCA")
Intended only to demonstrate a functional workflow. pbmc_small
is a subsetted dataset with 80 cells and 230 genes included in the Seurat
package.
require(Seurat)
#> Loading required package: Seurat
#> Loading required package: ggplot2
#> Loading required package: cowplot
#>
#> Attaching package: 'cowplot'
#> The following object is masked from 'package:ggplot2':
#>
#> ggsave
#> Loading required package: Matrix
require(scRobustPCA)
#> Loading required package: scRobustPCA
pcs.use=1:5
pbmc_small <- FindVariableGenes(pbmc_small, do.plot = F) # optional
pbmc_small <- RunRobPCA(pbmc_small, npcs=max(pcs.use), use.modified.pcscores = T)
#> [1] "Running rPCA"
#> [1] "PC1" "PC2" "PC3" "PC4" "PC5" "cell.name"
#> [1] "PC1" "PC2" "PC3" "PC4" "PC5"
#> [1] "Calculating modified PCs"
#> [1] "Adding modified PCs to Seurat object"
#> [1] "Adding rPCA loadings to Seurat object"
pairs(GetCellEmbeddings(pbmc_small, reduction.type = 'rpca'))
pbmc_small <- RunTSNE(pbmc_small, reduction.use = 'rpca', dims.use = pcs.use,perplexity=10)
Note: need to set dims.use = pcs.use
parameter or FindClusters
seems to default to using 'pca'
dimensionality reduction.
pbmc_small <- FindClusters(pbmc_small, reduction.type = 'rpca', dims.use = pcs.use, print.output = F)
TSNEPlot(pbmc_small)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.