Skip to content

Commit

Permalink
update the website
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed Jun 14, 2024
1 parent d436377 commit 7b65256
Show file tree
Hide file tree
Showing 299 changed files with 6,203 additions and 4,691 deletions.
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ vignettes/special_data_type.Rmd
vignettes/spiralize_git_commit.Rmd
vignettes/spiralize_intro.Rmd
vignettes/tree_of_life.Rmd
vignettes/git_commit_julia.png
vignettes/git_commit_perl.png
vignettes/git_commit_python.png
vignettes/git_commit_r.png
vignettes/more_examples.Rmd
vignettes/spiral_covid.Rmd
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: spiralize
Type: Package
Title: Visualize Data on Spirals
Version: 1.0.9
Date: 2024-02-26
Version: 1.1.0
Date: 2024-06-11
Authors@R: person("Zuguang", "Gu", email = "[email protected]", role = c("aut", "cre"),
comment = c('ORCID'="0000-0002-7395-8709"))
Depends: R (>= 4.0.0), grid
Expand All @@ -22,12 +22,12 @@ Suggests: ComplexHeatmap,
jpeg,
png,
tiff,
ape,
cranlogs,
cowplot,
dendextend,
bezier,
magick
magick,
ape
Description: It visualizes data along an Archimedean spiral <https://en.wikipedia.org/wiki/Archimedean_spiral>,
makes so-called spiral graph or spiral chart.
It has two major advantages for visualization: 1. It is able to visualize data with very long axis with high
Expand All @@ -36,6 +36,6 @@ VignetteBuilder: knitr
URL: https://github.com/jokergoo/spiralize, https://jokergoo.github.io/spiralize
License: MIT + file LICENSE
NeedsCompilation: no
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
19 changes: 0 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: Zuguang Gu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

120 changes: 65 additions & 55 deletions NAMESPACE
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,59 +1,69 @@
S3method("$", "TRACK_META")
export("$.TRACK_META")
S3method("names", "TRACK_META")
export("names.TRACK_META")
S3method("print", "TRACK_META")
export("print.TRACK_META")
export("TRACK_META")
export("cartesian_to_xy")
export("current_spiral")
export("current_spiral_vp")
export("current_track_index")
export("get_track_data")
export("horizon_legend")
export("is_in_track")
export("n_tracks")
export("phylo_to_dendrogram")
export("polar_to_cartesian")
export("set_current_track")
export("solve_theta_from_spiral_length")
export("spiral_arrow")
export("spiral_axis")
export("spiral_bars")
export("spiral_clear")
export("spiral_dendrogram")
export("spiral_git_commits")
export("spiral_highlight")
export("spiral_highlight_by_sector")
export("spiral_horizon")
export("spiral_info")
export("spiral_initialize")
export("spiral_initialize_by_gcoor")
export("spiral_initialize_by_time")
export("spiral_lines")
export("spiral_opt")
export("spiral_phylo")
export("spiral_points")
export("spiral_polygon")
export("spiral_raster")
export("spiral_rect")
export("spiral_segments")
export("spiral_text")
export("spiral_track")
export("spiral_xaxis")
export("spiral_yaxis")
export("xy_to_cartesian")
export("xy_to_polar")
# Generated by roxygen2: do not edit by hand

import("GlobalOptions")
import(GetoptLong)
S3method("$",TRACK_META)
S3method("[",TRACK_META)
S3method("[[",TRACK_META)
S3method(names,TRACK_META)
S3method(print,TRACK_META)
export(TRACK_META)
export(cartesian_to_polar)
export(cartesian_to_xy)
export(current_spiral)
export(current_spiral_vp)
export(current_track_index)
export(get_track_data)
export(horizon_legend)
export(is_in_track)
export(n_tracks)
export(phylo_to_dendrogram)
export(polar_to_cartesian)
export(set_current_track)
export(solve_theta_from_spiral_length)
export(spiral_arrow)
export(spiral_axis)
export(spiral_bars)
export(spiral_clear)
export(spiral_dendrogram)
export(spiral_git_commits)
export(spiral_highlight)
export(spiral_highlight_by_sector)
export(spiral_horizon)
export(spiral_info)
export(spiral_initialize)
export(spiral_initialize_by_gcoor)
export(spiral_initialize_by_time)
export(spiral_lines)
export(spiral_opt)
export(spiral_phylo)
export(spiral_pkg_downloads)
export(spiral_points)
export(spiral_polygon)
export(spiral_raster)
export(spiral_rect)
export(spiral_segments)
export(spiral_text)
export(spiral_track)
export(spiral_xaxis)
export(spiral_yaxis)
export(xy_to_cartesian)
export(xy_to_polar)
import(GlobalOptions)
import(grid)
import(lubridate)
import(methods)
importFrom("circlize", colorRamp2, rand_color)
importFrom("grDevices", "as.raster", "png", "dev.off")
importFrom("grDevices", "col2rgb", "rgb", "dev.size", "pdf.options")
importFrom("utils", "getFromNamespace", "packageDescription")
importFrom("utils", "read.table")
importFrom(stats, is.leaf, uniroot)

importFrom(GetoptLong,qq)
importFrom(GetoptLong,qqcat)
importFrom(circlize,colorRamp2)
importFrom(circlize,rand_color)
importFrom(grDevices,as.raster)
importFrom(grDevices,col2rgb)
importFrom(grDevices,dev.off)
importFrom(grDevices,dev.size)
importFrom(grDevices,pdf.options)
importFrom(grDevices,png)
importFrom(grDevices,rgb)
importFrom(stats,is.leaf)
importFrom(stats,quantile)
importFrom(stats,uniroot)
importFrom(utils,getFromNamespace)
importFrom(utils,read.table)
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## version 1.1.0

- use roxygen2 to generate documentations
- redesigned the website

## version 1.0.8

- add `spiral_git_commits()`.
Expand Down
142 changes: 69 additions & 73 deletions R/dendrogram.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

#' @importFrom stats is.leaf
construct_dend_segments = function(dend, gp = gpar()) {

if(!requireNamespace("ComplexHeatmap")) {
Expand Down Expand Up @@ -113,32 +115,34 @@ construct_dend_segments = function(dend, gp = gpar()) {

}

# == title
# Draw dendrogram
#
# == param
# -dend A ``stats::dendrogram`` object.
# -gp Graphics parameters of the dendrogram edges.
# -track_index Index of the track.
#
# == details
# Note the dendrogram edges can be rendered with the `dendextend::dendextend` package.
#
# == value
# Height of the dendrogram.
#
# == example
# k = 500
# dend = as.dendrogram(hclust(dist(runif(k))))
# spiral_initialize(xlim = c(0, k), start = 360, end = 360*3)
# spiral_track(height = 0.8, background_gp = gpar(fill = "#EEEEEE", col = NA))
#
# \donttest{
# require(dendextend)
# dend = color_branches(dend, k = 4)
# spiral_initialize(xlim = c(0, k), start = 360, end = 360*3)
# spiral_track(height = 0.8, background_gp = gpar(fill = "#EEEEEE", col = NA))
# }
#' Draw dendrogram
#'
#' @param dend A [`stats::dendrogram`] object.
#' @param gp Graphical parameters of the dendrogram edges, mainly as a global setting.
#' @param track_index Index of the track.
#'
#' @details
#' Graphical parameters for individual edges can be set via the `edgePar` attribute on each node in the dendrogram, see [`stats::dendrogram`]
#' for how to set `edgePar`.
#'
#' The dendrogram edges can also be rendered by [`dendextend::color_branches()`].
#'
#' @return Height of the dendrogram.
#' @export
#' @examples
#' k = 500
#' dend = as.dendrogram(hclust(dist(runif(k))))
#' spiral_initialize(xlim = c(0, k), start = 360, end = 360*3)
#' spiral_track(height = 0.8, background_gp = gpar(fill = "#EEEEEE", col = NA))
#' spiral_dendrogram(dend)
#'
#' \donttest{
#' require(dendextend)
#' dend = color_branches(dend, k = 4)
#' spiral_initialize(xlim = c(0, k), start = 360, end = 360*3)
#' spiral_track(height = 0.8, background_gp = gpar(fill = "#EEEEEE", col = NA))
#' spiral_dendrogram(dend)
#' }
spiral_dendrogram = function(dend, gp = gpar(), track_index = current_track_index()) {

lt = construct_dend_segments(dend, gp)
Expand All @@ -160,6 +164,7 @@ spiral_dendrogram = function(dend, gp = gpar(), track_index = current_track_inde

############# for phylo object ############

#' @importFrom circlize rand_color
construct_phylo_segments = function(obj, group = NULL, group_col = NULL) {
if(!inherits(obj, "phylo")) {
stop_wrap("The input should be a 'phylo' object.")
Expand Down Expand Up @@ -275,28 +280,25 @@ construct_phylo_segments = function(obj, group = NULL, group_col = NULL) {

}

# == title
# Draw phylogenetic tree
#
# == param
# -obj A ``phylo`` object.
# -gp Graphics parameters of the tree edges.
# -log Whether the height of the tree should be log-transformed (log10(x + 1))?
# -reverse Whether the tree should be reversed?
# -group A categorical variable for splitting the tree.
# -group_col A named vector which contains group colors.
# -track_index Index of the track.
#
# == value
# Height of the phylogenetic tree.
#
# == example
# require(ape)
# data(bird.families)
# n = length(bird.families$tip.label)
# spiral_initialize(xlim = c(0, n), start = 360, end = 360*3)
# spiral_track(height = 0.8)
# spiral_phylo(bird.families)
#' Draw phylogenetic tree
#'
#' @param obj A [`stats::dendrogram`] object.
#' @param gp Graphical parameters of the tree edges, mainly as a global setting.
#' @param log Whether the height of the tree to be log-transformed `log10(x + 1)`?
#' @param reverse Whether the tree to be reversed?
#' @param group A categorical variable for splitting the tree.
#' @param group_col A named vector which contains group colors.
#' @param track_index Index of the track.
#'
#' @return Height of the phylogenetic tree.
#' @export
#' @examples
#' require(ape)
#' data(bird.families)
#' n = length(bird.families$tip.label)
#' spiral_initialize(xlim = c(0, n), start = 360, end = 360*3)
#' spiral_track(height = 0.8)
#' spiral_phylo(bird.families)
spiral_phylo = function(obj, gp = gpar(), log = FALSE, reverse = FALSE,
group = NULL, group_col = NULL, track_index = current_track_index()) {

Expand Down Expand Up @@ -333,31 +335,25 @@ spiral_phylo = function(obj, gp = gpar(), log = FALSE, reverse = FALSE,
invisible(ymax2)
}

# == title
# Convert a phylo object to a dendrogram object
#
# == param
# -obj A ``phylo`` object.
# -log Whether the height of the phylogenetic tree should be log-transformed (log10(x + 1)).
#
# == details
# The motivation is that phylogenetic tree may contain polytomies, which means at a certain node,
# there are more than two children branches. Available tools that do the conversion only support binary trees.
#
# The returned ``dendrogram`` object is not in its standard format which means it can not be properly
# drawn by the ``plot.dendrogram`` function. However, you can still apply dendextend::`dendextend::cutree` to the returned
# ``dendrogram`` object with no problem and the dendrogram can be properly drawn with the ComplexHeatmap package.
#
# == value
# A ``dendrogram`` object.
#
# == example
# require(ape)
# data(bird.families)
# d = phylo_to_dendrogram(bird.families)
#
# require(ComplexHeatmap)
# grid.dendrogram(d, test = TRUE)
#' @details
#' [`phylo_to_dendrogram()`] converts a `phylo` object to a `dendrogram` object.
#'
#' The motivation is that phylogenetic tree may contain polytomies, which means at a certain node,
#' there are more than two children branches. Available tools that do the conversion only support binary trees.
#'
#' The returned `dendrogram` object is not in its standard format which means it can not be properly
#' drawn by the [`stats::plot.dendrogram()`] function. However, you can still apply [`stats::cutree()`] to the returned
#' `dendrogram` object with no problem and the dendrogram can be properly drawn with the **ComplexHeatmap** package (see examples).
#'
#' @return A [`stats::dendrogram`] object.
#' @rdname spiral_phylo
#' @export
#' @examples
#' require(ape)
#' data(bird.families)
#' d = phylo_to_dendrogram(bird.families)
#'
#' ComplexHeatmap::grid.dendrogram(d, test = TRUE)
phylo_to_dendrogram = function(obj, log = FALSE) {
if(!inherits(obj, "phylo")) {
stop_wrap("The input should be a 'phylo' object.")
Expand Down
Loading

0 comments on commit 7b65256

Please sign in to comment.