forked from dtm2451/dittoSeq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickStart_image-build.rmd
203 lines (169 loc) · 5.73 KB
/
QuickStart_image-build.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
---
title: Quick Start
author:
- name: Daniel Bunis
affiliation: Bakar Computational Health Sciences Institute, University of California San Francisco, San
email: [email protected]
date: "November 10th, 2019"
output:
BiocStyle::html_document:
toc_float: true
package: dittoSeq
bibliography: ref.bib
vignette: >
%\VignetteIndexEntry{Annotating scRNA-seq data}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, echo=FALSE, results="hide", message=FALSE}
knitr::opts_chunk$set(error=FALSE, message=FALSE, warning=FALSE)
library(BiocStyle)
```
```{r}
library(dittoSeq)
# library(Seurat)
```
```{r}
# For working with scRNAseq data, works directly with Seurat and SingleCellExperiment objects
seurat <- Seurat::pbmc_small
dittoPlot("CD14", seurat, group.by = "ident")
sce <- Seurat::as.SingleCellExperiment(seurat)
dittoBarPlot("ident", sce, group.by = "RNA_snn_res.0.8")
```
```{r}
# For working with bulk RNAseq data, first load your data into a format that dittoSeq quickly understands
# deseq2 <- importDESeq2()
# edger <- importEdgeR()
# limma.voom <- importEdgeR()
myRNA <- RNAseq_mock
# Add metadata
c(1:10)
dittoDimPlot("Gene1", myRNA, size = 3)
```
### Helper Functions
Quickly determine metadatas, genes, and dimensionality reductions that can be used for making plots with universal helper functions:
```{r}
getMetas(seurat)
isMeta("nCount_RNA", seurat)
getGenes(myRNA)
isGene("CD3E", myRNA)
getReductions(sce)
# View them with these:
gene("CD3E", seurat, data.type = "raw")
meta("groups", seurat)
meta.levels("groups", seurat)
```
### There are many dittoSeq Plot Types
**Intuitive default adjustments generally allow creation of immediately useable plots.**
```{r}
# dittoDimPlot
p1 <- dittoDimPlot("ident", seurat, size = 3)
p2 <- dittoDimPlot("CD3E", seurat, size = 3)
png("Misc/QuickStart1_Dim.png", w = 700, h = 300)
gridExtra::grid.arrange(grobs = list(p1, p2), ncol= 2)
dev.off()
```
![](Misc/QuickStart1_Dim.png)
```{r}
# dittoBarPlot
p3 <- dittoBarPlot("ident", seurat, group.by = "RNA_snn_res.0.8")
p4 <- dittoBarPlot("ident", seurat, group.by = "RNA_snn_res.0.8",
scale = "count")
png("Misc/QuickStart2_Bar.png", w = 700, h = 300)
gridExtra::grid.arrange(grobs = list(p3, p4), ncol = 2)
dev.off()
```
![](Misc/QuickStart2_Bar.png)
```{r}
# dittoPlot
p1 <- dittoPlot("CD3E", seurat, group.by = "ident")
p2 <- dittoBoxPlot("CD3E", seurat, group.by = "ident",
plots = c("boxplot", "jitter"))
p3 <- dittoRidgePlot("CD3E", seurat, group.by = "ident",
plots = c("ridgeplot", "jitter"))
png("Misc/QuickStart3_Plot.png", w = 700, h = 200)
gridExtra::grid.arrange(grobs = list(p1,p2,p3), ncol = 3)
dev.off()
```
![](Misc/QuickStart3_Plot.png)
```{r}
# dittoHeatmap
hm1 <- dittoHeatmap(genes = getGenes(seurat)[1:20], seurat)
hm2 <- dittoHeatmap(genes = getGenes(seurat)[1:20], seurat,
annotation.metas = c("groups", "ident"),
scaled.to.max = TRUE,
show.colnames = FALSE)
# Turning off cell clustering can be necessary for many cell scRNAseq
dittoHeatmap(genes = getGenes(seurat)[1:20], seurat,
cluster_cols = FALSE)
png("Misc/QuickStart4_Heatmap.png", w = 700, h = 350)
gridExtra::grid.arrange(grobs = list(hm1[[4]],hm2[[4]]), ncol = 2)
dev.off()
```
![](Misc/QuickStart4_Heatmap.png)
```{r}
# dittoScatterPlot
p1 <- dittoScatterPlot(
x.var = "CD3E", y.var = "CD14",
color.var = "ident", shape.var = "RNA_snn_res.0.8",
object = seurat,
size = 3)
p2 <- dittoScatterPlot(
x.var = "nCount_RNA", y.var = "nFeature_RNA",
color.var = "percent.mt",
object = sce,
size = 1.5)
png("Misc/QuickStart5_Scatter.png", w = 700, h = 300)
gridExtra::grid.arrange(grobs = list(p1,p2), ncol = 2)
dev.off()
```
![](Misc/QuickStart5_Scatter.png)
```{r}
# Also multi-plotters:
# multi_dittoDimPlot (multiple, in an array)
# multi_dittoDimPlotVaryCells (multiple, in an array, but showing only certain
# cells in each plot)
# multi_dittoPlot (multiple, in an array)
# dittoPlot_VarsAcrossGroups (multiple genes or metadata as the jitterpoints (and
# other representations), summarized across groups by mean, median, ..., )
```
**Many adjustments can be made with simple additional inputs:**
Many adjustments to how data is reresented are within the examples above. See documentation for more! Also,
- DEFAULTing: Set `DEFAULT <- object_name` to elinate the need to type `object = object_name` except when switching between multiple objects.
- All Titles are adjustable.
- Easily subset the cells or samples shown with `cells.use`
- Colors can be adjusted easily.
- Underlying data can be output.
- plotly hovering can be added.
- Many more! (Legends removal, label rotation, labels' and groupings' names, ...)
```{r}
DEFAULT <- "seurat"
p1 <- dittoBarPlot("ident", group.by = "RNA_snn_res.0.8",
main = "Starters",
sub = "By Type",
xlab = NULL,
ylab = "Generation 1",
x.labels = c("Ash", "Misty"),
legend.title = "Types",
var.labels.rename = c("Fire", "Water", "Grass"),
x.labels.rotate = FALSE)
p2 <- dittoBarPlot("ident", group.by = "RNA_snn_res.0.8",
cells.use = meta("ident")!=1,
sub = "Cell / Sample Subsetting")
p3 <- dittoBarPlot("ident", group.by = "RNA_snn_res.0.8",
colors = c(3,1,2),
sub = "Color Order Change") #Just changes the color order, probably most useful for dittoDimPlots
p4 <- dittoBarPlot("ident", seurat, group.by = "RNA_snn_res.0.8",
color.panel = c("red", "orange", "purple"),
sub = "Colors Change")
png("Misc/QuickStart6_Customizations.png", w = 700, h = 400)
gridExtra::grid.arrange(grobs = list(p1,p2,p3,p4), ncol = 2)
dev.off()
```
![](Misc/QuickStart5_Scatter.png)
```
dittoBarPlot("ident", group.by = "RNA_snn_res.0.8",
data.out = TRUE)
dittoBarPlot("ident", group.by = "RNA_snn_res.0.8",
do.hover = TRUE)
```