Skip to content

Commit

Permalink
add fortify_matrix method for phylo object
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Jan 8, 2025
1 parent de233eb commit 52bbe88
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 8 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ S3method(fortify_matrix,MAF)
S3method(fortify_matrix,default)
S3method(fortify_matrix,formula)
S3method(fortify_matrix,matrix)
S3method(fortify_matrix,phylo)
S3method(fortify_matrix,waiver)
S3method(fortify_upset,list)
S3method(fortify_upset,matrix)
Expand Down
19 changes: 19 additions & 0 deletions R/align-phylo.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,25 @@ AlignPhylo <- ggproto("AlignPhylo", Align,
summary_align = function(self) c(TRUE, FALSE)
)

#' @inherit fortify_matrix title
#' @description This method allows a [`phylo`][ape::as.phylo] object to be
#' directly input into `stack_discrete()` or `circle_discrete()`. This makes it
#' possible to add [`align_phylo()`] to the stack independently, as
#' [`align_phylo()`] requires the layout to have labels.
#' @return A one-column matrix where the tip labels are the values, and the row
#' names will also be the tip labels.
#' @family fortify_matrix methods
#' @export
fortify_matrix.phylo <- function(data, ...) {
rlang::check_dots_empty()
if (is.null(labels <- data$tip_labels)) {
cli_abort(
"{.arg data} {.cls phylo} object must have tip labels to match the layout data"
)
}
as.matrix(vec_set_names(labels, labels))
}

#' @inherit fortify_data_frame.default title description
#' @inheritParams rlang::args_dots_empty
#' @inheritParams fortify_data_frame.dendrogram
Expand Down
1 change: 1 addition & 0 deletions R/fortify-matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' - [`fortify_matrix.default()`]
#' - [`fortify_matrix.MAF()`]
#' - [`fortify_matrix.GISTIC()`]
#' - [`fortify_matrix.phylo()`]
#' @export
fortify_matrix <- function(data, ...) {
UseMethod("fortify_matrix")
Expand Down
3 changes: 2 additions & 1 deletion man/fortify_matrix.GISTIC.Rd

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

3 changes: 2 additions & 1 deletion man/fortify_matrix.MAF.Rd

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

1 change: 1 addition & 0 deletions man/fortify_matrix.Rd

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

3 changes: 2 additions & 1 deletion man/fortify_matrix.default.Rd

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

25 changes: 25 additions & 0 deletions man/fortify_matrix.phylo.Rd

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

6 changes: 1 addition & 5 deletions man/patch_titles.Rd

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

0 comments on commit 52bbe88

Please sign in to comment.