... | ... |
@@ -6,6 +6,10 @@ S3method(cbind,poplin.matrix) |
6 | 6 |
S3method(poplin_biplot,default) |
7 | 7 |
S3method(poplin_biplot,poplin.pca) |
8 | 8 |
S3method(poplin_biplot,poplin.plsda) |
9 |
+S3method(poplin_boxplot,default) |
|
10 |
+S3method(poplin_boxplot,poplin) |
|
11 |
+S3method(poplin_corplot,default) |
|
12 |
+S3method(poplin_corplot,poplin) |
|
9 | 13 |
S3method(poplin_scoreplot,default) |
10 | 14 |
S3method(poplin_scoreplot,poplin.pca) |
11 | 15 |
S3method(poplin_scoreplot,poplin.plsda) |
... | ... |
@@ -14,7 +18,6 @@ S3method(rbind,poplin.matrix) |
14 | 18 |
S3method(summary,poplin.pca) |
15 | 19 |
S3method(summary,poplin.plsda) |
16 | 20 |
S3method(summary,poplin.tsne) |
17 |
-export("missingCount<-") |
|
18 | 21 |
export("poplinData<-") |
19 | 22 |
export("poplinReducedData<-") |
20 | 23 |
export("poplin_data<-") |
... | ... |
@@ -41,13 +44,12 @@ export(.set_poplinReducedData_data_integer) |
41 | 44 |
export(.set_poplinReducedData_data_missing) |
42 | 45 |
export(.set_poplinReducedData_datalist) |
43 | 46 |
export(.verify_and_extract_input) |
44 |
-export(missingCount) |
|
45 |
-export(plot_box) |
|
46 |
-export(plot_cor) |
|
47 | 47 |
export(poplin) |
48 | 48 |
export(poplinData) |
49 | 49 |
export(poplinReducedData) |
50 | 50 |
export(poplin_biplot) |
51 |
+export(poplin_boxplot) |
|
52 |
+export(poplin_corplot) |
|
51 | 53 |
export(poplin_data) |
52 | 54 |
export(poplin_data_list) |
53 | 55 |
export(poplin_data_names) |
... | ... |
@@ -86,7 +88,6 @@ exportClasses(poplin) |
86 | 88 |
exportClasses(poplin.matrix) |
87 | 89 |
exportMethods("[") |
88 | 90 |
exportMethods("[<-") |
89 |
-exportMethods("missingCount<-") |
|
90 | 91 |
exportMethods("poplinData<-") |
91 | 92 |
exportMethods("poplinReducedData<-") |
92 | 93 |
exportMethods("poplin_data<-") |
... | ... |
@@ -96,7 +97,6 @@ exportMethods("poplin_reduced<-") |
96 | 97 |
exportMethods("poplin_reduced_list<-") |
97 | 98 |
exportMethods("poplin_reduced_names<-") |
98 | 99 |
exportMethods(coerce) |
99 |
-exportMethods(missingCount) |
|
100 | 100 |
exportMethods(poplinData) |
101 | 101 |
exportMethods(poplinReducedData) |
102 | 102 |
exportMethods(poplin_data) |
... | ... |
@@ -1,11 +1,11 @@ |
1 | 1 |
##' @importFrom ggplot2 geom_segment scale_x_continuous scale_y_continuous sec_axis |
2 | 2 |
##' @export |
3 |
-poplin_biplot <- function(x, comp = 1:2, ...) { |
|
3 |
+poplin_biplot <- function(x, ...) { |
|
4 | 4 |
UseMethod("poplin_biplot") |
5 | 5 |
} |
6 | 6 |
|
7 | 7 |
##' @export |
8 |
-poplin_biplot.default <- function(x, y, comp, group, |
|
8 |
+poplin_biplot.default <- function(x, y, comp = 1:2, group, |
|
9 | 9 |
group_col = NULL, |
10 | 10 |
point_size = 1.5, |
11 | 11 |
point_shape_by_group = FALSE, |
... | ... |
@@ -71,7 +71,7 @@ poplin_biplot.poplin.pca <- function(x, scale = 1, comp = 1:2, ...) { |
71 | 71 |
comp <- sort(comp) |
72 | 72 |
n <- nrow(x) |
73 | 73 |
lam <- attr(x, "sdev")[comp] * sqrt(n) |
74 |
- if (scale < 0 || scale > 1) |
|
74 |
+ if (scale < 0 || scale > 1) |
|
75 | 75 |
warning("'scale' is outside [0, 1]") |
76 | 76 |
if (scale != 0) |
77 | 77 |
lam <- lam**scale |
78 | 78 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,45 @@ |
1 |
+##' @export |
|
2 |
+poplin_boxplot <- function(x, ...) { |
|
3 |
+ UseMethod("poplin_boxplot") |
|
4 |
+} |
|
5 |
+ |
|
6 |
+##' @export |
|
7 |
+##' @importFrom stats reshape |
|
8 |
+##' @importFrom ggplot2 geom_boxplot geom_violin |
|
9 |
+poplin_boxplot.default <- function(x, group, log2 = FALSE, violin = FALSE, |
|
10 |
+ ylab = "Intensity") { |
|
11 |
+ ## convert wide to long format to draw fig |
|
12 |
+ if (log2) { |
|
13 |
+ x <- log2(x) |
|
14 |
+ } |
|
15 |
+ dt <- as.data.frame(t(x)) |
|
16 |
+ cols <- names(dt) |
|
17 |
+ dt$id <- rownames(dt) |
|
18 |
+ if (!missing(group)) { |
|
19 |
+ dt$group <- group |
|
20 |
+ } |
|
21 |
+ dd <- reshape(dt, varying = cols, timevar = "feature", |
|
22 |
+ times = cols, v.names = "value", |
|
23 |
+ direction = "long", sep = "") |
|
24 |
+ if (missing(group)) { |
|
25 |
+ p <- ggplot(dd, aes(x = id, y = value)) |
|
26 |
+ } else { |
|
27 |
+ p <- ggplot(dd, aes(x = id, y = value, fill = group)) |
|
28 |
+ } |
|
29 |
+ if (violin) { |
|
30 |
+ p <- p + geom_violin() |
|
31 |
+ } else { |
|
32 |
+ p <- p + geom_boxplot() |
|
33 |
+ } |
|
34 |
+ p + |
|
35 |
+ ylab(ylab) + |
|
36 |
+ theme_bw() + |
|
37 |
+ theme(legend.title = element_blank(), |
|
38 |
+ axis.title.x = element_blank()) |
|
39 |
+} |
|
40 |
+ |
|
41 |
+##' @export |
|
42 |
+poplin_boxplot.poplin <- function(x, poplin_in, ...) { |
|
43 |
+ m <- .verify_and_extract_input(x, poplin_in) |
|
44 |
+ poplin_boxplot.default(m, ...) |
|
45 |
+} |
0 | 46 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
1 |
+##' @export |
|
2 |
+poplin_corplot <- function(x, ...) { |
|
3 |
+ UseMethod("poplin_corplot") |
|
4 |
+} |
|
5 |
+ |
|
6 |
+##' @export |
|
7 |
+##' @importFrom heatmaply ggheatmap |
|
8 |
+poplin_corplot.default <- function(x, |
|
9 |
+ use = c("everything", "all.obs", "complete.obs", |
|
10 |
+ "na.or.complete", "pairwise.complete.obs"), |
|
11 |
+ method = c("pearson", "kendall", "spearman"), |
|
12 |
+ showticklabels = c(TRUE, TRUE), ...) { |
|
13 |
+ use <- match.arg(use) |
|
14 |
+ method <- match.arg(method) |
|
15 |
+ m <- cor(x, use = use, method = method) |
|
16 |
+ ggheatmap(m, showticklabels = showticklabels, ...) |
|
17 |
+} |
|
18 |
+ |
|
19 |
+##' @export |
|
20 |
+poplin_corplot.poplin <- function(x, poplin_in , ...) { |
|
21 |
+ m <- .verify_and_extract_input(x, poplin_in) |
|
22 |
+ poplin_corplot.default(m, ...) |
|
23 |
+} |
0 | 24 |
deleted file mode 100644 |
... | ... |
@@ -1,62 +0,0 @@ |
1 |
-##' @export |
|
2 |
-##' @importFrom stats reshape |
|
3 |
-##' @importFrom ggplot2 geom_boxplot geom_violin |
|
4 |
-plot_box <- function(x, group, log2 = FALSE, violin = FALSE) { |
|
5 |
- ## convert wide to long format to draw fig |
|
6 |
- if (log2) { |
|
7 |
- x <- log2(x) |
|
8 |
- } |
|
9 |
- dt <- as.data.frame(t(x)) |
|
10 |
- cols <- names(dt) |
|
11 |
- dt$id <- rownames(dt) |
|
12 |
- if (!missing(group)) { |
|
13 |
- dt$group <- group |
|
14 |
- } |
|
15 |
- dd <- reshape(dt, varying = cols, timevar = "feature", |
|
16 |
- times = cols, v.names = "value", |
|
17 |
- direction = "long", sep = "") |
|
18 |
- if (missing(group)) { |
|
19 |
- p <- ggplot(dd, aes(x = id, y = value)) |
|
20 |
- } else { |
|
21 |
- p <- ggplot(dd, aes(x = id, y = value, fill = group)) |
|
22 |
- } |
|
23 |
- if (violin) { |
|
24 |
- p <- p + geom_violin() |
|
25 |
- } else { |
|
26 |
- p <- p + geom_boxplot() |
|
27 |
- } |
|
28 |
- p + |
|
29 |
- ylab("Intensity") + |
|
30 |
- theme_bw() + |
|
31 |
- theme(legend.title = element_blank(), |
|
32 |
- axis.title.x = element_blank()) |
|
33 |
-} |
|
34 |
- |
|
35 |
-##' @export |
|
36 |
-##' @importFrom heatmaply ggheatmap is.na10 heatmaply |
|
37 |
-## plot_na <- function(x, grid_gap = 1, colors = c("gray80", "gray20"), |
|
38 |
-## showticklabels = c(TRUE, FALSE), |
|
39 |
-## ...) { |
|
40 |
- |
|
41 |
-## p <- heatmaply(is.na10(x), grid_gap = grid_gap, colors = colors, |
|
42 |
-## showticklabels = showticklabels, |
|
43 |
-## hide_colorbar = TRUE, return_ppxpy = TRUE, ...) |
|
44 |
-## browser() |
|
45 |
-## ## heatmaply:::arrange_plots(plots = p) |
|
46 |
-## ## temporary issue in arrange_plots |
|
47 |
-## .arrange_plots(plots = p, hide_colorbar = TRUE) |
|
48 |
-## } |
|
49 |
- |
|
50 |
-##' @export |
|
51 |
-plot_cor <- function(x, |
|
52 |
- use = c("everything", "all.obs", "complete.obs", |
|
53 |
- "na.or.complete", "pairwise.complete.obs"), |
|
54 |
- method = c("pearson", "kendall", "spearman"), |
|
55 |
- showticklabels = c(TRUE, TRUE), ...) { |
|
56 |
- use <- match.arg(use) |
|
57 |
- method <- match.arg(method) |
|
58 |
- m <- cor(x, use = use, method = method) |
|
59 |
- ggheatmap(m, showticklabels = showticklabels, ...) |
|
60 |
-} |
|
61 |
- |
|
62 |
- |