Skip to content

Commit

Permalink
add eheat and eanno
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Jun 25, 2024
1 parent ed90b73 commit 794cf10
Show file tree
Hide file tree
Showing 29 changed files with 1,720 additions and 1,371 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: eheat
Title: Extented ComplexHeatmap
Title: Extended ComplexHeatmap
Version: 0.99.0
Authors@R:
person("Yun", "Peng", , "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2801-3332"))
Expand All @@ -26,10 +26,11 @@ Suggests:
knitr,
rmarkdown
Collate:
'anno-.R'
'anno-gg.R'
'anno-subsettable-.R'
'draw-methods.R'
'eanno.R'
'eheat-package.R'
'eheat.R'
'ggheat.R'
'gganno.R'
'ggfit.R'
Expand Down
19 changes: 16 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
# Generated by roxygen2: do not edit by hand

S3method("[",ExtendedAnnotation)
S3method(eheat_prepare,ExtendedAnnotation)
S3method(eheat_prepare,ExtendedHeatmap)
S3method(eheat_prepare,ggHeatmap)
S3method(get_guides,default)
S3method(get_guides,ggplot)
S3method(get_guides,gtable)
S3method(make_legends,Legends)
S3method(make_legends,ggplot)
S3method(make_legends,grob)
S3method(make_legends,gtable)
S3method(make_legends,list)
export(anno_gg)
export(anno_gg2)
export(draw)
export(eanno)
export(eheat)
export(eheat_decorate)
export(eheat_grob)
export(eheat_prepare)
export(gganno)
export(ggfit)
export(ggfit2)
export(ggheat)
export(gpar)
export(make_legends)
export(new_anno)
export(new_anno_subset)
export(unit)
export(with_ht_opts)
export(with_ht_verbose)
exportClasses(ggAnnotationFunction)
exportClasses(ExtendedAnnotation)
exportClasses(ExtendedHeatmap)
exportClasses(ggAnno)
exportClasses(ggHeatmap)
exportMethods(draw)
exportMethods(make_layout)
exportMethods(prepare)
importClassesFrom(ComplexHeatmap,AnnotationFunction)
importClassesFrom(ComplexHeatmap,Heatmap)
Expand Down
105 changes: 0 additions & 105 deletions R/anno-.R

This file was deleted.

12 changes: 6 additions & 6 deletions R/anno-gg.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Create a heatmap annotation with ggplot object.
#' @inheritParams ggfit
#' @inheritParams new_anno
#' @inherit new_anno return
#' @inheritParams eanno
#' @inherit eanno return
#' @seealso [ggfit]
#' @examples
#' g <- ggplot(mpg, aes(displ, hwy, colour = class)) +
Expand Down Expand Up @@ -61,14 +61,14 @@ anno_gg <- function(gg, align_with = "full", clip = NULL, gt = NULL,
}
align_with <- match.arg(align_with, c("panel", "plot", "full"))
assert_clip(clip)
new_anno(NA,
eanno(
function(index, k, n) {
vp <- grid::viewport()
margins <- setup_margins(clip, vp)
.ggfit(gt, align_with, margins)
},
which = which, width = width, height = height,
show_name = show_name, name = "anno_gg"
show_name = show_name, fun_name = "anno_gg"
)
}

Expand Down Expand Up @@ -146,11 +146,11 @@ anno_gg2 <- function(gg, align_with = "full",
assert_margins(margins)
margins <- unique(margins)
elements <- setup_elements(elements, align_with, margins)
new_anno(NA,
eanno(
function(index, k, n) {
.ggfit(gt, align_with, margins, elements)
},
which = which, width = width, height = height,
show_name = show_name, name = "anno_gg2"
show_name = show_name, fun_name = "anno_gg2"
)
}
144 changes: 0 additions & 144 deletions R/anno-subsettable-.R

This file was deleted.

27 changes: 27 additions & 0 deletions R/draw-methods.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#' Draw methods for additional objects
#'
#' @description Only object with [make_legends] methods can be put in
#' `legends_margin`. Only object with [draw][draw-method] methods can be put in
#' `legends_panel`.
#'
#' @param object See method signature
#' @param ... Additional argumentds passed on to specific methods.
#' @examples
#' draw(eheat(matrix(rnorm(81), nrow = 9)))
#' @importFrom ComplexHeatmap draw
#' @export
#' @name draw-method
ComplexHeatmap::draw

methods::setOldClass(c("gtable", "ggplot"))

#' @export
#' @rdname draw-method
methods::setMethod("draw", "gtable", function(object) grid::grid.draw(object))

#' @export
#' @rdname draw-method
methods::setMethod("draw", "ggplot", function(object) {
object <- ggplot2::ggplotGrob(object)
methods::callGeneric()
})
Loading

0 comments on commit 794cf10

Please sign in to comment.