Browse code

added boxplot manual.

Jaehyun Joo authored on 15/12/2021 03:24:05
Showing 7 changed files

... ...
@@ -156,7 +156,6 @@ importFrom(ggplot2,theme)
156 156
 importFrom(ggplot2,theme_bw)
157 157
 importFrom(ggplot2,xlab)
158 158
 importFrom(ggplot2,ylab)
159
-importFrom(heatmaply,ggheatmap)
160 159
 importFrom(heatmaply,heatmaply)
161 160
 importFrom(heatmaply,is.na10)
162 161
 importFrom(methods,as)
... ...
@@ -1,15 +1,30 @@
1
+##' Box plot
2
+##'
3
+##' Produce a box-and-whisker plot of the feature intensity values.
4
+##'
5
+##' @param x A matrix or \linkS4class{poplin} object.
6
+##' @param poplin_in Name of a data matrix to retrieve.
7
+##' @param pre_log2 If \code{TRUE}, feature intensities are log2-transformed
8
+##'   before plotting.
9
+##' @param violin If \code{TRUE}, a violin plot is drawn instead of the boxplot.
10
+##' @param ylab The title of y-axis of the plot.
11
+##' @return A ggplot object.
12
+##' @name poplin_boxplot
13
+NULL
14
+
1 15
 ##' @export
2 16
 poplin_boxplot <- function(x, ...) {
3 17
   UseMethod("poplin_boxplot")
4 18
 }
5 19
 
20
+##' @rdname poplin_boxplot
6 21
 ##' @export
7 22
 ##' @importFrom stats reshape
8 23
 ##' @importFrom ggplot2 geom_boxplot geom_violin
9
-poplin_boxplot.default <- function(x, group, log2 = FALSE, violin = FALSE,
24
+poplin_boxplot.default <- function(x, group, pre_log2 = FALSE, violin = FALSE,
10 25
                            ylab = "Intensity") {
11 26
   ## convert wide to long format to draw fig
12
-  if (log2) {
27
+  if (pre_log2) {
13 28
     x <- log2(x)
14 29
   }
15 30
   dt <- as.data.frame(t(x))
... ...
@@ -38,8 +53,11 @@ poplin_boxplot.default <- function(x, group, log2 = FALSE, violin = FALSE,
38 53
           axis.title.x = element_blank())
39 54
 }
40 55
 
56
+##' @rdname poplin_boxplot
41 57
 ##' @export
42
-poplin_boxplot.poplin <- function(x, poplin_in, ...) {
58
+poplin_boxplot.poplin <- function(x, poplin_in, group, pre_log2 = FALSE,
59
+                                  violin = FALSE, ylab = "Intensity") {
43 60
   m <- .verify_and_extract_input(x, poplin_in)
44
-  poplin_boxplot.default(m, ...)
61
+  poplin_boxplot.default(m, group = group, pre_log2 = pre_log2,
62
+                         violin = violin, ylab = ylab)
45 63
 }
... ...
@@ -24,7 +24,7 @@
24 24
 ##' @param row_dend_left Logical controlling whether the row dendrogram is
25 25
 ##'   placed on the left on the plot.
26 26
 ##' @param ... Additional arguments passed to [heatmaply::heatmaply].
27
-##' @return \code{gtable} of aligned plots.
27
+##' @return gtable of aligned plots.
28 28
 ##' @name poplin_corplot
29 29
 NULL
30 30
 
... ...
@@ -36,7 +36,6 @@ poplin_corplot <- function(x, ...) {
36 36
 
37 37
 ##' @rdname poplin_corplot
38 38
 ##' @export
39
-##' @importFrom heatmaply ggheatmap
40 39
 poplin_corplot.default <- function(x, unit = c("sample", "feature"),
41 40
                      use = c("everything", "all.obs", "complete.obs",
42 41
                              "na.or.complete", "pairwise.complete.obs"),
... ...
@@ -19,7 +19,7 @@
19 19
 ##' @param row_dend_left Logical controlling whether the row dendrogram is
20 20
 ##'   placed on the left on the plot.
21 21
 ##' @param ... Additional arguments passed to [heatmaply::heatmaply].
22
-##' @return \code{gtable} of aligned plots.
22
+##' @return gtable of aligned plots.
23 23
 ##' @name poplin_naplot
24 24
 NULL
25 25
 
26 26
new file mode 100644
... ...
@@ -0,0 +1,37 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/plot-boxplot.R
3
+\name{poplin_boxplot}
4
+\alias{poplin_boxplot}
5
+\alias{poplin_boxplot.default}
6
+\alias{poplin_boxplot.poplin}
7
+\title{Box plot}
8
+\usage{
9
+\method{poplin_boxplot}{default}(x, group, pre_log2 = FALSE, violin = FALSE, ylab = "Intensity")
10
+
11
+\method{poplin_boxplot}{poplin}(
12
+  x,
13
+  poplin_in,
14
+  group,
15
+  pre_log2 = FALSE,
16
+  violin = FALSE,
17
+  ylab = "Intensity"
18
+)
19
+}
20
+\arguments{
21
+\item{x}{A matrix or \linkS4class{poplin} object.}
22
+
23
+\item{pre_log2}{If \code{TRUE}, feature intensities are log2-transformed
24
+before plotting.}
25
+
26
+\item{violin}{If \code{TRUE}, a violin plot is drawn instead of the boxplot.}
27
+
28
+\item{ylab}{The title of y-axis of the plot.}
29
+
30
+\item{poplin_in}{Name of a data matrix to retrieve.}
31
+}
32
+\value{
33
+A ggplot object.
34
+}
35
+\description{
36
+Produce a box-and-whisker plot of the feature intensity values.
37
+}
... ...
@@ -34,6 +34,8 @@
34 34
   widths = NULL,
35 35
   heights = NULL,
36 36
   colors = viridis::viridis(n = 256, alpha = 1, begin = 0, end = 1, option = "viridis"),
37
+  label = FALSE,
38
+  digits = 2,
37 39
   grid_gap = 0,
38 40
   hide_colorbar = FALSE,
39 41
   showticklabels = c(TRUE, TRUE),
... ...
@@ -59,7 +61,7 @@ to be computed. Refer to \code{?cor} for details.}
59 61
 
60 62
 \item{colors}{A vector of colors for heatmap.}
61 63
 
62
-\item{label}{If \code{TRUE}, cell values are shown.}
64
+\item{label}{Logical controlling whether cell values are shown.}
63 65
 
64 66
 \item{digits}{The desired number of digits when \code{label = TRUE}.}
65 67
 
... ...
@@ -79,7 +81,7 @@ placed on the left on the plot.}
79 81
 \item{poplin_in}{Name of a data matrix to retrieve.}
80 82
 }
81 83
 \value{
82
-\code{gtable} of aligned plots.
84
+gtable of aligned plots.
83 85
 }
84 86
 \description{
85 87
 Visualize correlations between samples or features. All values in a
... ...
@@ -11,6 +11,8 @@
11 11
   widths = NULL,
12 12
   heights = NULL,
13 13
   colors = viridis::viridis(2),
14
+  label = FALSE,
15
+  digits = 2,
14 16
   grid_gap = 1,
15 17
   hide_colorbar = TRUE,
16 18
   showticklabels = c(TRUE, FALSE),
... ...
@@ -23,7 +25,9 @@
23 25
   poplin_in,
24 26
   widths = NULL,
25 27
   heights = NULL,
26
-  color = viridis::viridis(2),
28
+  colors = viridis::viridis(2),
29
+  label = FALSE,
30
+  digits = 2,
27 31
   grid_gap = 1,
28 32
   hide_colorbar = TRUE,
29 33
   showticklabels = c(TRUE, FALSE),
... ...
@@ -40,6 +44,10 @@
40 44
 
41 45
 \item{colors}{A vector of colors for heatmap.}
42 46
 
47
+\item{label}{Logical controlling whether cell values are shown.}
48
+
49
+\item{digits}{The desired number of digits when \code{label = TRUE}.}
50
+
43 51
 \item{grid_gap}{Gap between cells.}
44 52
 
45 53
 \item{hide_colorbar}{Logical controlling whether the color bar (legend) is
... ...
@@ -56,7 +64,7 @@ placed on the left on the plot.}
56 64
 \item{poplin_in}{Name of a data matrix to retrieve.}
57 65
 }
58 66
 \value{
59
-\code{gtable} of aligned plots.
67
+gtable of aligned plots.
60 68
 }
61 69
 \description{
62 70
 Visualize data for exploring missing value (NA) patterns. All values in a