Skip to content

Commit

Permalink
fully compatible with position scale function
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Aug 5, 2024
1 parent e0f79a6 commit e3d1aa8
Show file tree
Hide file tree
Showing 18 changed files with 273 additions and 380 deletions.
26 changes: 4 additions & 22 deletions R/align-.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,6 @@
#' plots along a single axis.
#'
#' @param size Plot size, can be a [unit][grid::unit] object.
#' @param labels Labels for axis parallelly with the layout, the default will
#' use the rownames of the `data`. One of:
#' - `NULL` for no labels
#' - `waiver()` for the default labels
#' - A character vector giving labels (must be same length as the layout
#' axis). Note the labels will be reordered based on the layout.
#' - An expression vector (must be the same length as layout axis). See
#' `?plotmath` for details.
#' - A function that takes the default labels as the input and returns labels
#' as output. Also accepts rlang [lambda][rlang::as_function()] function
#' notation.
#' @param labels_nudge A single numeric or a numeric value of length
#' `nrow(data)`, to nudge each text label away from the center. One of:
#' - `NULL` for no breaks
#' - `waiver()`: if `labels` is `NULL`, then `labels_nudge` will be `NULL`,
#' otherwise it will inherit from the `layout` object.
#' - A numeric.
#' @param set_context A single boolean value indicates whether to set the active
#' context to current `Align` object. If `TRUE`, all subsequent ggplot elements
#' will be added into this `Align` object.
Expand All @@ -53,7 +36,6 @@
#' @export
#' @keywords internal
align <- function(align_class, params,
labels = NULL, labels_nudge = waiver(),
size = NULL, data = NULL,
set_context = TRUE, order = NA_integer_, name = NULL,
check.param = TRUE, call = caller_call()) {
Expand Down Expand Up @@ -117,10 +99,10 @@ align <- function(align_class, params,
# collect parameters
input_params = params[intersect(names(params), all)],
facetted_pos_scales = NULL,
# used to control the labels and breaks of
# the axis parallelly with the heatmap
labels = labels,
labels_nudge = labels_nudge,

# used to control the labels parallelly with the heatmap
labels = NULL,

# used to provide error message
call = call
)
Expand Down
2 changes: 0 additions & 2 deletions R/align-dendrogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ align_dendro <- function(mapping = aes(), ...,
k = NULL, h = NULL,
plot_cut_height = NULL, root = NULL,
center = FALSE, type = "rectangle",
labels = NULL, labels_nudge = waiver(),
size = NULL, data = NULL,
set_context = TRUE, order = NULL, name = NULL) {
assert_bool(reorder_group)
Expand All @@ -80,7 +79,6 @@ align_dendro <- function(mapping = aes(), ...,
reorder_group = reorder_group,
mapping = mapping
),
labels = labels, labels_nudge = labels_nudge,
set_context = set_context, name = name, order = order,
size = size, data = data
)
Expand Down
4 changes: 1 addition & 3 deletions R/align-gg.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'
#' The internal will always use a default mapping of `aes(y = .data$.y)` or
#' `aes(x = .data$.x)`.
#'
#'
#' For ggplot usage, matrix (including a simple vector) data is converted into a
#' long-format data frame, similar to the process utilized in `ggheatmap`. But
#' note that the long-format data frame does not contain `.row_panel` or
Expand Down Expand Up @@ -45,12 +45,10 @@
#' @importFrom rlang caller_call current_call
#' @export
align_gg <- function(mapping = aes(), data = NULL, size = NULL,
labels = NULL, labels_nudge = NULL,
set_context = TRUE, order = NULL, name = NULL) {
assert_mapping(mapping)
align(AlignGG,
params = list(mapping = mapping),
labels = labels, labels_nudge = labels_nudge,
size = size, data = data,
set_context = set_context, order = order, name = name
)
Expand Down
1 change: 0 additions & 1 deletion R/align-title.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ align_title <- function(titles = NULL, ..., mapping = aes(),
mapping = mapping, titles = titles,
text_params = rlang::list2(...)
),
labels = NULL, labels_nudge = NULL,
size = size, data = NULL,
set_context = set_context,
order = order, name = name
Expand Down
Loading

0 comments on commit e3d1aa8

Please sign in to comment.