Guided Clustering Tutorial, Single cell data analysis by R studio 1편
[Seurat] Guided Clustering Tutorial, Single cell data analysis by R studio
안녕하세요, 꿈꾸는 약사입니다. 이번에는 R을 이용한 Single cell analysis를 seurat library를 이용해서 진행하는 tutorial에 대해 공부해보겠습니다. 준비물 : R, R studio, R tools(Windows 사용자만) 설치 S..
pharm-dreamer.tistory.com
안녕하세요, 꿈꾸는 약사입니다. Seurat tutorial 1편에 이어서 2편 진행하도록 하겠습니다.
목차는 오른쪽에 있습니다.
Perform linear dimensional reduction
# Scaling된 data에 대해 PCA analysis
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))
Visualization method1. VizDimLoadings
# Visualize Dimensional Reduction genes
# Seurat object = pbmc
# dims = Number of dimensions to display
# reduction = Reduction technique to visualize results for
VizDimLoadings(pbmc, dims = 1:2, reduction = "pca")
# 실행 결과
Visualization method 2.Dimplot
# Dimensional reduction plot
# Seurat object = pbmc
# reduction = Which dimensionality reduction to use. If not specified, first searches for umap, then tsne, then pca
DimPlot(pbmc, reduction = "pca")
# 실행 결과
Visualization method 3.DimHeatmap
# Dimensional reduction heatmap
# Seurat object = pbmc
# dims = Dimensions to plot
# cells = A list of cells to plot. If numeric, just plots the top cells.
# balanced = Plot an equal number of genes with both + and - scores.
DimHeatmap(pbmc, dims = 1, cells = 500, balanced = TRUE)
# 실행 결과
Determine the ‘dimensionality’ of the dataset
# 연관된 특성 set에 따라 'metafeature'를 대표할 수 있는 Cell cluster을 grouping
# null distribution을 계속해서 재생산함에 따라 significant P value 갖는 clustering 형성하도록 함
# 오랜 시간 걸릴 수 있으나 ElbowPlot()로 연산시간 줄일 수 있음
# num.replicate = Number of replicate samplings to perform
# dims = Which dimensions to examine
pbmc <- JackStraw(pbmc, num.replicate = 100)
pbmc <- ScoreJackStraw(pbmc, dims = 1:20)
# JackStrawPlot()으로 각각의 Principle components(이하 PCs)에서 p value distribution을 visulaize
JackStrawPlot(pbmc, dims = 1:15)
# 실행 결과
# Alternative method Elbowplot()은 PCs에 대해 variance 기반으로 ranking
ElbowPlot(pbmc)
# 실행 결과
# 과도한 dimensionality 감소는 연관성을 갖지 않는 data subset 또한 연관지어 보이는 오류를 범할 수 있음
# 그렇다고 PC 반복 횟수를 줄이면 유의미한 상관 관계에 놓여 있는 data set 또한 관계성을 찾지 못할 수 있음
Cluster the cells
# PCA 공간 상에서의 local neiborhoods간 overlapping을 opitimize
# clustering analysis에 쓰인 distance metric은 똑같이 써줌(based on previously identified PCs)
pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)
Run non-linear dimensional reduction (UMAP/tSNE)
# non-linear dimensional reduction technieques tSNE, UMAP
pbmc <- RunUMAP(pbmc, dims = 1:10)
# UMAP화 시킨 PC를 Dimplot으로 visualize
DimPlot(pbmc, reduction = "umap")
# 실행 결과
# 이전의 step들을 rerun하지 않고도 지금까지의 data를 저장해서 나중에 불러올 수 있도록 함
saveRDS(pbmc, file = "D:/SNU/이유정 - 4 SNU Pharmacy data/1 individual data folder/Su-Yeong/9. Seurat/seurat tutorial.rds")