Learn R Programming

r3dmol

This is an R package that provides support for 3Dmol.js as a htmlwidgets.

Installation

Important: This package is still very early in its development stages. Please give the repository a star on Github if you find the package is useful. In addition, we need your feedback to improve the package, feel free to create an issue if you have any question or feature requirement. You are more than welcome to submit a PR to make any feasible improvements.

You could install the released version of r3dmol from CRAN with:

install.packages("r3dmol")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("swsoyee/r3dmol")

Example

library(r3dmol)

r3dmol(                         # Set up the initial viewer
  viewer_spec = m_viewer_spec(
    cartoonQuality = 10,
    lowerZoomLimit = 50,
    upperZoomLimit = 350
  )
) %>%
  m_add_model(                  # Add model to scene
    data = pdb_6zsl,
    format = "pdb"
  ) %>%
  m_zoom_to() %>%               # Zoom to encompass the whole scene
  m_set_style(                  # Set style of structures
    style = m_style_cartoon(
      color = "#00cc96"
    )
  ) %>%
  m_set_style(                  # Set style of specific selection
    sel = m_sel(ss = "s"),      # (selecting by secondary)
    style = m_style_cartoon(
      color = "#636efa",
      arrows = TRUE
    )
  ) %>%
  m_set_style(                  # Style the alpha helix
    sel = m_sel(ss = "h"),      # (selecting by alpha helix)
    style = m_style_cartoon(
      color = "#ff7f0e"
    )
  ) %>%
  m_rotate(                     # Rotate the scene by given angle on given axis
    angle = 90,
    axis = "y"
  ) %>%
  m_spin()                      # Animate the scene by spinning it


You can find more demo at here.

About 3Dmol.js

Nicholas Rego, David Koes, 3Dmol.js: molecular visualization with WebGL, Bioinformatics, Volume 31, Issue 8, 15 April 2015, Pages 1322–1324,

Code of Conduct

Please note that the r3dmol project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('r3dmol')

Monthly Downloads

351

Version

0.1.2

License

BSD_3_clause + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Wei Su

Last Published

March 14th, 2021

Functions in r3dmol (0.1.2)

m_add_arrow

Add arrow shape
m_add_style

Overwrite Previous Style
m_add_isosurface

Construct isosurface from volumetric data in gaussian cube format
m_add_as_one_molecule

Create and add model to viewer
m_add_sphere

Add Sphere Shape
.m_multi_spec

List of multiple start/stop locations.
m_add_outline

Add colored outline to all objects in scene.
cube_benzene_homo

Gaussian cube file example
m_add_property_labels

Add property labels
m_add_box

Create and add shape
m_add_shape

Add shape object to viewer
m_add_res_labels

Add Residue Labels
m_fetch_pdb

Fetch Structure from PDB
init

Initialise a WebGL-based viewer
m_get_model

Return specified model
m_create_model_from

Create a new model from atoms specified by sel
m_is_animated

Get viewer animate status
m_enable_fog

Enable/disable fog for content far from the camera
m_center

Re-center the viewer around the provided selection
m_add_label

Add label to viewer
m_clear

Clear scene of all objects
m_add_model

Create and add model to viewer
m_multi_resi_sel

Selection Across Multiple Residues
m_glimpse

Quickly View Given Structure
cif_254385

Cif file example
m_button

Add button into viewer
m_bio3d

Load structure from package bio3d
m_png

Convert widgets to PNG image
m_remove_all_labels

Remove all labels from viewer
m_set_preceived_distance

Set the distance between the model and the camera
m_sel

Selection Function for r3dmol
m_grid

Create a grid of viewers that share a WebGL canvas
m_set_projection

Set view projection scheme
pdb_1j72

Crystal Structure of Mutant Macrophage Capping Protein (Cap G) with Actin-severing Activity in the Ca2+-Free Form in PDB format
m_render

Render current state of viewer
pdb_6zsl

Crystal structure of the SARS-CoV-2 helicase at 1.94 Angstrom resolution in PDB format
m_stop_animate

Stop animation of all models in viewer
m_set_color_by_element

Set color by element
m_style_cartoon

Specify Styling for Cartoon
m_remove_all_models

Delete all existing models
m_remove_all_shapes

Remove all shape objects from viewer
m_set_slab

Set slab of view
m_set_zoom_limits

Set lower and upper limit stops for zoom
m_rotate

Rotate scene by angle degrees around axis
m_set_style

Add Style to Selection
m_viewer_spec

Specifying setup options for viewer
xyz_multiple

Multiple xyz file example
m_vibrate

Add model's vibration
m_set_default_cartoon_quality

Set the default cartoon quality for newly created models
sdf_multiple

Multiple sdf file example
m_style_sphere

Specify Styling for Sphere
m_set_view

Sets the view to the specified translation, zoom, rotation and style
m_set_viewer

Set viewer properties
m_style_label

Specify Styling for Labels
m_set_hover_duration

Set the duration of the hover delay
m_style_stick

Specify Styling for Stick
r3dmol-shiny

Shiny bindings for r3dmol
m_zoom

Zoom current view by a constant factor
m_zoom_to

Zoom to center of atom selection
m_style_line

Specify Styling for Lines
m_add_custom

Add custom shape component from user supplied function
reexports

Objects exported from other packages
m_add_line

Add Lines Between Points
m_add_surface

Add surface representation to atoms
m_remove_all_surfaces

Remove all labels from viewer
m_add_models_as_frames

Create and add model to viewer
m_add_cylinder

Add Cylinder Between Points
m_animate

Animate all models in viewer from their respective frames
m_shape_spec

Specify Styling for Generic Shapes
m_vector3

Create a 3 dimensional vector
m_add_unit_cell

Unit cell visualization
m_remove_label

Remove label from viewer
m_shiny_demo

Run examples of using r3dmol in a Shiny app
m_translate

Translate current view or models by x,y screen coordinates
m_spin

Continuously rotate a scene around the specified axis
m_style_surface

Specify Styling for Surface