diff --git a/DESCRIPTION b/DESCRIPTION index ecd2a13..33c400d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: balance Title: Visualize Balances of Compositional Data -Version: 0.0.7 +Version: 0.0.8 URL: http://github.com/tpq/balance BugReports: http://github.com/tpq/balance/issues Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 473ebab..2293adb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +## balance 0.0.8 +--------------------- +* Update `balance` method + * Remove `size.line` argument and do not set size for `!weigh.var` + ## balance 0.0.7 --------------------- * Update `balance` method diff --git a/R/balance.R b/R/balance.R index a119cdf..fe3ded8 100644 --- a/R/balance.R +++ b/R/balance.R @@ -17,7 +17,6 @@ #' by the proportion of explained variance. Only do this if balances #' come from an SBP that decomposes variance. #' @param size.text An integer. Sets legend text size. -#' @param size.line An integer. Sets line width size. #' @param size.pt An integer. Sets point size. #' #' @return A list of the "partition" \code{ggplot} object, the "distribution" @@ -32,7 +31,6 @@ balance <- function(x, y, boxplot.split = FALSE, weigh.var = FALSE, size.text = 20, - size.line = 1, size.pt = 4){ cols <- c("#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", @@ -92,10 +90,7 @@ balance <- function(x, y, if(weigh.var){ vars <- apply(B, 2, stats::var) vars <- vars/sum(vars) - linewidth <- data.frame("BalanceID" = colnames(B), "LineWidth" = size.line * vars) - dt <- merge(dt, linewidth) - }else{ - linewidth <- data.frame("BalanceID" = colnames(B), "LineWidth" = size.line) + linewidth <- data.frame("BalanceID" = colnames(B), "LineWidth" = vars) dt <- merge(dt, linewidth) } @@ -144,17 +139,26 @@ balance <- function(x, y, balance.distribution <- ggplot2::ggplot(dt, ggplot2::aes_string(x = "BalanceID", y = "SampleValue", group = "Group"), col = "black") + ggplot2::geom_boxplot(ggplot2::aes_string(col = "n.group")) + # if missing, set to "1" - ggplot2::geom_line(ggplot2::aes_string(size = "LineWidth")) + # keep unchanged to show range... ggplot2::geom_jitter(ggplot2::aes_string(col = "n.group"), size = size.pt) + # if missing, set to "1" ggplot2::scale_colour_manual(values = n.cols) + # if missing, set to "black" ggplot2::xlab("") + ggplot2::ylab("Sample-wise Distribution of Balance") + ggplot2::ylim(-1.1 * max(abs(dt$SampleValue)), 1.1 * max(abs(dt$SampleValue))) + - ggplot2::labs(col = "Sample Group") + ggplot2::guides(size = FALSE) + + ggplot2::labs(col = "Sample Group") + ggplot2::coord_flip() + ggplot2::theme_bw() + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, hjust = 1, vjust = .5)) + ggplot2::theme(text = ggplot2::element_text(size = size.text)) + ggplot2::theme(legend.position = "top") + if(weigh.var){ + balance.distribution <- balance.distribution + + ggplot2::geom_line(ggplot2::aes_string(size = "LineWidth")) + # keep unchanged to show range... + ggplot2::guides(size = FALSE) + }else{ + balance.distribution <- balance.distribution + + ggplot2::geom_line() + + ggplot2::guides(size = FALSE) + } + grid::grid.newpage() grob <- cbind(ggplot2::ggplotGrob(balance.partition), ggplot2::ggplotGrob(balance.distribution), diff --git a/README-unnamed-chunk-4-1.png b/README-unnamed-chunk-4-1.png index f2e8647..83db6af 100644 Binary files a/README-unnamed-chunk-4-1.png and b/README-unnamed-chunk-4-1.png differ diff --git a/README-unnamed-chunk-5-1.png b/README-unnamed-chunk-5-1.png index d061485..8b8f91d 100644 Binary files a/README-unnamed-chunk-5-1.png and b/README-unnamed-chunk-5-1.png differ diff --git a/README-unnamed-chunk-6-1.png b/README-unnamed-chunk-6-1.png index 41aeb06..444a492 100644 Binary files a/README-unnamed-chunk-6-1.png and b/README-unnamed-chunk-6-1.png differ diff --git a/README-unnamed-chunk-7-1.png b/README-unnamed-chunk-7-1.png index f502b3c..d7d8672 100644 Binary files a/README-unnamed-chunk-7-1.png and b/README-unnamed-chunk-7-1.png differ diff --git a/README-unnamed-chunk-8-1.png b/README-unnamed-chunk-8-1.png index 6de7b24..c6da9ca 100644 Binary files a/README-unnamed-chunk-8-1.png and b/README-unnamed-chunk-8-1.png differ diff --git a/man/balance.Rd b/man/balance.Rd index 9e6907d..6043bb0 100644 --- a/man/balance.Rd +++ b/man/balance.Rd @@ -5,7 +5,7 @@ \title{Calculate and Visualize Balances} \usage{ balance(x, y, d.group, n.group, boxplot.split = FALSE, weigh.var = FALSE, - size.text = 20, size.line = 1, size.pt = 4) + size.text = 20, size.pt = 4) } \arguments{ \item{x}{A matrix with rows as samples (N) and columns as components (D).} @@ -28,8 +28,6 @@ come from an SBP that decomposes variance.} \item{size.text}{An integer. Sets legend text size.} -\item{size.line}{An integer. Sets line width size.} - \item{size.pt}{An integer. Sets point size.} } \value{