-
Notifications
You must be signed in to change notification settings - Fork 10
/
Interactive.Rmd
executable file
·61 lines (52 loc) · 1.63 KB
/
Interactive.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
title: "Interactive examples"
author: "Leo Lahti, Sudarshan Shetty et al."
bibliography:
- bibliography.bib
output:
BiocStyle::html_document:
number_sections: no
toc: yes
toc_depth: 4
toc_float: true
self_contained: true
thumbnails: true
lightbox: true
gallery: true
use_bookdown: false
highlight: haddock
---
<!--
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{microbiome tutorial - Interactive}
%\usepackage[utf8]{inputenc}
%\VignetteEncoding{UTF-8}
-->
## Interactive plots
```{r interactive-example, warning=FALSE, message=FALSE, fig.height=5, eval = TRUE}
library(ggplot2)
library(rvg)
library(ggiraph)
library(microbiome)
data("atlas1006")
pseq <- atlas1006
x <- microbiome::transform(atlas1006, "compositional")
mytheme_main <- theme( panel.background = element_blank(),
panel.grid.major = element_line(colour = "#dddddd"),
axis.ticks = element_line(colour = "#dddddd") )
mytheme_map <- theme(
panel.background = element_blank(), axis.title.x = element_blank(),
axis.text = element_blank(), axis.line.x = element_blank(),
axis.line.y = element_blank(), axis.title.y = element_blank(),
axis.ticks.x = element_blank(), axis.ticks.y = element_blank() )
df <- as(sample_data(x), "data.frame")
df$Dialister <- get_sample(x, "Dialister")
df$Prevotella <- get_sample(x, "Prevotella melaninogenica et rel.")
df$sample <- row.names(df)
# geom_point_interactive example
gg_point_1 <- ggplot(df, aes(x = Prevotella, y = Dialister,
color = age, tooltip = sample) ) +
geom_point_interactive(size=3)
# htmlwidget call
ggiraph(code = {print(gg_point_1 + mytheme_main)})
```