-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
434 lines (258 loc) · 13.8 KB
/
README.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# SeuratExplorer
<!-- badges: start -->
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
<!-- badges: end -->
## Why build this R package
> Currently, there is still no good tools for visualising the analysis results from ``Seurat``, when the bioinformatics analyst hands over the results to the user, if the user does not have any R language foundation, it is still difficult to retrieve the results and re-analysis on their own, and this R package is designed to help such users to visualize and explore the anaysis results. The only thing to do for such users is to configure R and Rstudio on their own computers, and then install ``SeuratExplorer``, without any other operations, an optional way is to upload the ``Seurat object`` file to a server which has been deployed with ``shinyserver`` and ``SeuratExplorer``.
> Essentially, what ``SeuratExplorer`` done is just to perform visual operations for command line tools from ``Seurat`` or other packages.
## A live demo webserver
Upload an Rds or qs2 file, with file size no more than 5GB. [Open](http://www.nibs.ac.cn:666/SeuratExplorer/), you can download a mini demo data from github [here](https://github.com/fentouxungui/SeuratExplorerServer/blob/main/inst/extdata/demo/fly/Rds-file/G101_PC20res04.rds).
## Installation
You can use codes bellow to install the latest version of ``SeuratExplorer``:
```{r eval=FALSE}
# install dependency
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("ComplexHeatmap")
# install SeuratExplorer
if(!require(devtools)){install.packages("devtools")}
install_github("fentouxungui/SeuratExplorer")
```
## Run App
```{r eval=FALSE}
library(SeuratExplorer)
launchSeuratExplorer()
```
## Introduction
### Load data
- support ``Seurat`` object saved as ``.rds`` or ``.qs2`` file.
- support data processed by ``Seurat`` V5 and older versions. it may takes a while to update ``Seurat`` object when loading data.
```{r echo = FALSE, message=FALSE, warning=FALSE, out.width="50%"}
knitr::include_graphics("inst/extdata/www/loading-before.png")
knitr::include_graphics("inst/extdata/www/loading-after.png")
```
### Cell Metadata
- support download cell metadata in ``csv`` format, which can be used to for further analysis.
```{r echo = FALSE, message=FALSE, warning=FALSE}
knitr::include_graphics("inst/extdata/www/cell-metadata.png")
```
### Dimensional Reduction Plot
- support options for **Dimension Reductions**
- support options for **Cluster Resolution**
- support **split** plots
- support adjust the height/width ratio of the plot
- support options for showing **cluster label**
- support adjust label size
- support adjust point size
- support download plot in pdf format, what you see is what you get
**Example plots:**
```{r echo = FALSE, message=FALSE, warning=FALSE, out.width="50%"}
knitr::include_graphics("inst/extdata/www/dimplot.png")
```
```{r echo = FALSE, message=FALSE, warning=FALSE, out.width="90%"}
knitr::include_graphics("inst/extdata/www/Dimplot-splited.png")
```
### Feature Plot
- support display multiple genes simultaneous, genes names are case-insensitive. Tips: paste multiple genes from excel
- support options for **Dimension Reductions**
- support **split** plots
- support change colors for the lowest expression and highest expression
- support adjust the height/width ratio of the plot
- support adjust point size
- support download plot in pdf format, what you see is what you get
**Example plots:**
```{r echo = FALSE, message=FALSE, warning=FALSE, out.width="50%"}
knitr::include_graphics("inst/extdata/www/featureplot-1-with-label.png")
```
```{r echo = FALSE, message=FALSE, warning=FALSE}
knitr::include_graphics("inst/extdata/www/featureplot-1.png")
knitr::include_graphics("inst/extdata/www/Featureplot-split.png")
```
### Violin Plot
- support display multiple genes simultaneous, genes names are case-insensitive. Tips: paste multiple genes from excel
- support options for **Cluster Resolution**
- support **split** plots
- support **stack** and **flip** plot, and color mapping selection.
- support adjust point size and transparency
- support adjust font size on x and y axis
- support adjust the height/width ratio of the plot
- support download plot in pdf format, what you see is what you get
**Example plots:**
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/Vlnplot-1.png")
knitr::include_graphics("inst/extdata/www/Vlnplot-2.png")
knitr::include_graphics("inst/extdata/www/vlnplot-splited-1.png")
knitr::include_graphics("inst/extdata/www/vlnplot-splited-2.png")
```
### Dot Plot
- support display multiple genes simultaneous, genes names are case-insensitive. Tips: paste multiple genes from excel
- support options for **Cluster Resolution** and subset clusters
- support **split** plots
- support cluster clusters
- support rotate axis and flip coordinate
- support adjust point size and transparency
- support adjust font size on x and y axis
- support adjust the height/width ratio of the plot
- support download plot in pdf format, what you see is what you get
**Example plots:**
```{r echo = FALSE, out.width="70%"}
knitr::include_graphics("inst/extdata/www/Dotplot-1.png")
```
```{r echo = FALSE, out.width="50%"}
knitr::include_graphics("inst/extdata/www/dotplot-splited-1.png")
```
### Heatmap for cell level expression
- support display multiple genes simultaneous, genes names are case-insensitive. Tips: paste multiple genes from excel
- support options for **Cluster Resolution** and reorder clusters
- support adjust font size and rotation angle of cluster label, and flip coordinate
- support adjust the height of group bar
- support adjust the gap size between groups
- support adjust the font size of gene names
- support adjust the height/width ratio of the plot
- support download plot in pdf format, what you see is what you get
**Example plots:**
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/Heatmap-1.png")
```
### Heatmap for group averaged expression
- support display multiple genes simultaneous, genes names are case-insensitive. Tips: paste multiple genes from excel
- support options for **Cluster Resolution** and reorder clusters
- support adjust font size and rotation angle of cluster label
- support adjust the font size of gene names
- support adjust the height/width ratio of the plot
- support download plot in pdf format, what you see is what you get
**Example plots:**
```{r echo = FALSE, out.width="50%"}
knitr::include_graphics("inst/extdata/www/averagedheatmap.png")
```
### Ridge Plot
- support display multiple genes simultaneous, genes names are case-insensitive. Tips: paste multiple genes from excel
- support options for **Cluster Resolution** and reorder clusters
- support adjust column numbers
- support stack plot and color mapping
- support adjust font size on x and y axis
- support adjust the height/width ratio of the plot
- support download plot in pdf format, what you see is what you get
**Example plots:**
```{r echo = FALSE, out.width="70%"}
knitr::include_graphics("inst/extdata/www/ridgeplot-1.png")
```
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/Ridgeplot-2.png")
knitr::include_graphics("inst/extdata/www/Ridgeplot-3.png")
```
### Plot Cell Percentage
- support facet
- support adjust the height/width ratio of the plot
- support download plot in pdf format, what you see is what you get
**Example plots:**
```{r echo = FALSE, out.width="50%"}
knitr::include_graphics("inst/extdata/www/cellratio-1.png")
knitr::include_graphics("inst/extdata/www/cellratio-2.png")
```
### Find Cluster Markers and DEGs Analysis
This usually takes longer, please wait patiently.Please save the results before start a new analysis, the old results will be overwritten by the new results, the results can be downloaded as ``csv`` format.
#### Support two ways
- support find markers for all clusters
- support calculate DEGs for self-defined two groups, you can subset cells before calculate DEGs between two groups, default use all cells of two groups.
You can modify part calculation parameters before a analysis.
**Screen shots:**
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/DEGs-1.png")
knitr::include_graphics("inst/extdata/www/DEGs-2.png")
knitr::include_graphics("inst/extdata/www/DEGs-3.png")
```
#### Output description
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/DEGs-4.png")
```
> [FindMarkers(object, ...)](https://satijalab.org/seurat/reference/findmarkers)
>
> A data.frame with a ranked list of putative markers as rows, and associated statistics as columns (p-values, ROC score, etc., depending on the test used (test.use)). The following columns are always present:
>
> avg_logFC: log fold-chage of the average expression between the two groups. Positive values indicate that the gene is more highly expressed in the first group
>
> pct.1: The percentage of cells where the gene is detected in the first group
>
> pct.2: The percentage of cells where the gene is detected in the second group
>
> p_val_adj: Adjusted p-value, based on bonferroni correction using all genes in the dataset
### Top Expressed Features
Highly expressed genes can reflect the main functions of cells, there two ways to do this. the first - ``Find Top Genes by Cell`` could find gene only high express in a few cells, while the second - ``Find Top Genes by Accumulated UMI counts`` is biased to find the highly expressed genes in most cells by accumulated UMI counts.
#### 1. Find Top Genes by Cell
#### How?
Step1: for each cell, find genes that has high UMI percentage, for example, if a cell has 10000 UMIs, and the ``UMI percentage cutoff`` is set to 0.01, then all genes that has more than 10000 * 0.01 = 100 UMIs is thought to be the highly expressed genes for this cell.
Step2: summary those genes for each cluster, firstly get all highly expressed genes in a cluster, some genes may has less cells, then for each gene, count cells in which this genes is highly expressed, and also calculate the mean and median UMI percentage in those highly expressed cells.
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/Find-Top-Genes-by-Cell.png")
```
#### Output description
- ``celltype``: the cluster name which is define by ``Choose A Cluster Resolution``
- ``total.cells``: total cell in this cluster
- ``Gene``: this Gene is highly expressed in at least 1 cell in this cluster
- ``total.pos.cells``: how many cells express this gene
- ``total.UMI.pct``: (all UMIs of this gene)/(total UMIs of this cluster)
- ``cut.Cells``: how many cells highly express this gene
- ``cut.pct.mean``: in those highly expressed cells, the mean expression percentage
- ``cut.pct.median``: in those highly expressed cells, the median expression percentage
#### 2. Find Top Genes by Accumulated UMI counts
for each cluster, calculate the ``top n`` highly expressed genes by accumulated UMI counts. if a cluster has less than 3 cells, this cluster will be escaped.
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/Find-Top-Genes-by-Accumulated-UMI-counts.png")
```
#### Output description
- ``CellType``: the cluster name which is define by ``Choose A Cluster Resolution``
- ``total.cells``: total cell in this cluster
- ``Gene``: the ``top n`` highly expressed genes
- ``total.pos.cells``: how many cells express this gene
- ``NormalizedAccumulatedUMICounts``: (total accumulated UMI counts) / (total cells of this cluster)
- ``PCT``: (total accumulated UMI counts) / (total UMIs of this cluster)
### Feature Summary
Summary interested features by cluster, such as the positive cell percentage and mean/median expression level.
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/gene-short-summary.png")
```
#### Output description
- ``celltype``: the cluster name which is define by ``Choose A Cluster Resolution``
- ``TotalCells``: total cell in this cluster
- ``Gene``: the input genes
- ``PCT``: the percentage of how many cells express this gene in this cluster
- ``Expr.mean``: the mean normalized expression in this cluster
- ``Expr.median``: the median normalized expression in this cluster
### Feature Correlation Analysis
Can calculate the correlation value of gene pairs within cells from a cluster, support pearson & spearman methods.
#### 3 ways to do
- ``Find Top Correlated Gene Pairs``: to find top 1000 correlated gene pairs
- ``Find Correlated Genes for A Gene``: to find the most correlated genes for input genes
- ``Calculate Correlation for A Gene List``: to calculate the correlation value for each pair of the input genes
```{r echo = FALSE}
knitr::include_graphics("inst/extdata/www/featurecorrelation.png")
```
#### Output description
```{r echo = FALSE, out.width="40%"}
knitr::include_graphics("inst/extdata/www/feature-correlation-output.png")
```
- ``GeneA``: the first gene in a Gene pair
- ``GeneB``: the second gene in a Gene pair
- ``correlation``: the correlation value
if nothing return, this is because the input genes has very low expression level, very low expressed genes will be removed before analysis.
## Key related packages
- [Hla-Lab/SeuratExplorer](https://github.com/rwcrocker/SeuratExplorer/): An interactive R shiny application for exploring scRNAseq data processed in Seurat
- [junjunlab/scRNAtoolVis](https://github.com/junjunlab/scRNAtoolVis): Some useful function to make your scRNA-seq plot more beautiful
- [rstudio/shiny-server](https://github.com/rstudio/shiny-server): Shiny Server is a server program that makes Shiny applications available over the web
## Session Info
```{r echo = FALSE}
sessionInfo()
```