#Using sctransform in Seurat
##Tutorial
##packages
library(Seurat)
library(ggplot2)
library(sctransform)
#Load Data and Create Seurat Object
pbmc.data <- Read10X(data.dir = "C:/Users/evrajadh/Documents/RBook/filtered_gene_bc_matrices/hg19/")
#"C:\Users\evrajadh\Documents\RBook\filtered_gene_bc_matrices\hg19"
pbmc <- CreateSeuratObject(counts = pbmc.data)
Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')
head(pbmc)
View(pbmc)
#Store mitochondria percentage in object meta data
pbmc <- PercentageFeatureSet(pbmc, pattern = "^MT-", col.name = "percent.mt")
#THIS STORES A NEW COLUMN IN METADATA (with nCount_RNA and nFeature_RNA)
#run sctransform
#This covers NORMALIZE, SCALE, and FindVariableFeatures
pbmc <- SCTransform(pbmc, vars.to.regress = "percent.mt", verbose=F)
head(VariableFeatures(pbmc))
[1] "S100A9" "GNLY" "LYZ" "S100A8" "NKG7" "FTL"
VariableFeatures(pbmc)[1:10]
[1] "S100A9" "GNLY" "LYZ" "S100A8" "NKG7" "FTL" "GZMB" "IGLL5" "FTH1" "CCL5"
interesting_gene_names <- VariableFeatures(pbmc)[1:100]
head(interesting_gene_names)
[1] "S100A9" "GNLY" "LYZ" "S100A8" "NKG7" "FTL"
#Perform dimensionality reduction by PCA and UMAP embedding (workflow for visualization and clustering
pbmc <- RunPCA(pbmc, verbose=F)
ElbowPlot(pbmc)
pbmc <- RunUMAP(pbmc, dims = 1:30, verbose=F)
pbmc <- FindNeighbors(pbmc, dims = 1:30)
Computing nearest neighbor graph
Computing SNN
pbmc <- FindClusters(pbmc)
Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
Number of nodes: 2700
Number of edges: 111035
Running Louvain algorithm...
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Maximum modularity in 10 random starts: 0.8342
Number of communities: 12
Elapsed time: 0 seconds
DimPlot(pbmc, label=T)
DimPlot(pbmc, dims = c(2,1), label=T)