Skip to content

Commit

Permalink
rename aes name
Browse files Browse the repository at this point in the history
  • Loading branch information
Hy4m committed May 26, 2020
1 parent a49d6c5 commit 65f9438
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 121 deletions.
34 changes: 18 additions & 16 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ S3method(ggplot_add,anno_bar)
S3method(ggplot_add,anno_bar2)
S3method(ggplot_add,anno_boxplot)
S3method(ggplot_add,anno_col_custom)
S3method(ggplot_add,anno_col_heat)
S3method(ggplot_add,anno_col_tree)
S3method(ggplot_add,anno_hc_rect)
S3method(ggplot_add,anno_link)
Expand Down Expand Up @@ -111,6 +112,7 @@ export(anno_bar)
export(anno_bar2)
export(anno_boxplot)
export(anno_col_custom)
export(anno_col_heat)
export(anno_col_tree)
export(anno_hc_rect)
export(anno_link)
Expand Down Expand Up @@ -206,26 +208,26 @@ export(remove_all_axis)
export(remove_axis)
export(remove_x_axis)
export(remove_y_axis)
export(scale_col_fill_continuous)
export(scale_col_fill_discrete)
export(scale_col_fill_gradient)
export(scale_col_fill_gradient2)
export(scale_col_fill_gradientn)
export(scale_col_fill_hue)
export(scale_col_fill_identity)
export(scale_col_fill_manual)
export(scale_color_gradient2n)
export(scale_colour_gradient2n)
export(scale_fill0_continuous)
export(scale_fill0_discrete)
export(scale_fill0_gradient)
export(scale_fill0_gradient2)
export(scale_fill0_gradientn)
export(scale_fill0_hue)
export(scale_fill0_identity)
export(scale_fill0_manual)
export(scale_fill2_continuous)
export(scale_fill2_discrete)
export(scale_fill2_gradient)
export(scale_fill2_gradient2)
export(scale_fill2_gradientn)
export(scale_fill2_hue)
export(scale_fill2_identity)
export(scale_fill2_manual)
export(scale_fill_gradient2n)
export(scale_radius_area)
export(scale_row_fill_continuous)
export(scale_row_fill_discrete)
export(scale_row_fill_gradient)
export(scale_row_fill_gradient2)
export(scale_row_fill_gradientn)
export(scale_row_fill_hue)
export(scale_row_fill_identity)
export(scale_row_fill_manual)
export(set_p_xaxis)
export(set_p_yaxis)
export(spectral)
Expand Down
11 changes: 7 additions & 4 deletions R/annotation.R
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,19 @@ anno_row_heat <- function(mapping,
data,
align = TRUE,
geom = "anno_tile",
mark = NULL,
space = 0.5,
width = 1,
col.label = TRUE,
...) {
if(!is_cor_tbl(data)) {
stop("Invalid data input.", call. = FALSE)
}
geom <- match.arg(geom, c("anno_tile", "point"))
geom <- match.arg(geom, c("anno_tile", "anno_tile2", "point"))
structure(.Data = list(mapping = mapping, data = data, align = align,
geom = geom, space = space, width = width,
col.label = col.label, params = list(...)),
geom = geom, space = space, mark = mark,
width = width, col.label = col.label,
params = list(...)),
class = "anno_row_heat")
}

Expand All @@ -242,14 +244,15 @@ anno_col_heat <- function(mapping,
data,
align = TRUE,
geom = "anno_tile2",
mark = NULL,
space = 0.5,
height = 1,
row.label = TRUE,
...) {
if(!is_cor_tbl(data)) {
stop("Invalid data input.", call. = FALSE)
}
geom <- match.arg(geom, c("anno_tile2", "point"))
geom <- match.arg(geom, c("anno_tile", "anno_tile2", "point"))
structure(.Data = list(mapping = mapping, data = data, align = align,
geom = geom, space = space, height = height,
row.label = row.label, params = list(...)),
Expand Down
4 changes: 2 additions & 2 deletions R/draw-key.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ draw_anno_tile <- function (data, params, size)
grid::rectGrob(width = grid::unit(1, "npc") - grid::unit(lwd, "mm"),
height = grid::unit(1, "npc") - grid::unit(lwd, "mm"),
gp = grid::gpar(col = data$colour %||% NA,
fill = scales::alpha(data$row_fill %||% "grey20", data$alpha),
fill = scales::alpha(data$fill0 %||% "grey20", data$alpha),
lty = data$linetype %||% 1, lwd = lwd * ggplot2::.pt,
linejoin = params$linejoin %||% "mitre",
lineend = if (identical(params$linejoin, "round")) "round" else "square"))
Expand All @@ -143,7 +143,7 @@ draw_anno_tile2 <- function (data, params, size)
grid::rectGrob(width = grid::unit(1, "npc") - grid::unit(lwd, "mm"),
height = grid::unit(1, "npc") - grid::unit(lwd, "mm"),
gp = grid::gpar(col = data$colour %||% NA,
fill = scales::alpha(data$col_fill %||% "grey20", data$alpha),
fill = scales::alpha(data$fill2 %||% "grey20", data$alpha),
lty = data$linetype %||% 1, lwd = lwd * ggplot2::.pt,
linejoin = params$linejoin %||% "mitre",
lineend = if (identical(params$linejoin, "round")) "round" else "square"))
Expand Down
16 changes: 8 additions & 8 deletions R/geom-anno-tile.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#' \item \strong{\code{y}}
#' \item \code{alpha}
#' \item \code{colour}
#' \item \code{row_fill}
#' \item \code{col_fill}
#' \item \code{fill0}
#' \item \code{fill2}
#' \item \code{linetype}
#' \item \code{size}
#' }
Expand All @@ -30,7 +30,7 @@ geom_anno_tile <- function(mapping = NULL,
params <- list(na.rm = na.rm, ...)
name <- names(params)
if("fill" %in% name) {
name[which(name == "fill")] <- "row_fill"
name[which(name == "fill")] <- "fill0"
}
names(params) <- name
layer(
Expand Down Expand Up @@ -58,7 +58,7 @@ geom_anno_tile2 <- function(mapping = NULL,
params <- list(na.rm = na.rm, ...)
name <- names(params)
if("fill" %in% name) {
name[which(name == "fill")] <- "col_fill"
name[which(name == "fill")] <- "fill2"
}
names(params) <- name
layer(
Expand All @@ -79,11 +79,11 @@ geom_anno_tile2 <- function(mapping = NULL,
#' @export
GeomAnnoTile <- ggproto(
"GeomAnnoTile", GeomTile,
default_aes = aes(colour = NA, row_fill = "grey20", width = 1,
default_aes = aes(colour = NA, fill0 = "grey20", width = 1,
height = 1, size = 0.1, linetype = 1, alpha = NA),
required_aes = c("x", "y"),
draw_panel = function(self, data, panel_params, coord) {
data <- dplyr::rename(data, fill = row_fill)
data <- dplyr::rename(data, fill = fill0)
GeomTile$draw_panel(data, panel_params, coord)
},
draw_key = draw_anno_tile
Expand All @@ -95,11 +95,11 @@ GeomAnnoTile <- ggproto(
#' @export
GeomAnnoTile2 <- ggproto(
"GeomAnnoTile2", GeomTile,
default_aes = aes(colour = NA, col_fill = "grey20", width = 1,
default_aes = aes(colour = NA, fill2 = "grey20", width = 1,
height = 1, size = 0.1, linetype = 1, alpha = NA),
required_aes = c("x", "y"),
draw_panel = function(self, data, panel_params, coord) {
data <- dplyr::rename(data, fill = col_fill)
data <- dplyr::rename(data, fill = fill2)
GeomTile$draw_panel(data, panel_params, coord)
},
draw_key = draw_anno_tile2
Expand Down
6 changes: 3 additions & 3 deletions R/guide-colourbar2.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ guide_colourbar2 <- function(title = waiver(),
default.unit = default.unit,
reverse = reverse,
order = order,
available_aes = c("row_fill", "col_fill"),
available_aes = c("fill0", "fill2"),
..., name = "colourbar2"
)
class(guide) <- c("guide", "colourbar2", "colorbar")
Expand All @@ -79,8 +79,8 @@ guide_colorbar2 <- guide_colourbar2
#' @export
guide_train.colourbar2 <- function(guide, scale, aesthetic = NULL) {
if (length(intersect(scale$aesthetics, c(
"row_fill", "col_fill"))) == 0) {
warning("colourbar2 guide 'row_fill' or 'col_fill' scales.", call. = FALSE)
"fill0", "fill2"))) == 0) {
warning("colourbar2 guide 'fill0' or 'fill2' scales.", call. = FALSE)
return(NULL)
}
if (scale$is_discrete()) {
Expand Down
2 changes: 1 addition & 1 deletion R/methods-ggplotadd.R
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ ggplot_add.anno_row_heat <- function(object, plot, object_name) {
# reset y axis parameters
polar.args$yaxis_df$x <- polar.args$yaxis_df$x + ncols(data) * object$width + object$space
if(isTRUE(object$col.label)) {
df <- data.frame(x = seq_len(ncols(data)) * object$width + shift,
df <- data.frame(x = seq_len(ncols(data)) * object$width + ncols(plot$data) + object$space + row.shift,
y = unique(polar.args$xaxis_df$y),
label = get_col_name(data),
angle = 0,
Expand Down
Loading

0 comments on commit 65f9438

Please sign in to comment.