{r3dmol} v0.1.2 is now available on CRAN. By using {r3dmol}, you could create rich and fully interactive 3D visualizations of molecular data, and embed pdbs easily into a rmarkdown report or blogdown post.

Some powerful features are introduced from v0.1.2.

1. Convert Widget to PNG

Some times you may not need an interactive widget or just want to reduce the size of the document, then you can use m_png to quickly convert the widget to a PNG image (base64 encoded).

library(r3dmol)

r3dmol() %>%
  m_add_model(data = pdb_1j72, format = "pdb") %>%
  m_set_style(style = m_style_cartoon()) %>%
  m_zoom_to() %>%
  m_png(width = 800)

2. Quickly View Given Structure

From v0.1.2, m_glimpse() has been added to create a scene with a number of simple defaults in order to quickly view the structure without having to write multiple lines of code.

m_glimpse(model = "4ozs", spin = TRUE)

3. Multiple Selections

Please refer to this article (Dealing with multiple selections to speed up adding lines & shapes.) to see more details.

4. Multiple Viewers

You could create and initialize an appropriate a grid of viewers that share a WebGL canvas from v0.1.2

library(r3dmol)

m1 <- r3dmol() %>%
  m_add_model(data = pdb_6zsl, format = "pdb") %>%
  m_zoom_to()

m2 <- m1 %>%
  m_set_style(style = m_style_cartoon(color = "spectrum"))

m3 <- m1 %>%
  m_set_style(style = m_style_stick())

m4 <- m1 %>%
  m_set_style(style = m_style_sphere())

m_grid(
  viewer = list(m1, m2, m3, m4),
  control_all = TRUE,
  viewer_config = m_viewer_spec(
    backgroundColor = "black"
  )
)