Prepare data
Load counts
pbmc.data <- Read10X( "/home/idies/workspace/c_moor_data/pbmc3k/filtered_gene_bc_matrices/hg19/" )
pbmc <- CreateSeuratObject( pbmc.data, min.cells = 3, min.features = 200 )
Feature names cannot have underscores ('_'), replacing with dashes ('-')
pbmc
An object of class Seurat
13714 features across 2700 samples within 1 assay
Active assay: RNA (13714 features, 0 variable features)
Normalize
pbmc <- NormalizeData( pbmc )
Performing log-normalization
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Find variable genes
pbmc <- FindVariableFeatures( pbmc )
Calculating gene variances
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Calculating feature variances of standardized and clipped values
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
top10 <- head( VariableFeatures(pbmc), 10 )
plot1 <- VariableFeaturePlot( pbmc )
LabelPoints( plot1, points = top10, repel=TRUE )
When using repel, set xnudge and ynudge to 0 for optimal results
Scale
all.genes <- rownames( pbmc )
pbmc <- ScaleData( pbmc, features=all.genes, verbose=FALSE )
PCA
pbmc <- RunPCA( pbmc, verbose=FALSE )
VizDimLoadings( pbmc, dims=1:2 )
Cluster
pbmc <- FindNeighbors( pbmc, dims=1:10 )
Computing nearest neighbor graph
Computing SNN
pbmc <- FindClusters( pbmc, resolution=0.5 )
Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
Number of nodes: 2700
Number of edges: 97892
Running Louvain algorithm...
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Maximum modularity in 10 random starts: 0.8719
Number of communities: 9
Elapsed time: 0 seconds
UMAP
pbmc <- RunUMAP( pbmc, dims=1:10 )
The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric
To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation'
This message will be shown once per session21:31:41 UMAP embedding parameters a = 0.9922 b = 1.112
21:31:41 Read 2700 rows and found 10 numeric columns
21:31:41 Using Annoy for neighbor search, n_neighbors = 30
21:31:41 Building Annoy index with metric = cosine, n_trees = 50
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
21:31:42 Writing NN index file to temp file /tmp/RtmprNLYRG/file14275bf786a
21:31:42 Searching Annoy index using 1 thread, search_k = 3000
21:31:44 Annoy recall = 100%
21:31:45 Commencing smooth kNN distance calibration using 1 thread
21:31:47 Initializing from normalized Laplacian + noise
21:31:47 Commencing optimization for 500 epochs, with 107868 positive edges
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
21:31:54 Optimization finished
Find markers
Detect genes
pbmc.markers <- FindAllMarkers(
pbmc, only.pos=TRUE,
min.pct=0.25, logfc.threshold=0.25,
verbose=FALSE
)
Summarize
pbmc.markers %>%
group_by( cluster ) %>%
top_n( n=2, wt=avg_log2FC
)
Violin plot
VlnPlot( pbmc, features=c( "MS4A1", "CD79A" ) )
Feature plot
FeaturePlot( pbmc, features=c( "MS4A1", "GNLY", "CD3E", "CD14", "FCER1A", "FCGR3A", "LYZ", "PPBP", "CD8A" ) )
Label clusters
new.cluster.ids <- c( "Naive CD4 T", "CD14+ Mono", "Memory CD4 T", "B", "CD8 T", "FCGR3A+ Mono", "NK", "DC", "Platelet" )
names( new.cluster.ids ) <- levels( pbmc )
pbmc <- RenameIdents( pbmc, new.cluster.ids )
DimPlot( pbmc, reduction="umap", label=TRUE, pt.size=0.5 ) + NoLegend()
LS0tCnRpdGxlIDogIlRlc3QgU2V1cmF0IG9uIFNjaVNlcnZlciIKYXV0aG9yOiAiRnJlZGVyaWNrIEogVGFuIgpkYXRlICA6ICIxOSBNYXJjaCAyMDIxIgpvdXRwdXQ6IAogIGh0bWxfbm90ZWJvb2s6CiAgICB0b2M6IHRydWUKICAgIHRvY19mbG9hdDogdHJ1ZQotLS0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