Necessary Package
library(sunburstR)
The “sunburst” package provides functions to create interactive
visualizations of sunburst diagrams. Sunburst diagrams are useful for
displaying the hierarchical structure of data and how categories
overlap.
To make an interactive phylogenetic tree plot with the SunburstR
package The data must be in csv and each taxonomic class to be
classified must be separated by a hyphen (in the same column) and in
another column the count
sun_all <- read.csv(choose.files(), header = FALSE, sep = ";", stringsAsFactors = FALSE)
Sunburst Graphic
First, we will plot all identified individuals, regardless of the
level to which they have been identified.
p1 <- sunburst(sun_all, count = TRUE, sumNodes = FALSE)
htmlwidgets::saveWidget(p1, file = "sunburst_all.html")
cat('<iframe src="sunburst_all.html" width="800" height="600" frameborder="0"></iframe>')
Sunburst Graphic with only species
In this case we will only graph the individuals that have been
identified up to the species level to compare with the previous
graph.
sun_species <- read.csv(choose.files(), header = FALSE, sep = ";", stringsAsFactors = FALSE)
p2 <- sunburst(sun_species, count = TRUE)
htmlwidgets::saveWidget(p2, file = "sunburst_species.html")
cat('<iframe src="sunburst_species.html" width="800" height="600" frameborder="0"></iframe>')
LS0tDQp0aXRsZTogIkludGVyYWN0aXZlIFN1bmJ1cnN0IEdyYXBoaWMgZm9yIE1ldGFnZW5vbWljIEFuYWx5c2lzIg0KYXV0aG9yOiAiQWxlamFuZHJvIEpvc8OpIEfDs21leiBHYXJjw61hIg0Kb3V0cHV0Og0KICBodG1sX2RvY3VtZW50Og0KICAgIGNvZGVfZG93bmxvYWQ6IHllcw0KICAgIHRvYzogdHJ1ZQ0KICAgIHRvY19mbG9hdDogdHJ1ZQ0KLS0tDQoNCiMjIE5lY2Vzc2FyeSBQYWNrYWdlDQpgYGB7cn0NCmxpYnJhcnkoc3VuYnVyc3RSKQ0KYGBgDQoNClRoZSAic3VuYnVyc3QiIHBhY2thZ2UgcHJvdmlkZXMgZnVuY3Rpb25zIHRvIGNyZWF0ZSBpbnRlcmFjdGl2ZSB2aXN1YWxpemF0aW9ucyBvZiBzdW5idXJzdCBkaWFncmFtcy4gU3VuYnVyc3QgZGlhZ3JhbX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