-
Notifications
You must be signed in to change notification settings - Fork 0
/
scRNA_GSM3215435.Rmd
117 lines (67 loc) · 2.62 KB
/
scRNA_GSM3215435.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
title: "scRNA-seq analisys Kazantseva"
output: html_document
---
Preprocessing: filtering out bad cells and normalization
UMAP + clustering
Marker selection for clusters
GSM3215435
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
if (!requireNamespace("Seurat", quietly = TRUE)) install.packages("Seurat")
if (!requireNamespace("ggplot2", quietly = TRUE)) install.packages("ggplot2")
if (!requireNamespace("MAST", quietly = TRUE)) BiocManager::install("MAST")
if (!requireNamespace("dplyr", quietly = TRUE)) install.packages("dplyr")
if (!requireNamespace("Matrix", quietly = TRUE)) install.packages("Matrix")
library(Seurat)
library(Matrix)
library(MAST)
library(ggplot2)
library(dplyr)
```
## R Markdown
```{r}
data <- Read10X("Downloads/GSM3215435/")
dim(data)
plotData <- data.frame(
umis <- colSums(data)
)
ggplot(data=plotData, aes(x=umis)) +
geom_histogram() + theme_bw()
```
```{r}
seurat <- CreateSeuratObject(data, min.cells = 10, min.features = 10)
dim(seurat)
```
```{r,message=FALSE}
seurat[["percent.mt"]] <- PercentageFeatureSet(seurat, pattern = "^MT-")
FeatureScatter(seurat, "nCount_RNA", "nFeature_RNA") + scale_x_log10() + scale_y_log10()
FeatureScatter(seurat, "nCount_RNA", "percent.mt")+scale_x_log10()
FeatureScatter(seurat, "nFeature_RNA", "percent.mt") + scale_x_log10()
```
```{r,message=FALSE}
seurat <- subset(seurat, subset = nFeature_RNA > 1000)
dim(seurat)
seurat <- SCTransform(seurat, vars.to.regress = "percent.mt", verbose = FALSE)
VariableFeaturePlot(seurat) + scale_y_log10()
top10_variable_genes <- head(VariableFeatures(seurat), 10)
VariableFeaturePlot(seurat) %>%
LabelPoints(points = top10_variable_genes, repel = TRUE) +
scale_y_log10()
seurat <- RunPCA(seurat, verbose = FALSE)
ElbowPlot(seurat, ndims = 50)
seurat <- RunUMAP(seurat, dims=1:20, verbose = FALSE)
DimPlot(seurat, reduction = "umap") + NoLegend()
#seurat <- RunTSNE(seurat, dims=1:10)
#DimPlot(seurat, reduction = "tsne") + NoLegend()
```
```{r,message=FALSE}
seurat <- FindNeighbors(seurat, dims = 1:20, verbose = FALSE)
seurat <- FindClusters(seurat, resolution=0.6, verbose = FALSE)
DimPlot(seurat, reduction = "umap", label = TRUE) + NoLegend()
FeaturePlot(seurat, c("Cd3e",'Flt3'), cols=c("grey", "red"), reduction="umap", ncol=3)
allMarkers <- FindAllMarkers(seurat, max.cells.per.ident = 100, test.use = "MAST", only.pos = T,assay = "RNA", verbose = FALSE)
goodMarkers <- allMarkers %>% group_by(cluster) %>% top_n(n = 1, wt = avg_log2FC) %>% pull(gene)
FeaturePlot(seurat, goodMarkers[6:10], cols=c("grey", "red"), reduction="umap", ncol=3)
VlnPlot(seurat, goodMarkers[6:10], pt.size = 0.1)
```