Skip to content

Commit

Permalink
Remove size.line argument from balance
Browse files Browse the repository at this point in the history
  • Loading branch information
tpq committed Aug 2, 2018
1 parent 6fdc3d7 commit 88b82fe
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 12 additions & 8 deletions R/balance.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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),
Expand Down
Binary file modified README-unnamed-chunk-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README-unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README-unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README-unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions man/balance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 88b82fe

Please sign in to comment.