Browse code

fix plotDimReduceModule example

zhewa authored on 24/04/2019 00:46:07
Showing 5 changed files

... ...
@@ -78,8 +78,10 @@ exportMethods(runParams)
78 78
 exportMethods(sampleLabel)
79 79
 import(Rcpp)
80 80
 import(RcppEigen)
81
+import(data.table, except = melt)
81 82
 import(foreach)
82 83
 import(ggplot2)
84
+import(grDevices)
83 85
 import(graphics)
84 86
 import(grid)
85 87
 import(gridExtra, except = c(combine))
... ...
@@ -117,6 +119,7 @@ importFrom(methods,is)
117 119
 importFrom(methods,new)
118 120
 importFrom(plyr,mapvalues)
119 121
 importFrom(reshape2,melt)
122
+importFrom(scales,brewer_pal)
120 123
 importFrom(scales,dscale)
121 124
 importFrom(scales,hue_pal)
122 125
 importFrom(stringi,stri_list2matrix)
... ...
@@ -26,7 +26,7 @@
26 26
 #' clusterDiffexpRes = differentialExpression(celdaCGSim$counts,
27 27
 #'     celdaCGMod, c1 = c(1, 2))
28 28
 #' @export
29
-#' @importFrom data.table as.data.table
29
+#' @rawNamespace import(data.table, except = melt)
30 30
 #' @importFrom MAST FromMatrix
31 31
 #' @importFrom MAST zlm
32 32
 #' @importFrom MAST summary
... ...
@@ -81,7 +81,7 @@ differentialExpression <- function(counts,
81 81
     # explicitly load library SummarizedExperiment due to MAST package
82 82
     # dependency error
83 83
     library(SummarizedExperiment)
84
-    
84
+
85 85
     sca <- suppressMessages(MAST::FromMatrix(log_normalized_mat, cdat))
86 86
     cdr2 <- colSums(SummarizedExperiment::assay(sca) > 0)
87 87
     SummarizedExperiment::colData(sca)$cngeneson <- scale(cdr2)
... ...
@@ -216,6 +216,7 @@ plotDimReduceFeature <- function(dim1,
216 216
 #'  This matrix should be the same as the one used to generate `celdaMod`.
217 217
 #' @param celdaMod Celda object of class "celda_G" or "celda_CG".
218 218
 #' @param modules Character vector. Module(s) from celda model to be plotted.
219
+#' e.g. c("1", "2").
219 220
 #' @param rescale Logical.
220 221
 #'  Whether rows of the matrix should be rescaled to [0, 1]. Default TRUE.
221 222
 #' @param size Numeric. Sets size of point on plot. Default 1.
... ...
@@ -237,7 +238,7 @@ plotDimReduceFeature <- function(dim1,
237 238
 #' plotDimReduceModule(
238 239
 #'     dim1 = celdaTsne[, 1], dim2 = celdaTsne[, 2],
239 240
 #'     counts = celdaCGSim$counts, celdaMod = celdaCGMod,
240
-#'     modules = c("L1", "L2"))
241
+#'     modules = c("1", "2"))
241 242
 #' @export
242 243
 plotDimReduceModule <-
243 244
     function(dim1,
... ...
@@ -252,6 +253,7 @@ plotDimReduceModule <-
252 253
         colorLow = "grey",
253 254
         colorMid = NULL,
254 255
         colorHigh = "blue") {
256
+
255 257
         factorized <- factorizeMatrix(celdaMod = celdaMod,
256 258
             counts = counts)
257 259
         matrix <- factorized$proportions$cell
... ...
@@ -585,6 +585,7 @@ vplayout <- function(x, y) {
585 585
 #' @importFrom gtable gtable_height
586 586
 #' @importFrom gtable gtable_width
587 587
 #' @importFrom gtable gtable_add_grob
588
+#' @import grDevices
588 589
 .heatmapMotor <- function(matrix,
589 590
         borderColor,
590 591
         cellWidth,
... ...
@@ -1218,6 +1219,7 @@ vplayout <- function(x, y) {
1218 1219
 }
1219 1220
 
1220 1221
 #' @importFrom scales dscale
1222
+#' @importFrom scales brewer_pal
1221 1223
 .generateAnnotationColours <- function(annotation,
1222 1224
     annotationColors,
1223 1225
     drop) {
... ...
@@ -1265,7 +1267,7 @@ vplayout <- function(x, y) {
1265 1267
                     factorColors <- factorColors[-ind]
1266 1268
                 } else {
1267 1269
                     annotationColors[[names(annotation)[i]]] <-
1268
-                        brewer_pal("seq", contCounter)(5)[seq(4)]
1270
+                        scales::brewer_pal("seq", contCounter)(5)[seq(4)]
1269 1271
                     contCounter <- contCounter + 1
1270 1272
                 }
1271 1273
             }
... ...
@@ -23,7 +23,8 @@ This matrix should be the same as the one used to generate `celdaMod`.}
23 23
 
24 24
 \item{celdaMod}{Celda object of class "celda_G" or "celda_CG".}
25 25
 
26
-\item{modules}{Character vector. Module(s) from celda model to be plotted.}
26
+\item{modules}{Character vector. Module(s) from celda model to be plotted.
27
+e.g. c("1", "2").}
27 28
 
28 29
 \item{rescale}{Logical.
29 30
 Whether rows of the matrix should be rescaled to [0, 1]. Default TRUE.}
... ...
@@ -61,5 +62,5 @@ celdaTsne <- celdaTsne(counts = celdaCGSim$counts,
61 62
 plotDimReduceModule(
62 63
     dim1 = celdaTsne[, 1], dim2 = celdaTsne[, 2],
63 64
     counts = celdaCGSim$counts, celdaMod = celdaCGMod,
64
-    modules = c("L1", "L2"))
65
+    modules = c("1", "2"))
65 66
 }