Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only color more than 2 residues in shiny (cartoon)? #10

Open
juan2089 opened this issue Apr 4, 2023 · 1 comment
Open

only color more than 2 residues in shiny (cartoon)? #10

juan2089 opened this issue Apr 4, 2023 · 1 comment

Comments

@juan2089
Copy link

juan2089 commented Apr 4, 2023

Hello there,
I am trying to use NGLViewer in Shiny.
I want to color a specific amino acid in the cartoon representation. However, it seems that NGL is only able to color the selection if I select more than one residue. Is anybody having the same issue?
Here is the code im using:

library(shiny)
library(NGLVieweR)


ui <- fluidPage(
          NGLVieweROutput("structure")
  )
server <- function(input, output) {
   output$structure <- renderNGLVieweR({
     NGLVieweR("3RY2") %>%
        addRepresentation("cartoon",
                         param = list(
                           name = "test",
                           colorValue = "red",
                           colorScheme = "element",
                           sele = "( 20 or 30 or 100 )"
                         )
       )
       
    
   })
  
 }
shinyApp(ui, server)

Also, do you know how to color by residue in a ball+stick or surface representation? I would like to color all atoms in a residue using the same color in any of those two representations.

Thank you in advance, NGLVieweR rocks!!

@nvelden
Copy link
Owner

nvelden commented Apr 5, 2023

Unfortunately, you need to select at least three consecutive residues to display the protein in the cartoon representation due to a restriction in the NGL.js library. However, for the ball and stick representation, you can select a single residue.

I hope the below example also answers your second question. For more examples see: link

library(shiny)
library(NGLVieweR)


ui <- fluidPage(NGLVieweROutput("structure"))
server <- function(input, output) {
  output$structure <- renderNGLVieweR({
    NGLVieweR("3RY2") %>%
      addRepresentation("cartoon",
                        param = list(
                          name = "test",
                          colorValue = "red",
                          colorScheme = "element"
                        )) %>%
      addRepresentation(
        "ball+stick",
        param = list(
          name = "test",
          colorValue = "green",
          colorScheme = "element",
          sele = "20"
        )) %>%
          addRepresentation(
            "ball+stick",
            param = list(
              name = "test",
              colorValue = "yellow",
              colorScheme = "element",
              sele = "19"
            ))

  })
    
}
shinyApp(ui, server)
```






Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants