Add a representation and its parameters.
addRepresentation(NGLVieweR, type, param = list())A NGLVieweR object.
Type of representation. Most common options are "cartoon", "ball+stick", "line", "surface", "ribbon" and "label". For a full list of options, see the "structureRepresentation" method in the official NGL.js manual.
Options for the different types of representations. Most common
options are name, opacity, colorScheme, sele,
colorValue and visibility. For a full list of options, see the
general "RepresentationParameters" method and type specific Label-,
Structure- and Surface- RepresentationParameters in the official
NGL.js manual.
List of representation parameters to NGLVieweR
htmlwidgets object.
type and param are passed to NGL.js as they are, so
every NGL.js representation and parameter works, including ones not
listed above. Some useful ones:
Other styles: "spacefill", "licorice", "hyperball", "backbone", "trace", "tube", "rope", "rocket", "point", "axes", "helixorient", "unitcell" and "contact".
Measurements: "distance" (atomPair), "angle"
(atomTriple) and "dihedral" (atomQuad). Give each as a list
of selections, e.g. atomPair = list(list("1.CA", "20.CA")). These
are only drawn; the measured values are not returned to R or Shiny.
Biological assemblies and crystal packing: the assembly
parameter shows a biological unit such as "BU1", the unit cell
("UNITCELL") or a 3x3x3 block of unit cells ("SUPERCELL"). The default
is the asymmetric unit ("AU"). Only assemblies defined in the file can
be shown.
NGLVieweR_example() See example "basic".
NGLVieweR("7CID") %>%
stageParameters(backgroundColor = "black") %>%
addRepresentation("cartoon",
param = list(name = "cartoon", colorValue = "blue")) %>%
addRepresentation("ball+stick",
param = list(
name = "ball+stick", sele = "241",
colorScheme = "element", colorValue = "yellow"
)
) %>%
addRepresentation("label",
param = list(
name = "label",
showBackground = TRUE,
labelType = "res",
color = "black",
backgroundColor = "white",
backgroundOpacity = 0.8,
sele = ":A and 241 and .CG"
)
)
# Biological assembly
NGLVieweR("1RUZ") %>%
addRepresentation("cartoon", param = list(assembly = "BU1"))
# Distance measurement
NGLVieweR("1CRN") %>%
addRepresentation("cartoon") %>%
addRepresentation("distance",
param = list(atomPair = list(list("1.CA", "20.CA")))
)
# Shiny context
if (interactive()) {
library(shiny)
ui <- fluidPage(NGLVieweROutput("structure"))
server <- function(input, output) {
output$structure <- renderNGLVieweR({
NGLVieweR("7CID") %>%
stageParameters(backgroundColor = "black") %>%
addRepresentation("cartoon",
param = list(name = "cartoon", colorValue = "blue")
) %>%
addRepresentation("ball+stick",
param = list(
name = "ball+stick", sele = "241",
colorScheme = "element"
)
) %>%
addRepresentation("label",
param = list(
name = "label",
showBackground = TRUE,
labelType = "res",
colorValue = "black",
backgroundColor = "white",
backgroundOpacity = 0.8,
sele = ":A and 241 and .CG"
)
)
})
}
shinyApp(ui, server)
}