Browse code

color of scatterplot adjustable with colorLow, etc. arguments

Yusuke Koga authored on 22/06/2020 16:34:02
Showing 6 changed files

... ...
@@ -156,7 +156,9 @@ runDoubletFinder <- function(inSCE,
156 156
       ))
157 157
       result <- suppressMessages(Seurat::RunUMAP(result,
158 158
                                                  dims = 1:10,
159
-                                                 verbose = verbose))
159
+                                                 verbose = verbose,
160
+                                                 umap.method = "umap-learn",
161
+                                                 metric = "correlation"))
160 162
 
161 163
       seuratDims <- Seurat::Embeddings(result, reduction = "umap")
162 164
       umapDims[sceSampleInd, 1] <- seuratDims[,1]
... ...
@@ -25,6 +25,15 @@
25 25
 #'  Default NULL.
26 26
 #' @param dotSize Size of dots. Default 2.
27 27
 #' @param transparency Transparency of the dots, values will be 0-1. Default 1.
28
+#' @param colorLow Character. A color available from `colors()`.
29
+#'  The color will be used to signify the lowest values on the scale.
30
+#'  Default 'white'.
31
+#' @param colorMid Character. A color available from `colors()`.
32
+#'  The color will be used to signify the midpoint on the scale.
33
+#'  Default 'gray'.
34
+#' @param colorHigh Character. A color available from `colors()`.
35
+#'  The color will be used to signify the highest values on the scale.
36
+#'  Default 'blue'.
28 37
 #' @param defaultTheme Removes grid in plot and sets axis title size to 10
29 38
 #'  when TRUE. Default TRUE.
30 39
 #' @param title Title of plot. Default NULL.
... ...
@@ -48,6 +57,9 @@
48 57
                        binLabel = NULL,
49 58
                        dotSize = 2,
50 59
                        transparency = 1,
60
+                       colorLow = "white",
61
+                       colorMid = "gray",
62
+                       colorHigh = "blue",
51 63
                        defaultTheme = TRUE,
52 64
                        title = NULL,
53 65
                        titleSize = 15,
... ...
@@ -137,6 +149,14 @@
137 149
     if (!is.null(colorBySub)) {
138 150
       g <- g + ggplot2::aes_string(color = "color")
139 151
     }
152
+    if (class(colorBySub) == "numeric"){
153
+        g <- g + ggplot2::scale_color_gradient2(
154
+            low = colorLow,
155
+            mid = colorMid,
156
+            high = colorHigh,
157
+            aesthetics = "colour",
158
+            midpoint = mean(colorBySub))
159
+    }
140 160
     if (!is.null(shape)) {
141 161
       g <- g + ggplot2::aes_string(shape = "shape") +
142 162
         ggplot2::labs(shape = shape)
... ...
@@ -227,6 +247,15 @@
227 247
 #'  Default NULL.
228 248
 #' @param dotSize Size of dots. Default 2.
229 249
 #' @param transparency Transparency of the dots, values will be 0-1. Default 1.
250
+#' @param colorLow Character. A color available from `colors()`.
251
+#'  The color will be used to signify the lowest values on the scale.
252
+#'  Default 'white'.
253
+#' @param colorMid Character. A color available from `colors()`.
254
+#'  The color will be used to signify the midpoint on the scale.
255
+#'  Default 'gray'.
256
+#' @param colorHigh Character. A color available from `colors()`.
257
+#'  The color will be used to signify the highest values on the scale.
258
+#'  Default 'blue'.
230 259
 #' @param defaultTheme adds grid to plot when TRUE. Default TRUE.
231 260
 #' @param title Title of plot. Default NULL.
232 261
 #' @param titleSize Size of title of plot. Default 15.
... ...
@@ -263,6 +292,9 @@ plotSCEDimReduceColData <- function(inSCE,
263 292
                                     binLabel = NULL,
264 293
                                     dotSize = 2,
265 294
                                     transparency = 1,
295
+                                    colorLow = "white",
296
+                                    colorMid = "gray",
297
+                                    colorHigh = "blue",
266 298
                                     defaultTheme = TRUE,
267 299
                                     title = NULL,
268 300
                                     titleSize = 15,
... ...
@@ -285,6 +317,9 @@ plotSCEDimReduceColData <- function(inSCE,
285 317
     binLabel = binLabel,
286 318
     dotSize = dotSize,
287 319
     transparency = transparency,
320
+    colorLow = colorLow,
321
+    colorMid = colorMid,
322
+    colorHigh = colorHigh,
288 323
     defaultTheme = defaultTheme,
289 324
     title = title,
290 325
     titleSize = titleSize,
... ...
@@ -321,6 +356,15 @@ plotSCEDimReduceColData <- function(inSCE,
321 356
 #'  Default NULL.
322 357
 #' @param dotSize Size of dots. Default 2.
323 358
 #' @param transparency Transparency of the dots, values will be 0-1. Default 1.
359
+#' @param colorLow Character. A color available from `colors()`.
360
+#'  The color will be used to signify the lowest values on the scale.
361
+#'  Default 'white'.
362
+#' @param colorMid Character. A color available from `colors()`.
363
+#'  The color will be used to signify the midpoint on the scale.
364
+#'  Default 'gray'.
365
+#' @param colorHigh Character. A color available from `colors()`.
366
+#'  The color will be used to signify the highest values on the scale.
367
+#'  Default 'blue'.
324 368
 #' @param defaultTheme adds grid to plot when TRUE. Default TRUE.
325 369
 #' @param title Title of plot. Default NULL.
326 370
 #' @param titleSize Size of title of plot. Default 15.
... ...
@@ -347,6 +391,9 @@ plotSCEDimReduceFeatures <- function(inSCE,
347 391
                                      binLabel = NULL,
348 392
                                      dotSize = 2,
349 393
                                      transparency = 1,
394
+                                     colorLow = "white",
395
+                                     colorMid = "gray",
396
+                                     colorHigh = "blue",
350 397
                                      defaultTheme = TRUE,
351 398
                                      title = NULL,
352 399
                                      titleSize = 15,
... ...
@@ -366,6 +413,9 @@ plotSCEDimReduceFeatures <- function(inSCE,
366 413
     colorBy = counts,
367 414
     shape = shape,
368 415
     transparency = 1,
416
+    colorLow = colorLow,
417
+    colorMid = colorMid,
418
+    colorHigh = colorHigh,
369 419
     reducedDimName = reducedDimName,
370 420
     xlab = xlab,
371 421
     ylab = ylab,
... ...
@@ -416,6 +466,15 @@ plotSCEDimReduceFeatures <- function(inSCE,
416 466
 #'  Default NULL.
417 467
 #' @param dotSize Size of dots. Default 2.
418 468
 #' @param transparency Transparency of the dots, values will be 0-1. Default 1.
469
+#' @param colorLow Character. A color available from `colors()`.
470
+#'  The color will be used to signify the lowest values on the scale.
471
+#'  Default 'white'.
472
+#' @param colorMid Character. A color available from `colors()`.
473
+#'  The color will be used to signify the midpoint on the scale.
474
+#'  Default 'gray'.
475
+#' @param colorHigh Character. A color available from `colors()`.
476
+#'  The color will be used to signify the highest values on the scale.
477
+#'  Default 'blue'.
419 478
 #' @param defaultTheme adds grid to plot when TRUE. Default TRUE.
420 479
 #' @param title Title of plot. Default NULL.
421 480
 #' @param titleSize Size of title of plot. Default 15.
... ...
@@ -445,6 +504,9 @@ plotSCEScatter <- function(inSCE,
445 504
                            binLabel = NULL,
446 505
                            dotSize = 2,
447 506
                            transparency = 1,
507
+                           colorLow = "white",
508
+                           colorMid = "gray",
509
+                           colorHigh = "blue",
448 510
                            defaultTheme = TRUE,
449 511
                            title = NULL,
450 512
                            titleSize = 15,
... ...
@@ -491,6 +553,9 @@ plotSCEScatter <- function(inSCE,
491 553
     binLabel = binLabel,
492 554
     dotSize = dotSize,
493 555
     transparency = transparency,
556
+    colorLow = colorLow,
557
+    colorMid = colorMid,
558
+    colorHigh = colorHigh,
494 559
     defaultTheme = defaultTheme,
495 560
     title = title,
496 561
     titleSize = titleSize,
... ...
@@ -20,6 +20,9 @@
20 20
   binLabel = NULL,
21 21
   dotSize = 2,
22 22
   transparency = 1,
23
+  colorLow = "white",
24
+  colorMid = "gray",
25
+  colorHigh = "blue",
23 26
   defaultTheme = TRUE,
24 27
   title = NULL,
25 28
   titleSize = 15,
... ...
@@ -68,6 +71,18 @@ Default NULL.}
68 71
 
69 72
 \item{transparency}{Transparency of the dots, values will be 0-1. Default 1.}
70 73
 
74
+\item{colorLow}{Character. A color available from `colors()`.
75
+The color will be used to signify the lowest values on the scale.
76
+Default 'white'.}
77
+
78
+\item{colorMid}{Character. A color available from `colors()`.
79
+The color will be used to signify the midpoint on the scale.
80
+Default 'gray'.}
81
+
82
+\item{colorHigh}{Character. A color available from `colors()`.
83
+The color will be used to signify the highest values on the scale.
84
+Default 'blue'.}
85
+
71 86
 \item{defaultTheme}{Removes grid in plot and sets axis title size to 10
72 87
 when TRUE. Default TRUE.}
73 88
 
... ...
@@ -19,6 +19,9 @@ plotSCEDimReduceColData(
19 19
   binLabel = NULL,
20 20
   dotSize = 2,
21 21
   transparency = 1,
22
+  colorLow = "white",
23
+  colorMid = "gray",
24
+  colorHigh = "blue",
22 25
   defaultTheme = TRUE,
23 26
   title = NULL,
24 27
   titleSize = 15,
... ...
@@ -66,6 +69,18 @@ Default NULL.}
66 69
 
67 70
 \item{transparency}{Transparency of the dots, values will be 0-1. Default 1.}
68 71
 
72
+\item{colorLow}{Character. A color available from `colors()`.
73
+The color will be used to signify the lowest values on the scale.
74
+Default 'white'.}
75
+
76
+\item{colorMid}{Character. A color available from `colors()`.
77
+The color will be used to signify the midpoint on the scale.
78
+Default 'gray'.}
79
+
80
+\item{colorHigh}{Character. A color available from `colors()`.
81
+The color will be used to signify the highest values on the scale.
82
+Default 'blue'.}
83
+
69 84
 \item{defaultTheme}{adds grid to plot when TRUE. Default TRUE.}
70 85
 
71 86
 \item{title}{Title of plot. Default NULL.}
... ...
@@ -19,6 +19,9 @@ plotSCEDimReduceFeatures(
19 19
   binLabel = NULL,
20 20
   dotSize = 2,
21 21
   transparency = 1,
22
+  colorLow = "white",
23
+  colorMid = "gray",
24
+  colorHigh = "blue",
22 25
   defaultTheme = TRUE,
23 26
   title = NULL,
24 27
   titleSize = 15,
... ...
@@ -64,6 +67,18 @@ Default NULL.}
64 67
 
65 68
 \item{transparency}{Transparency of the dots, values will be 0-1. Default 1.}
66 69
 
70
+\item{colorLow}{Character. A color available from `colors()`.
71
+The color will be used to signify the lowest values on the scale.
72
+Default 'white'.}
73
+
74
+\item{colorMid}{Character. A color available from `colors()`.
75
+The color will be used to signify the midpoint on the scale.
76
+Default 'gray'.}
77
+
78
+\item{colorHigh}{Character. A color available from `colors()`.
79
+The color will be used to signify the highest values on the scale.
80
+Default 'blue'.}
81
+
67 82
 \item{defaultTheme}{adds grid to plot when TRUE. Default TRUE.}
68 83
 
69 84
 \item{title}{Title of plot. Default NULL.}
... ...
@@ -21,6 +21,9 @@ plotSCEScatter(
21 21
   binLabel = NULL,
22 22
   dotSize = 2,
23 23
   transparency = 1,
24
+  colorLow = "white",
25
+  colorMid = "gray",
26
+  colorHigh = "blue",
24 27
   defaultTheme = TRUE,
25 28
   title = NULL,
26 29
   titleSize = 15,
... ...
@@ -74,6 +77,18 @@ Default NULL.}
74 77
 
75 78
 \item{transparency}{Transparency of the dots, values will be 0-1. Default 1.}
76 79
 
80
+\item{colorLow}{Character. A color available from `colors()`.
81
+The color will be used to signify the lowest values on the scale.
82
+Default 'white'.}
83
+
84
+\item{colorMid}{Character. A color available from `colors()`.
85
+The color will be used to signify the midpoint on the scale.
86
+Default 'gray'.}
87
+
88
+\item{colorHigh}{Character. A color available from `colors()`.
89
+The color will be used to signify the highest values on the scale.
90
+Default 'blue'.}
91
+
77 92
 \item{defaultTheme}{adds grid to plot when TRUE. Default TRUE.}
78 93
 
79 94
 \item{title}{Title of plot. Default NULL.}