Title: | Interactive 3D Visualization of Molecular Structures |
---|---|
Description: | Provides an 'htmlwidgets' <https://www.htmlwidgets.org/> interface to 'NGL.js' <http://nglviewer.org/ngl/api/>. 'NGLvieweR' can be used to visualize and interact with protein databank ('PDB') and structural files in R and Shiny applications. It includes a set of API functions to manipulate the viewer after creation in Shiny. |
Authors: | Niels van der Velden [aut, cre], Alexander Rose [cph] (NGL.js library) |
Maintainer: | Niels van der Velden <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.4.0 |
Built: | 2024-11-23 16:57:09 UTC |
Source: | CRAN |
Add a representation and its parameters.
addRepresentation(NGLVieweR, type, param = list())
addRepresentation(NGLVieweR, type, param = list())
NGLVieweR |
A NGLVieweR object. |
type |
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. |
param |
Options for the different types of representations. Most common
options are |
List of representation parameters to NGLVieweR
htmlwidgets
object.
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" ) ) # 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) }
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" ) ) # 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) }
Add a new selection to a NGLVieweR object in Shinymode.
addSelection(NGLVieweR_proxy, type, param = list(), structureIndex = NULL)
addSelection(NGLVieweR_proxy, type, param = list(), structureIndex = NULL)
NGLVieweR_proxy |
A NGLVieweR object. |
type |
Type of representation. Most common options are "cartoon", "ball+stick", "surface", "ribbon" and "label". |
param |
Options for the different types of representations. Most common
options are |
structureIndex |
(optional) The index of the specific structure to which the selection should be added (index 0 for the first). If not specified, the selection will be applied to all loaded structures. |
API call containing NGLVieweR
id
and list of message
parameters.
updateRepresentation()
Update an existing NGLVieweR representation.
NGLVieweR_example()
See example "addSelection".
Other selections:
removeSelection()
,
updateSelection()
## Not run: NGLVieweR_proxy("7CID") %>% addSelection("ball+stick", param = list(name="sel1", sele="1-20", colorValue="yellow", colorScheme="element" )) ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")), selectInput("color", "Color", c("orange", "grey", "white")), actionButton("add", "Add"), actionButton("remove", "Remove") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "residueindex") ) }) observeEvent(input$add, { NGLVieweR_proxy("structure") %>% addSelection(isolate(input$type), param = list( name = "sel1", sele = isolate(input$selection), colorValue = isolate(input$color) ) ) }) observeEvent(input$remove, { NGLVieweR_proxy("structure") %>% removeSelection("sel1") }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("7CID") %>% addSelection("ball+stick", param = list(name="sel1", sele="1-20", colorValue="yellow", colorScheme="element" )) ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")), selectInput("color", "Color", c("orange", "grey", "white")), actionButton("add", "Add"), actionButton("remove", "Remove") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "residueindex") ) }) observeEvent(input$add, { NGLVieweR_proxy("structure") %>% addSelection(isolate(input$type), param = list( name = "sel1", sele = isolate(input$selection), colorValue = isolate(input$color) ) ) }) observeEvent(input$remove, { NGLVieweR_proxy("structure") %>% removeSelection("sel1") }) } shinyApp(ui, server) }
Add a structure to the NGLVieweR object, either from a PDB entry code, a file, or directly from the R environment.
addStructure(NGLVieweR, data, format = NULL)
addStructure(NGLVieweR, data, format = NULL)
NGLVieweR |
A NGLVieweR object. |
data |
Structure data to be added. Can be a PDB entry code (e.g. "7CID"), a file path to a structure file, or a text representation of the structure. |
format |
Format of the structure file, if reading from a file. Supported formats are "pdb", "cif", etc. If the file format cannot be inferred from the file name, this parameter must be specified. |
This function allows you to add a structure to the NGLVieweR widget.
You can add the structure using a PDB entry code, by specifying a local
file, or by providing the structure data directly. If the format is not
clear from the input, you may need to specify it using the format
parameter.
An updated NGLVieweR object with the added structure.
NGLVieweR("1CRN") %>% addRepresentation("cartoon", param = list(color = "blue")) %>% addStructure("1CRN") %>% addRepresentation("cartoon", param = list(color = "orange")) %>% setPosition(x = 20, y = 0, z = 0) %>% setRotation(x = 2, y = 0, z = 0, degrees = FALSE) %>% setScale(0.5) # Note: The first "1CRN" structure is represented in blue, while the second # "1CRN" structure is represented in orange. Transformations such as # setPosition, setRotation, and setScale apply to the second # (most recently added) structure.
NGLVieweR("1CRN") %>% addRepresentation("cartoon", param = list(color = "blue")) %>% addStructure("1CRN") %>% addRepresentation("cartoon", param = list(color = "orange")) %>% setPosition(x = 20, y = 0, z = 0) %>% setRotation(x = 2, y = 0, z = 0, degrees = FALSE) %>% setScale(0.5) # Note: The first "1CRN" structure is represented in blue, while the second # "1CRN" structure is represented in orange. Transformations such as # setPosition, setRotation, and setScale apply to the second # (most recently added) structure.
NGLVieweR can be used to visualize and interact with Protein Data Bank (PDB) and structural files in R and Shiny applications. It includes a set of API functions to manipulate the viewer after creation in Shiny.
NGLVieweR(data, format = NULL, width = NULL, height = NULL, elementId = NULL)
NGLVieweR(data, format = NULL, width = NULL, height = NULL, elementId = NULL)
data |
PDB file or PDB entry code |
format |
Input format (.mmcif, .cif, .mcif, .pdb, .ent, .pqr, .gro, .sdf, .sd, .mol2, .mmtf). Needed when no file extension is provided. |
width , height
|
Must be a valid CSS unit (like |
elementId |
optional element Id |
The package is based on the NGL.js JavaScript library. To see the full set of features please read the official manual of NGL.js.
A NGLVieweR
htmlwidgets
object.
NGLVieweR_proxy()
for handling of API calls after rendering.
NGLVieweR_example()
See example "API" and "basic".
# Example 1: Most Basic NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme="residueindex")) # Example 2: Advanced NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white") %>% setQuality("high") %>% setSpin(FALSE) %>% addRepresentation("cartoon", param = list( name = "cartoon", colorScheme = "residueindex" ) ) %>% addRepresentation("ball+stick", param = list( name = "ball+stick", colorValue = "red", colorScheme = "element", sele = "200" ) ) %>% addRepresentation("label", param = list( name = "label", sele = "200:A.O", showBackground = TRUE, backgroundColor = "black", backgroundMargin = 2, backgroundOpacity = 0.5, showBorder = TRUE, colorValue = "white" ) ) %>% addRepresentation("surface", param = list( name = "surface", colorValue = "white", opacity = 0.1 ) ) %>% zoomMove("200", "200", 2000, -20) #---------------------Using Shiny------------------------- # App 1: Basic Example if (interactive()) { library(shiny) ui <- fluidPage(NGLVieweROutput("structure")) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list( name = "cartoon", colorScheme = "residueindex" ) ) %>% addRepresentation("ball+stick", param = list( name = "cartoon", sele = "1-20", colorScheme = "element" ) ) %>% stageParameters(backgroundColor = "black") %>% setQuality("high") %>% setFocus(0) %>% setSpin(TRUE) }) } shinyApp(ui, server) } # App 2: Example with API calls if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")), selectInput("color", "Color", c("orange", "grey", "white")), actionButton("add", "Add"), actionButton("remove", "Remove") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "residueindex") ) %>% stageParameters(backgroundColor = input$backgroundColor) %>% setQuality("high") %>% setFocus(0) %>% setSpin(TRUE) }) observeEvent(input$add, { NGLVieweR_proxy("structure") %>% addSelection(isolate(input$type), param = list( name = "sel1", sele = isolate(input$selection), colorValue = isolate(input$color) ) ) }) observeEvent(input$remove, { NGLVieweR_proxy("structure") %>% removeSelection("sel1") }) } shinyApp(ui, server) }
# Example 1: Most Basic NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme="residueindex")) # Example 2: Advanced NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white") %>% setQuality("high") %>% setSpin(FALSE) %>% addRepresentation("cartoon", param = list( name = "cartoon", colorScheme = "residueindex" ) ) %>% addRepresentation("ball+stick", param = list( name = "ball+stick", colorValue = "red", colorScheme = "element", sele = "200" ) ) %>% addRepresentation("label", param = list( name = "label", sele = "200:A.O", showBackground = TRUE, backgroundColor = "black", backgroundMargin = 2, backgroundOpacity = 0.5, showBorder = TRUE, colorValue = "white" ) ) %>% addRepresentation("surface", param = list( name = "surface", colorValue = "white", opacity = 0.1 ) ) %>% zoomMove("200", "200", 2000, -20) #---------------------Using Shiny------------------------- # App 1: Basic Example if (interactive()) { library(shiny) ui <- fluidPage(NGLVieweROutput("structure")) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list( name = "cartoon", colorScheme = "residueindex" ) ) %>% addRepresentation("ball+stick", param = list( name = "cartoon", sele = "1-20", colorScheme = "element" ) ) %>% stageParameters(backgroundColor = "black") %>% setQuality("high") %>% setFocus(0) %>% setSpin(TRUE) }) } shinyApp(ui, server) } # App 2: Example with API calls if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")), selectInput("color", "Color", c("orange", "grey", "white")), actionButton("add", "Add"), actionButton("remove", "Remove") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "residueindex") ) %>% stageParameters(backgroundColor = input$backgroundColor) %>% setQuality("high") %>% setFocus(0) %>% setSpin(TRUE) }) observeEvent(input$add, { NGLVieweR_proxy("structure") %>% addSelection(isolate(input$type), param = list( name = "sel1", sele = isolate(input$selection), colorValue = isolate(input$color) ) ) }) observeEvent(input$remove, { NGLVieweR_proxy("structure") %>% removeSelection("sel1") }) } shinyApp(ui, server) }
Launch an example to demonstrate how to use NGLvieweR
in
Shiny.
NGLVieweR_example(example = "basic")
NGLVieweR_example(example = "basic")
example |
Example type for which to see an example, possible values are: "basic", "API", "addSelection", "removeSelection", "snapshot", "updateAnimation", "updateColor", "updateFocus", "updateFullscreen", "updateRepresentation", "updateSelection", "updateStage", "updateVisibility", "updateZoomMove", "multiStructureSelection". |
Call to load Shiny example.
if (interactive()) { # Basic example NGLVieweR_example("basic") # Example with API calls NGLVieweR_example("API") # Function specific example NGLVieweR_example("addSelection") }
if (interactive()) { # Basic example NGLVieweR_example("basic") # Example with API calls NGLVieweR_example("API") # Function specific example NGLVieweR_example("addSelection") }
Output and render functions for using NGLVieweR within Shiny applications and interactive Rmd documents.
NGLVieweROutput(outputId, width = "100%", height = "400px") renderNGLVieweR(expr, env = parent.frame(), quoted = FALSE) NGLVieweR_proxy(id, session = shiny::getDefaultReactiveDomain())
NGLVieweROutput(outputId, width = "100%", height = "400px") renderNGLVieweR(expr, env = parent.frame(), quoted = FALSE) NGLVieweR_proxy(id, session = shiny::getDefaultReactiveDomain())
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a NGLVieweR. |
env |
The environment in which to evaluate |
quoted |
Is |
id |
single-element character vector indicating the output ID of the chart to modify (if invoked from a Shiny module, the namespace will be added automatically) |
session |
The Shiny session object to which the map belongs; usually the default value will suffice. |
NGLVieweR
object that can be placed in the UI.
if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")), selectInput("color", "Color", c("orange", "grey", "white")), actionButton("add", "Add"), actionButton("remove", "Remove") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "residueindex") ) %>% stageParameters(backgroundColor = input$backgroundColor) %>% setQuality("high") %>% setFocus(0) %>% setSpin(TRUE) }) observeEvent(input$add, { NGLVieweR_proxy("structure") %>% addSelection(isolate(input$type), param = list( name = "sel1", sele = isolate(input$selection), color = isolate(input$color) ) ) }) observeEvent(input$remove, { NGLVieweR_proxy("structure") %>% removeSelection("sel1") }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")), selectInput("color", "Color", c("orange", "grey", "white")), actionButton("add", "Add"), actionButton("remove", "Remove") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "residueindex") ) %>% stageParameters(backgroundColor = input$backgroundColor) %>% setQuality("high") %>% setFocus(0) %>% setSpin(TRUE) }) observeEvent(input$add, { NGLVieweR_proxy("structure") %>% addSelection(isolate(input$type), param = list( name = "sel1", sele = isolate(input$selection), color = isolate(input$color) ) ) }) observeEvent(input$remove, { NGLVieweR_proxy("structure") %>% removeSelection("sel1") }) } shinyApp(ui, server) }
Remove an existing NGLVieweR selection in Shinymode.
removeSelection(NGLVieweR_proxy, name)
removeSelection(NGLVieweR_proxy, name)
NGLVieweR_proxy |
A NGLVieweR object. |
name |
Name of selection to be removed. |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "removeSelection".
Other selections:
addSelection()
,
updateSelection()
## Not run: NGLVieweR_proxy("structure") %>% removeSelection("sel1") ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")), selectInput("color", "Color", c("orange", "grey", "white")), actionButton("add", "Add"), actionButton("remove", "Remove") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "residueindex") ) }) observeEvent(input$add, { NGLVieweR_proxy("structure") %>% addSelection(isolate(input$type), param = list( name = "sel1", sele = isolate(input$selection), colorValue = isolate(input$color) ) ) }) observeEvent(input$remove, { NGLVieweR_proxy("structure") %>% removeSelection("sel1") }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% removeSelection("sel1") ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")), selectInput("color", "Color", c("orange", "grey", "white")), actionButton("add", "Add"), actionButton("remove", "Remove") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "residueindex") ) }) observeEvent(input$add, { NGLVieweR_proxy("structure") %>% addSelection(isolate(input$type), param = list( name = "sel1", sele = isolate(input$selection), colorValue = isolate(input$color) ) ) }) observeEvent(input$remove, { NGLVieweR_proxy("structure") %>% removeSelection("sel1") }) } shinyApp(ui, server) }
Set selection parameters.
selectionParameters(NGLVieweR, proximity = 3, level = "residue")
selectionParameters(NGLVieweR, proximity = 3, level = "residue")
NGLVieweR |
A NGLVieweR object. |
proximity |
Set distance in angstrom for atoms to return in proximity of
selection. Default = |
level |
Set level on which atoms in proximity of selection are returned. Options are "residue" (default) or atom". |
Returns list of selection parameters to NGLVieweR
htmlwidgets
object.
NGLVieweR("7CID") %>% addRepresentation("cartoon") %>% selectionParameters(3, "residue") # Shiny context if (interactive()) { library(shiny) ui <- fluidPage(NGLVieweROutput("structure")) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon") %>% selectionParameters(3, "residue") }) observeEvent(input$structure_selAround, { NGLVieweR_proxy("structure") %>% removeSelection("selAround") NGLVieweR_proxy("structure") %>% addSelection( "ball+stick", param = list( name = "selAround", sele = input$structure_selAround, colorValue = "grey" ) ) }) } shinyApp(ui, server) }
NGLVieweR("7CID") %>% addRepresentation("cartoon") %>% selectionParameters(3, "residue") # Shiny context if (interactive()) { library(shiny) ui <- fluidPage(NGLVieweROutput("structure")) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon") %>% selectionParameters(3, "residue") }) observeEvent(input$structure_selAround, { NGLVieweR_proxy("structure") %>% removeSelection("selAround") NGLVieweR_proxy("structure") %>% addSelection( "ball+stick", param = list( name = "selAround", sele = input$structure_selAround, colorValue = "grey" ) ) }) } shinyApp(ui, server) }
Set Focus
setFocus(NGLVieweR, focus = 0)
setFocus(NGLVieweR, focus = 0)
NGLVieweR |
A NGLVieweR object. |
focus |
Set focus between 0 (default) to 100. |
setFocus parameter in NGLVieweR
htmlwidgets
object.
Other options:
setQuality()
,
snapShot()
,
updateFocus()
,
updateFullscreen()
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setFocus(0)
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setFocus(0)
Set position for the representation
setPosition(NGLVieweR, x = 0, y = 0, z = 0)
setPosition(NGLVieweR, x = 0, y = 0, z = 0)
NGLVieweR |
A NGLVieweR object. |
x |
Position along the x-axis in angstroms. Default is 0. |
y |
Position along the y-axis in angstroms. Default is 0. |
z |
Position along the z-axis in angstroms. Default is 0. |
NGLVieweR object with updated setPosition parameters.
Other transformations:
setRotation()
,
setScale()
,
zoomMove()
NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="red")) %>% addRepresentation("ball+stick", param=list(name="ball+stick", colorValue="yellow", colorScheme="element", sele="200")) %>% setPosition(25, 0, 0)
NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="red")) %>% addRepresentation("ball+stick", param=list(name="ball+stick", colorValue="yellow", colorScheme="element", sele="200")) %>% setPosition(25, 0, 0)
Set Quality
setQuality(NGLVieweR, quality = "medium")
setQuality(NGLVieweR, quality = "medium")
NGLVieweR |
A NGLVieweR object. |
quality |
Set rendering quality. Can be "low", "medium" (default) or "high". |
setQuality parameter in NGLVieweR
htmlwidgets
object.
Other options:
setFocus()
,
snapShot()
,
updateFocus()
,
updateFullscreen()
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setQuality("medium")
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setQuality("medium")
Set rock animation
setRock(NGLVieweR, rock = TRUE)
setRock(NGLVieweR, rock = TRUE)
NGLVieweR |
A NGLVieweR object. |
rock |
If |
setRock parameter to TRUE
or FALSE
in NGLVieweR
htmlwidgets
object.
Other animations:
setSpin()
,
updateRock()
,
updateSpin()
,
updateZoomMove()
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setRock(TRUE)
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setRock(TRUE)
Set rotation for the representation
setRotation(NGLVieweR, x = 0, y = 0, z = 0, degrees = TRUE)
setRotation(NGLVieweR, x = 0, y = 0, z = 0, degrees = TRUE)
NGLVieweR |
A NGLVieweR object. |
x |
Rotation angle around the x-axis. Default is 0. |
y |
Rotation angle around the y-axis. Default is 0. |
z |
Rotation angle around the z-axis. Default is 0. |
degrees |
A logical value. If TRUE (default), the input angles are assumed to be in degrees and will be converted to radians. If FALSE, the angles are assumed to be in radians. |
NGLVieweR object with updated rotateView parameters.
Other transformations:
setPosition()
,
setScale()
,
zoomMove()
NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="red")) %>% addRepresentation("ball+stick", param=list(name="ball+stick", colorValue="yellow", colorScheme="element", sele="200")) %>% setRotation(30, 45, 60, degrees = TRUE)
NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="red")) %>% addRepresentation("ball+stick", param=list(name="ball+stick", colorValue="yellow", colorScheme="element", sele="200")) %>% setRotation(30, 45, 60, degrees = TRUE)
Set the scale factor for the representation
setScale(NGLVieweR, scale = 1)
setScale(NGLVieweR, scale = 1)
NGLVieweR |
A NGLVieweR object. |
scale |
A numeric value indicating the scale factor (default is 1). |
Updated NGLVieweR
object with new scale parameter.
Other transformations:
setPosition()
,
setRotation()
,
zoomMove()
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setScale(2)
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setScale(2)
Set Spin animation
setSpin(NGLVieweR, spin = TRUE)
setSpin(NGLVieweR, spin = TRUE)
NGLVieweR |
A NGLVieweR object. |
spin |
If |
setSpin parameter to TRUE
or FALSE
in NGLVieweR
htmlwidgets
object.
Other animations:
setRock()
,
updateRock()
,
updateSpin()
,
updateZoomMove()
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setSpin(TRUE)
NGLVieweR("7CID") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="blue")) %>% setSpin(TRUE)
Enable or disable superposition of multiple structures, with options to specify the reference structure and selection strings for alignment.
setSuperpose( NGLVieweR, reference = 1, sele_reference, sele_target, superpose = TRUE )
setSuperpose( NGLVieweR, reference = 1, sele_reference, sele_target, superpose = TRUE )
NGLVieweR |
A NGLVieweR object. |
reference |
The index of the reference structure to align other structures to. Defaults to 1 (the first loaded structure). |
sele_reference |
Selection string for the reference structure, specifying which parts to align. Mandatory. |
sele_target |
Selection string for each target structure, specifying which parts to align. Mandatory. |
superpose |
Logical; if |
Sets the superpose
list in the NGLVieweR
htmlwidgets
object.
NGLVieweR("1GZM") %>% addRepresentation("cartoon", param = list(color = "blue")) %>% addStructure("1U19") %>% addRepresentation("cartoon", param = list(color = "orange")) %>% setSuperpose( reference = 1, sele_reference = ":A", sele_target = ":A", superpose = TRUE )
NGLVieweR("1GZM") %>% addRepresentation("cartoon", param = list(color = "blue")) %>% addStructure("1U19") %>% addRepresentation("cartoon", param = list(color = "orange")) %>% setSuperpose( reference = 1, sele_reference = ":A", sele_target = ":A", superpose = TRUE )
Make a snapshot of a NGLVieweR object in Shinymode.
snapShot(NGLVieweR_proxy, fileName = "Snapshot", param = list())
snapShot(NGLVieweR_proxy, fileName = "Snapshot", param = list())
NGLVieweR_proxy |
A NGLVieweR object. |
fileName |
Optional name for Snapshot (default = "Snapshot"). |
param |
Of type list, can be; antialias |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "snapshot".
Other options:
setFocus()
,
setQuality()
,
updateFocus()
,
updateFullscreen()
## Not run: NGLVieweR_proxy("structure") %>% snapShot("Snapshot", param = list( antialias = TRUE, trim = TRUE, transparent = TRUE, scale = 1)) ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( actionButton("snapshot", "Snapshot"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list( name = "cartoon", color = "residueindex" ) ) }) observeEvent(input$snapshot, { NGLVieweR_proxy("structure") %>% snapShot("Snapshot", param = list( antialias = TRUE, trim = TRUE, transparent = TRUE, scale = 1 ) ) }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% snapShot("Snapshot", param = list( antialias = TRUE, trim = TRUE, transparent = TRUE, scale = 1)) ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( actionButton("snapshot", "Snapshot"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list( name = "cartoon", color = "residueindex" ) ) }) observeEvent(input$snapshot, { NGLVieweR_proxy("structure") %>% snapShot("Snapshot", param = list( antialias = TRUE, trim = TRUE, transparent = TRUE, scale = 1 ) ) }) } shinyApp(ui, server) }
Set stage parameters.
stageParameters(NGLVieweR, ...)
stageParameters(NGLVieweR, ...)
NGLVieweR |
A NGLVieweR object. |
... |
Options controlling the stage. Most common options are
|
Returns list of stage parameters to NGLVieweR
htmlwidgets
object.
NGLVieweR_example()
See example "basic".
NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white", zoomSpeed = 1) %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme="residueindex")) if (interactive()) { library(shiny) ui <- fluidPage(NGLVieweROutput("structure")) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white", zoomSpeed = 1) %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "residueindex") ) }) } shinyApp(ui, server) }
NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white", zoomSpeed = 1) %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme="residueindex")) if (interactive()) { library(shiny) ui <- fluidPage(NGLVieweROutput("structure")) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white", zoomSpeed = 1) %>% addRepresentation("cartoon", param = list(name = "cartoon", colorScheme = "residueindex") ) }) } shinyApp(ui, server) }
Update color of an existing NGLVieweR selection in Shinymode.
updateColor(NGLVieweR_proxy, name, color)
updateColor(NGLVieweR_proxy, name, color)
NGLVieweR_proxy |
A NGLVieweR object. |
name |
Name of selection to alter the color. |
color |
Can be a colorValue (color name or HEX code) or colorScheme (e.g. "element", "resname", "random" or "residueindex"). For a full list of options, see the "Colormaker" section in the official NGL.js manual. |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateColor".
Other updates:
updateRepresentation()
,
updateStage()
,
updateVisibility()
## Not run: NGLVieweR_proxy("structure") %>% updateColor("cartoon", "red") ## End(Not run) if (interactive()) { library(shiny) library(colourpicker) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( colourInput("color", "red", "red"), actionButton("update", "Update"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "residueindex") ) }) observeEvent(input$update, { NGLVieweR_proxy("structure") %>% updateColor("cartoon", isolate(input$color)) }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateColor("cartoon", "red") ## End(Not run) if (interactive()) { library(shiny) library(colourpicker) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( colourInput("color", "red", "red"), actionButton("update", "Update"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "residueindex") ) }) observeEvent(input$update, { NGLVieweR_proxy("structure") %>% updateColor("cartoon", isolate(input$color)) }) } shinyApp(ui, server) }
Update the focus of an existing NGLVieweR object in Shinymode.
updateFocus(NGLVieweR_proxy, focus = 0)
updateFocus(NGLVieweR_proxy, focus = 0)
NGLVieweR_proxy |
A NGLVieweR object. |
focus |
Numeric value between 0-100 (default = 0). |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateFocus".
Other options:
setFocus()
,
setQuality()
,
snapShot()
,
updateFullscreen()
## Not run: NGLVieweR_proxy("structure") %>% updateFocus(focus = 50) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( sliderInput("focus", "Focus", 0, 100, 50) ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color= "red")) }) observeEvent(input$focus, { NGLVieweR_proxy("structure") %>% updateFocus(input$focus) }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateFocus(focus = 50) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( sliderInput("focus", "Focus", 0, 100, 50) ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color= "red")) }) observeEvent(input$focus, { NGLVieweR_proxy("structure") %>% updateFocus(input$focus) }) } shinyApp(ui, server) }
Put viewer in fullscreen. Works in Shinymode.
updateFullscreen(NGLVieweR_proxy, fullscreen = TRUE)
updateFullscreen(NGLVieweR_proxy, fullscreen = TRUE)
NGLVieweR_proxy |
A NGLVieweR object. |
fullscreen |
If |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateFullscreen".
Other options:
setFocus()
,
setQuality()
,
snapShot()
,
updateFocus()
## Not run: NGLVieweR_proxy("structure") %>% updateFullscreen() ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( actionButton("fullscreen", "Fullscreen"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "red") ) }) observeEvent(input$fullscreen, { NGLVieweR_proxy("structure") %>% updateFullscreen() }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateFullscreen() ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( actionButton("fullscreen", "Fullscreen"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "red") ) }) observeEvent(input$fullscreen, { NGLVieweR_proxy("structure") %>% updateFullscreen() }) } shinyApp(ui, server) }
Update an existing NGLVieweR representation in Shinymode.
updateRepresentation(NGLVieweR_proxy, name, param = list())
updateRepresentation(NGLVieweR_proxy, name, param = list())
NGLVieweR_proxy |
A NGLVieweR object. |
name |
Name of representation to alter the color. |
param |
Options for the different types of representations. Most common
options are |
API call containing NGLVieweR
id
and list of message
parameters.
addSelection()
Add a new selection to a NGLVieweR object.
NGLVieweR_example()
See example "updateRepresentation".
Other updates:
updateColor()
,
updateStage()
,
updateVisibility()
## Not run: NGLVieweR_proxy("structure") %>% updateRepresentation("cartoon", param = list( name = "cartoon", color = isolate(input$color), opacity = isolate(input$opacity) ) ) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( selectInput("color", "Color", c("red", "white", "blue")), sliderInput("opacity", "Opacity", 0, 1, 1), actionButton("update", "Update"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) }) observeEvent(input$update, { NGLVieweR_proxy("structure") %>% updateRepresentation("cartoon", param = list( color = isolate(input$color), opacity = isolate(input$opacity) ) ) }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateRepresentation("cartoon", param = list( name = "cartoon", color = isolate(input$color), opacity = isolate(input$opacity) ) ) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( selectInput("color", "Color", c("red", "white", "blue")), sliderInput("opacity", "Opacity", 0, 1, 1), actionButton("update", "Update"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) }) observeEvent(input$update, { NGLVieweR_proxy("structure") %>% updateRepresentation("cartoon", param = list( color = isolate(input$color), opacity = isolate(input$opacity) ) ) }) } shinyApp(ui, server) }
Start rock animation and stop spinning. Works on an existing NGLVieweR object in Shinymode.
updateRock(NGLVieweR_proxy, rock = TRUE)
updateRock(NGLVieweR_proxy, rock = TRUE)
NGLVieweR_proxy |
A NGLVieweR object. |
rock |
If |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateAnimation".
Other animations:
setRock()
,
setSpin()
,
updateSpin()
,
updateZoomMove()
## Not run: NGLVieweR_proxy("structure") %>% updateRock(TRUE) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( radioButtons("animate", label = "Animation", choices = c("None", "Spin", "Rock"), selected = "None") ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) }) observeEvent(input$animate,{ if(input$animate == "Rock"){ NGLVieweR_proxy("structure") %>% updateRock(TRUE) } else if(input$animate == "Spin") { NGLVieweR_proxy("structure") %>% updateSpin(TRUE) } else{ NGLVieweR_proxy("structure") %>% updateRock(FALSE) %>% updateSpin(FALSE) } }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateRock(TRUE) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( radioButtons("animate", label = "Animation", choices = c("None", "Spin", "Rock"), selected = "None") ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) }) observeEvent(input$animate,{ if(input$animate == "Rock"){ NGLVieweR_proxy("structure") %>% updateRock(TRUE) } else if(input$animate == "Spin") { NGLVieweR_proxy("structure") %>% updateSpin(TRUE) } else{ NGLVieweR_proxy("structure") %>% updateRock(FALSE) %>% updateSpin(FALSE) } }) } shinyApp(ui, server) }
Update the selected residues of an existing NGLVieweR selection in
updateSelection(NGLVieweR_proxy, name = name, sele = "none")
updateSelection(NGLVieweR_proxy, name = name, sele = "none")
NGLVieweR_proxy |
A NGLVieweR object. |
name |
Name of selection. |
sele |
Selected atoms/residues. See the section "selection-language" in the official NGL.js manual. |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateSelection".
Other selections:
addSelection()
,
removeSelection()
## Not run: NGLVieweR_proxy("structure") %>% updateSelection("ball+stick", sele = "1-20") ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), actionButton("update", "Update") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "red") ) %>% addRepresentation("ball+stick", param = list( name = "ball+stick", colorValue = "yellow", colorScheme = "element", sele = "1-20" ) ) }) observeEvent(input$update, { NGLVieweR_proxy("structure") %>% updateSelection("ball+stick", sele = isolate(input$selection)) }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateSelection("ball+stick", sele = "1-20") ## End(Not run) if (interactive()) { library(shiny) ui <- fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("selection", "Selection", "1-20"), actionButton("update", "Update") ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "red") ) %>% addRepresentation("ball+stick", param = list( name = "ball+stick", colorValue = "yellow", colorScheme = "element", sele = "1-20" ) ) }) observeEvent(input$update, { NGLVieweR_proxy("structure") %>% updateSelection("ball+stick", sele = isolate(input$selection)) }) } shinyApp(ui, server) }
Start spin animation and stop rocking. Works on an existing NGLVieweR object in Shinymode.
updateSpin(NGLVieweR_proxy, spin = TRUE)
updateSpin(NGLVieweR_proxy, spin = TRUE)
NGLVieweR_proxy |
A NGLVieweR object. |
spin |
If |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateAnimation".
Other animations:
setRock()
,
setSpin()
,
updateRock()
,
updateZoomMove()
## Not run: NGLVieweR_proxy("structure") %>% updateRock(TRUE) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( radioButtons("animate", label = "Animation", choices = c("None", "Spin", "Rock"), selected = "None") ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) }) observeEvent(input$animate,{ if(input$animate == "Rock"){ NGLVieweR_proxy("structure") %>% updateRock(TRUE) } else if(input$animate == "Spin") { NGLVieweR_proxy("structure") %>% updateSpin(TRUE) } else{ NGLVieweR_proxy("structure") %>% updateRock(FALSE) %>% updateSpin(FALSE) } }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateRock(TRUE) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( radioButtons("animate", label = "Animation", choices = c("None", "Spin", "Rock"), selected = "None") ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) }) observeEvent(input$animate,{ if(input$animate == "Rock"){ NGLVieweR_proxy("structure") %>% updateRock(TRUE) } else if(input$animate == "Spin") { NGLVieweR_proxy("structure") %>% updateSpin(TRUE) } else{ NGLVieweR_proxy("structure") %>% updateRock(FALSE) %>% updateSpin(FALSE) } }) } shinyApp(ui, server) }
Update an existing NGLVieweR stage in Shinymode.
updateStage(NGLVieweR_proxy, param = list())
updateStage(NGLVieweR_proxy, param = list())
NGLVieweR_proxy |
A NGLVieweR object. |
param |
Of type list. Most common options are |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateStage".
Other updates:
updateColor()
,
updateRepresentation()
,
updateVisibility()
## Not run: NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) %>% stageParameters(backgroundColor = "black") ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( selectInput("background", "Background", c("black", "white", "blue")), actionButton("update", "Update"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "red") ) %>% stageParameters(backgroundColor = "black") }) observeEvent(input$update, { NGLVieweR_proxy("structure") %>% updateStage( param = list("backgroundColor" = isolate(input$background))) }) } shinyApp(ui, server) }
## Not run: NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) %>% stageParameters(backgroundColor = "black") ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( selectInput("background", "Background", c("black", "white", "blue")), actionButton("update", "Update"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server <- function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color = "red") ) %>% stageParameters(backgroundColor = "black") }) observeEvent(input$update, { NGLVieweR_proxy("structure") %>% updateStage( param = list("backgroundColor" = isolate(input$background))) }) } shinyApp(ui, server) }
Hide or show an existing NGLVieweR selection in Shinymode.
updateVisibility(NGLVieweR_proxy, name, value = FALSE)
updateVisibility(NGLVieweR_proxy, name, value = FALSE)
NGLVieweR_proxy |
A NGLVieweR object. |
name |
Name of selection to alter the color. |
value |
Hide |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateVisibility".
Other updates:
updateColor()
,
updateRepresentation()
,
updateStage()
## Not run: NGLVieweR_proxy("structure") %>% updateVisibility("cartoon", value = TRUE) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( actionButton("show", "Show"), actionButton("hide", "Hide"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="residueindex")) }) observeEvent(input$show, { NGLVieweR_proxy("structure") %>% updateVisibility("cartoon", value = TRUE) }) observeEvent(input$hide, { NGLVieweR_proxy("structure") %>% updateVisibility("cartoon", value = FALSE) }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateVisibility("cartoon", value = TRUE) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( actionButton("show", "Show"), actionButton("hide", "Hide"), ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="residueindex")) }) observeEvent(input$show, { NGLVieweR_proxy("structure") %>% updateVisibility("cartoon", value = TRUE) }) observeEvent(input$hide, { NGLVieweR_proxy("structure") %>% updateVisibility("cartoon", value = FALSE) }) } shinyApp(ui, server) }
Add a zoom animation on an existing NGLVieweR object.
updateZoomMove( NGLVieweR_proxy, center, zoom, duration = 0, z_offSet = 0, structureIndex = NULL )
updateZoomMove( NGLVieweR_proxy, center, zoom, duration = 0, z_offSet = 0, structureIndex = NULL )
NGLVieweR_proxy |
A NGLVieweR object. |
center |
Target distance of selected atoms/residues. See the section "selection-language" in the official NGL.js manual. |
zoom |
Target zoom of selected atoms/residues. See the section "selection-language" in the official NGL.js manual. |
duration |
Optional animation time in milliseconds (default = 0). |
z_offSet |
Optional zoom offset value (default = 0). |
structureIndex |
Optional index of the structure to target for the zoom
animation. If |
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updatezoomMove".
Other animations:
setRock()
,
setSpin()
,
updateRock()
,
updateSpin()
## Not run: NGLVieweR_proxy("structure") %>% updateZoomMove(center = "200", zoom = "200", z_offSet = 80, duration = 2000) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("center", "Center", "200"), textInput("zoom", "Zoom", "200"), numericInput("zoomOffset", "Zoom offset", 80,0,100), numericInput("duration", "Duration", 2000,0,2000), actionButton("zoom", "Zoom"), actionButton("reset", "Reset") ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) %>% addRepresentation("ball+stick", param = list(name = "ball+stick", sele="200")) }) observeEvent(input$zoom, { NGLVieweR_proxy("structure") %>% updateZoomMove( center = isolate(input$center), zoom = isolate(input$zoom), z_offSet = isolate(input$zoomOffset), duration = isolate(input$duration) ) }) observeEvent(input$reset, { NGLVieweR_proxy("structure") %>% updateZoomMove( center = "*", zoom = "*", z_offSet = 0, duration = 1000 ) }) } shinyApp(ui, server) }
## Not run: NGLVieweR_proxy("structure") %>% updateZoomMove(center = "200", zoom = "200", z_offSet = 80, duration = 2000) ## End(Not run) if (interactive()) { library(shiny) ui = fluidPage( titlePanel("Viewer with API inputs"), sidebarLayout( sidebarPanel( textInput("center", "Center", "200"), textInput("zoom", "Zoom", "200"), numericInput("zoomOffset", "Zoom offset", 80,0,100), numericInput("duration", "Duration", 2000,0,2000), actionButton("zoom", "Zoom"), actionButton("reset", "Reset") ), mainPanel( NGLVieweROutput("structure") ) ) ) server = function(input, output) { output$structure <- renderNGLVieweR({ NGLVieweR("7CID") %>% addRepresentation("cartoon", param = list(name = "cartoon", color="red")) %>% addRepresentation("ball+stick", param = list(name = "ball+stick", sele="200")) }) observeEvent(input$zoom, { NGLVieweR_proxy("structure") %>% updateZoomMove( center = isolate(input$center), zoom = isolate(input$zoom), z_offSet = isolate(input$zoomOffset), duration = isolate(input$duration) ) }) observeEvent(input$reset, { NGLVieweR_proxy("structure") %>% updateZoomMove( center = "*", zoom = "*", z_offSet = 0, duration = 1000 ) }) } shinyApp(ui, server) }
Add a zoom animation
zoomMove(NGLVieweR, center, zoom, duration = 0, z_offSet = 0)
zoomMove(NGLVieweR, center, zoom, duration = 0, z_offSet = 0)
NGLVieweR |
A NGLVieweR object. |
center |
Target distance of selected atoms/residues. See the section "selection-language" in the official NGL.js manual. |
zoom |
Target zoom of selected atoms/residues. See the section "selection-language" in the official NGL.js manual. |
duration |
Optional animation time in milliseconds (default = 0). |
z_offSet |
Optional zoom offset value (default = 0). |
List of zoomMove parameters to NGLVieweR
htmlwidgets
object.
Other transformations:
setPosition()
,
setRotation()
,
setScale()
NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="red")) %>% addRepresentation("ball+stick", param=list(name="ball+stick", colorValue="yellow", colorScheme="element", sele="200")) %>% zoomMove("200:A.C", "200:A.C", 2000, -20)
NGLVieweR("7CID") %>% stageParameters(backgroundColor = "white") %>% addRepresentation("cartoon", param=list(name="cartoon", colorValue="red")) %>% addRepresentation("ball+stick", param=list(name="ball+stick", colorValue="yellow", colorScheme="element", sele="200")) %>% zoomMove("200:A.C", "200:A.C", 2000, -20)