| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/circlize.R |
| 3 |
\name{circlize_dendrogram} |
| 4 |
\alias{circlize_dendrogram} |
| 5 |
\title{Plot a circlized dendrograms} |
| 6 |
\source{ |
| 7 |
This code is based on the work of Zuguang Gu. If you use the function, please cite both |
| 8 |
dendextend (see: \code{citation("dendextend")}), as well as the circlize package (see: \code{citation("circlize")}). |
| 9 |
} |
| 10 |
\usage{ |
| 11 |
circlize_dendrogram( |
| 12 |
dend, |
| 13 |
facing = c("outside", "inside"), |
| 14 |
labels = TRUE, |
| 15 |
labels_track_height = 0.1, |
| 16 |
dend_track_height = 0.5, |
| 17 |
... |
| 18 |
) |
| 19 |
} |
| 20 |
\arguments{ |
| 21 |
\item{dend}{a \link{dendrogram} object} |
| 22 |
|
| 23 |
\item{facing}{Is the dendromgrams facing inside to the circle or outside.} |
| 24 |
|
| 25 |
\item{labels}{logical (TRUE) - should the labels be plotted as well.} |
| 26 |
|
| 27 |
\item{labels_track_height}{a value for adjusting the room for the labels. |
| 28 |
It is 0.2 by default, but if NULL or NA, it will adjust automatically based on |
| 29 |
the max width of the labels. However, if this is too long, the plot will give an error: |
| 30 |
Error in check.track.position(track.index, track.start, track.height) : |
| 31 |
not enough space for cells at track index '2'.} |
| 32 |
|
| 33 |
\item{dend_track_height}{a value for adjusting the room for the dendrogram.} |
| 34 |
|
| 35 |
\item{...}{Ignored.} |
| 36 |
} |
| 37 |
\value{ |
| 38 |
The dend that was used for plotting. |
| 39 |
} |
| 40 |
\description{ |
| 41 |
Plot a circlized dendrograms using the circlize package (must be installed for the function to work). |
| 42 |
|
| 43 |
This type of plot is also sometimes called fan tree plot (although the name fan-plot is also used for a different |
| 44 |
plot in time series analysis), radial tree plot, polar tree plot, circular tree plot, and probably other names as well. |
| 45 |
|
| 46 |
An advantage for using the circlize package directly is for plotting a |
| 47 |
circular dendrogram so that you can add more graphics for the elements |
| 48 |
in the tree just by adding more tracks using \link[circlize]{circos.track}. |
| 49 |
} |
| 50 |
\examples{ |
| 51 |
|
| 52 |
\dontrun{ |
| 53 |
|
| 54 |
dend <- iris[1:40, -5] \%>\% |
| 55 |
dist() \%>\% |
| 56 |
hclust() \%>\% |
| 57 |
as.dendrogram() \%>\% |
| 58 |
set("branches_k_color", k = 3) \%>\% |
| 59 |
set("branches_lwd", c(5, 2, 1.5)) \%>\% |
| 60 |
set("branches_lty", c(1, 1, 3, 1, 1, 2)) \%>\% |
| 61 |
set("labels_colors") \%>\% |
| 62 |
set("labels_cex", c(.9, 1.2)) \%>\% |
| 63 |
set("nodes_pch", 19) \%>\% |
| 64 |
set("nodes_col", c("orange", "black", "plum", NA)) |
| 65 |
|
| 66 |
circlize_dendrogram(dend) |
| 67 |
circlize_dendrogram(dend, labels = FALSE) |
| 68 |
circlize_dendrogram(dend, facing = "inside", labels = FALSE) |
| 69 |
|
| 70 |
|
| 71 |
# In the following we get the dendrogram but can also get extra information on top of it |
| 72 |
circos.initialize("foo", xlim = c(0, 40)) |
| 73 |
circos.track(ylim = c(0, 1), panel.fun = function(x, y) { |
| 74 |
circos.rect(1:40 - 0.8, rep(0, 40), 1:40 - 0.2, runif(40), col = rand_color(40), border = NA) |
| 75 |
}, bg.border = NA) |
| 76 |
circos.track(ylim = c(0, 1), panel.fun = function(x, y) { |
| 77 |
circos.text(1:40 - 0.5, rep(0, 40), labels(dend), |
| 78 |
col = labels_colors(dend), |
| 79 |
facing = "clockwise", niceFacing = TRUE, adj = c(0, 0.5) |
| 80 |
) |
| 81 |
}, bg.border = NA, track.height = 0.1) |
| 82 |
max_height <- attr(dend, "height") |
| 83 |
circos.track(ylim = c(0, max_height), panel.fun = function(x, y) { |
| 84 |
circos.dendrogram(dend, max_height = max_height) |
| 85 |
}, track.height = 0.5, bg.border = NA) |
| 86 |
circos.clear() |
| 87 |
} |
| 88 |
} |
| 89 |
\seealso{ |
| 90 |
\link[circlize]{circos.dendrogram} |
| 91 |
} |
| 92 |
\author{ |
| 93 |
Zuguang Gu, Tal Galili |
| 94 |
} |