Browse code

Fixed warnings from R CMD check. Mostly fixing documenation

Joshua D. Campbell authored on 29/01/2020 03:48:26
Showing 11 changed files

... ...
@@ -2,3 +2,5 @@
2 2
 ^\.Rproj\.user$
3 3
 ^CONDUCT\.md$
4 4
 .travis.yml
5
+NOTICE
6
+_pkgdown.yml
... ...
@@ -50,13 +50,13 @@ Imports:
50 50
     scater (>= 1.14.4),
51 51
     scran,
52 52
     SingleCellExperiment,
53
-    dbscan
53
+    dbscan,
54
+    DelayedArray
54 55
 Suggests:
55 56
     testthat,
56 57
     knitr,
57 58
     roxygen2,
58 59
     rmarkdown,
59
-    corrplot,
60 60
     Matrix,
61 61
     biomaRt,
62 62
     covr,
... ...
@@ -58,6 +58,10 @@
58 58
 #'  Default TRUE.
59 59
 #' @param showNamesCell Logical. Specifies if cell names should be shown.
60 60
 #'  Default FALSE.
61
+#' @param rowGroupOrder Vector. Specifies the order of feature clusters when 
62
+#'  semisupervised clustering is performed on the \code{y} labels.
63
+#' @param colGroupOrder Vector. Specifies the order of cell clusters when 
64
+#'  semisupervised clustering is performed on the \code{z} labels.
61 65
 #' @param hclustMethod Character. Specifies the method to use for the 'hclust'
62 66
 #'  function. See `?hclust` for possible values. Default "ward.D2".
63 67
 #' @param treeheightFeature Numeric. Width of the feature dendrogram. Set to 0
... ...
@@ -79,8 +83,6 @@
79 83
 plotHeatmap <- function(counts,
80 84
     z = NULL,
81 85
     y = NULL,
82
-    rowGroupOrder = NULL,
83
-    colGroupOrder = NULL,
84 86
     scaleRow = scale,
85 87
     trim = c(-2, 2),
86 88
     featureIx = NULL,
... ...
@@ -101,6 +103,8 @@ plotHeatmap <- function(counts,
101 103
     annotationNamesCell = TRUE,
102 104
     showNamesFeature = FALSE,
103 105
     showNamesCell = FALSE,
106
+    rowGroupOrder = NULL,
107
+    colGroupOrder = NULL,
104 108
     hclustMethod = "ward.D2",
105 109
     treeheightFeature = ifelse(clusterFeature, 50, 0),
106 110
     treeheightCell = ifelse(clusterCell, 50, 0),
... ...
@@ -45,6 +45,7 @@
45 45
 #' @param logfile Character. Messages will be redirected to a file named
46 46
 #'  `logfile`. If NULL, messages will be printed to stdout.  Default NULL.
47 47
 #' @param verbose Logical. Whether to print log messages. Default TRUE.
48
+#' @param ... For the generic, further arguments to pass to each method.
48 49
 #'
49 50
 #' @return If \code{x} is a matrix-like object, a list will be returned
50 51
 #' with the following items:
... ...
@@ -153,7 +154,7 @@ setMethod("decontX", "SingleCellExperiment", function(x,
153 154
   ## Save the rest of the result object into metadata
154 155
   decontXcounts(x) <- result$decontXcounts
155 156
   result$decontXcounts <- NULL
156
-  metadata(x)$decontX <- result
157
+  S4Vectors::metadata(x)$decontX <- result
157 158
 
158 159
   return(x)
159 160
 })
... ...
@@ -208,12 +209,27 @@ SET_FUN <- function(exprs_values, ...) {
208 209
   }
209 210
 }
210 211
 
212
+
213
+
214
+#' @title Get or set decontaminated counts matrix
215
+#'
216
+#' @description Gets or sets the decontaminated counts matrix from a
217
+#' a \linkS4class{SingleCellExperiment} object.
218
+#' @name decontXcounts
219
+#' @param object A \linkS4class{SingleCellExperiment} object.
220
+#' @param value A matrix to save as an assay called \code{decontXcounts} 
221
+#' @param ... For the generic, further arguments to pass to each method.
222
+#' @seealso \code{\link{assay}} and \code{\link{assay<-}}
223
+NULL
224
+
211 225
 #' @export
226
+#' @rdname decontXcounts
212 227
 setGeneric("decontXcounts", function(object, ...) {
213 228
   standardGeneric("decontXcounts")
214 229
 })
215 230
 
216 231
 #' @export
232
+#' @rdname decontXcounts
217 233
 setGeneric("decontXcounts<-", function(object, ..., value) {
218 234
   standardGeneric("decontXcounts<-")
219 235
 })
... ...
@@ -339,7 +355,7 @@ setReplaceMethod(
339 355
         append = TRUE,
340 356
         verbose = verbose
341 357
       )
342
-      countsBat <- as(countsBat, "dgCMatrix")
358
+      countsBat <- methods::as(countsBat, "dgCMatrix")
343 359
     }
344 360
 
345 361
 
... ...
@@ -440,19 +456,19 @@ setReplaceMethod(
440 456
     ## Determine class of seed in DelayedArray
441 457
     seed.class <- unique(DelayedArray::seedApply(counts, class))[[1]]
442 458
     if (seed.class == "HDF5ArraySeed") {
443
-      returnResult$decontXcounts <- as(returnResult$decontXcounts, "HDF5Matrix")
459
+      returnResult$decontXcounts <- methods::as(returnResult$decontXcounts, "HDF5Matrix")
444 460
     } else {
445
-      if (isTRUE(canCoerce(returnResult$decontXcounts, seed.class))) {
446
-        returnResult$decontXcounts <- as(returnResult$decontXcounts, seed.class)
461
+      if (isTRUE(methods::canCoerce(returnResult$decontXcounts, seed.class))) {
462
+        returnResult$decontXcounts <- methods::as(returnResult$decontXcounts, seed.class)
447 463
       }
448 464
     }
449 465
     returnResult$decontXcounts <-
450 466
       DelayedArray::DelayedArray(returnResult$decontXcounts)
451 467
   } else {
452 468
     try({
453
-        if (canCoerce(returnResult$decontXcounts, class(counts))) {
469
+        if (methods::canCoerce(returnResult$decontXcounts, class(counts))) {
454 470
           returnResult$decontXcounts <-
455
-            as(returnResult$decontXcounts, class(counts))
471
+            methods::as(returnResult$decontXcounts, class(counts))
456 472
         }
457 473
       },
458 474
       silent = TRUE
... ...
@@ -152,7 +152,8 @@ plotDendro <- function(decisionTree,
152 152
     suppressMessages(dendroP <- ggdendro::ggdendrogram(dendro) +
153 153
             ggplot2::geom_label(
154 154
                 data = dendSegsLabelled,
155
-                ggplot2::aes(x = xend, y = y, label = label),
155
+                ggplot2::aes(x = dendSegsLabelled$xend, y = dendSegsLabelled$y,
156
+                             label = dendSegsLabelled$label),
156 157
                 size = boxSize,
157 158
                 label.size = 1,
158 159
                 fontface = "bold",
... ...
@@ -447,7 +447,7 @@ plotDimReduceCluster <- function(dim1,
447 447
         ggplot2::guides(color =
448 448
                 ggplot2::guide_legend(override.aes = list(size = 1)))
449 449
 
450
-    if (labelClusters == TRUE) {
450
+    if (isTRUE(labelClusters)) {
451 451
         #centroidList <- lapply(seq(length(unique(cluster))), function(x) {
452 452
         centroidList <- lapply(unique(cluster), function(x) {
453 453
             df.sub <- df[df$Cluster == x, ]
... ...
@@ -467,7 +467,7 @@ plotDimReduceCluster <- function(dim1,
467 467
             size = 0,
468 468
             alpha = 0) +
469 469
             ggrepel::geom_text_repel(data = centroid,
470
-                mapping = ggplot2::aes(label = Cluster),
470
+                mapping = ggplot2::aes(label = centroid$Cluster),
471 471
                 size = labelSize)
472 472
     }
473 473
     if (!is.null(x = groupBy)) {
... ...
@@ -1401,6 +1401,10 @@ vplayout <- function(x, y) {
1401 1401
 #' @param silent do not draw the plot (useful when using the gtable output)
1402 1402
 #' @param rowLabel row cluster labels for semi-clustering
1403 1403
 #' @param colLabel column cluster labels for semi-clustering
1404
+#' @param rowGroupOrder Vector. Specifies the order of feature clusters when 
1405
+#'  semisupervised clustering is performed on the \code{y} labels.
1406
+#' @param colGroupOrder Vector. Specifies the order of cell clusters when 
1407
+#'  semisupervised clustering is performed on the \code{z} labels.
1404 1408
 #' @param \dots graphical parameters for the text used in plot. Parameters
1405 1409
 #'  passed to \code{\link{grid.text}}, see \code{\link{gpar}}.
1406 1410
 #' @return
... ...
@@ -1627,8 +1631,7 @@ semiPheatmap <- function(mat,
1627 1631
             mat <- mat[o, , drop = FALSE]
1628 1632
             fmat <- fmat[o, , drop = FALSE]
1629 1633
             rowLabel <- rowLabel[o]
1630
-            if (!is.null(annotationRow) && length(annotationRow) > 0
1631
-                && !is.na(annotationRow)) {
1634
+            if (!is.null(annotationRow) && !is.null(ncol(annotationRow))) {
1632 1635
                 annotationRow <- annotationRow[o, , drop = FALSE]
1633 1636
             }
1634 1637
         }
... ...
@@ -1641,8 +1644,7 @@ semiPheatmap <- function(mat,
1641 1644
         mat <- mat[treeRow$order, , drop = FALSE]
1642 1645
         fmat <- fmat[treeRow$order, , drop = FALSE]
1643 1646
         labelsRow <- labelsRow[treeRow$order]
1644
-        if (!is.null(annotationRow) && length(annotationRow) > 0
1645
-            && !is.na(annotationRow)) {
1647
+        if (!is.null(annotationRow) && !is.null(ncol(annotationRow))) {
1646 1648
           annotationRow <- annotationRow[treeRow$order, , drop = FALSE]
1647 1649
         }
1648 1650
         if (!is.na(cutreeRows)) {
... ...
@@ -1666,8 +1668,7 @@ semiPheatmap <- function(mat,
1666 1668
             mat <- mat[, o, drop = FALSE]
1667 1669
             fmat <- fmat[, o, drop = FALSE]
1668 1670
             colLabel <- colLabel[o]
1669
-            if (!is.null(annotationCol) && length(annotationCol) > 0
1670
-                && !is.na(annotationCol)) {
1671
+            if (!is.null(annotationCol) && !is.null(ncol(annotationCol))) {
1671 1672
                 annotationCol <- annotationCol[o, , drop = FALSE]
1672 1673
             }
1673 1674
         }
... ...
@@ -1682,8 +1683,7 @@ semiPheatmap <- function(mat,
1682 1683
         fmat <- fmat[, treeCol$order, drop = FALSE]
1683 1684
         labelsCol <- labelsCol[treeCol$order]
1684 1685
 
1685
-        if (!is.null(annotationCol) && length(annotationCol) > 0
1686
-            && !is.na(annotationCol)) {
1686
+        if (!is.null(annotationCol) && !is.null(ncol(annotationCol))) {
1687 1687
           annotationCol <- annotationCol[treeCol$order, , drop = FALSE]
1688 1688
         }
1689 1689
         if (!is.na(cutreeCols)) {
... ...
@@ -93,6 +93,8 @@ a default value of 12345 is used. If NULL, no calls to
93 93
 `logfile`. If NULL, messages will be printed to stdout.  Default NULL.}
94 94
 
95 95
 \item{verbose}{Logical. Whether to print log messages. Default TRUE.}
96
+
97
+\item{...}{For the generic, further arguments to pass to each method.}
96 98
 }
97 99
 \value{
98 100
 If \code{x} is a matrix-like object, a list will be returned
99 101
new file mode 100644
... ...
@@ -0,0 +1,25 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/decon.R
3
+\name{decontXcounts}
4
+\alias{decontXcounts}
5
+\alias{decontXcounts<-}
6
+\title{Get or set decontaminated counts matrix}
7
+\usage{
8
+decontXcounts(object, ...)
9
+
10
+decontXcounts(object, ...) <- value
11
+}
12
+\arguments{
13
+\item{object}{A \linkS4class{SingleCellExperiment} object.}
14
+
15
+\item{...}{For the generic, further arguments to pass to each method.}
16
+
17
+\item{value}{A matrix to save as an assay called \code{decontXcounts}}
18
+}
19
+\description{
20
+Gets or sets the decontaminated counts matrix from a
21
+a \linkS4class{SingleCellExperiment} object.
22
+}
23
+\seealso{
24
+\code{\link{assay}} and \code{\link{assay<-}}
25
+}
... ...
@@ -8,8 +8,6 @@ plotHeatmap(
8 8
   counts,
9 9
   z = NULL,
10 10
   y = NULL,
11
-  rowGroupOrder = NULL,
12
-  colGroupOrder = NULL,
13 11
   scaleRow = scale,
14 12
   trim = c(-2, 2),
15 13
   featureIx = NULL,
... ...
@@ -30,6 +28,8 @@ plotHeatmap(
30 28
   annotationNamesCell = TRUE,
31 29
   showNamesFeature = FALSE,
32 30
   showNamesCell = FALSE,
31
+  rowGroupOrder = NULL,
32
+  colGroupOrder = NULL,
33 33
   hclustMethod = "ward.D2",
34 34
   treeheightFeature = ifelse(clusterFeature, 50, 0),
35 35
   treeheightCell = ifelse(clusterCell, 50, 0),
... ...
@@ -118,6 +118,12 @@ Default TRUE.}
118 118
 \item{showNamesCell}{Logical. Specifies if cell names should be shown.
119 119
 Default FALSE.}
120 120
 
121
+\item{rowGroupOrder}{Vector. Specifies the order of feature clusters when 
122
+semisupervised clustering is performed on the \code{y} labels.}
123
+
124
+\item{colGroupOrder}{Vector. Specifies the order of cell clusters when 
125
+semisupervised clustering is performed on the \code{z} labels.}
126
+
121 127
 \item{hclustMethod}{Character. Specifies the method to use for the 'hclust'
122 128
 function. See `?hclust` for possible values. Default "ward.D2".}
123 129
 
... ...
@@ -203,6 +203,12 @@ unless specified otherwise.}
203 203
 
204 204
 \item{colLabel}{column cluster labels for semi-clustering}
205 205
 
206
+\item{rowGroupOrder}{Vector. Specifies the order of feature clusters when 
207
+semisupervised clustering is performed on the \code{y} labels.}
208
+
209
+\item{colGroupOrder}{Vector. Specifies the order of cell clusters when 
210
+semisupervised clustering is performed on the \code{z} labels.}
211
+
206 212
 \item{\dots}{graphical parameters for the text used in plot. Parameters
207 213
 passed to \code{\link{grid.text}}, see \code{\link{gpar}}.}
208 214
 }