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

g3lollipops are stacked instead of replaced inside a Shiny g3LollipopOutput() element #2

Closed
diegollarrull opened this issue Apr 30, 2019 · 1 comment

Comments

@diegollarrull
Copy link

@diegollarrull diegollarrull commented Apr 30, 2019

HTML widgets don't get recycled when rendering g3viz plots inside a Shiny application. Please run the attached code snippet to verify its behaviour.

library(g3viz)

mutation.csv <- system.file("extdata", "ccle.csv", package = "g3viz")
selectize_values <- function(){
    return(levels(read.csv(mutation.csv, header = T)$Hugo_Symbol))
}


ui <- fluidPage(
    titlePanel("g3lollipop test"),
    sidebarLayout(
        sidebarPanel(
            selectizeInput("gene", "Elija un gen de la muestra", selectize_values())
        ),
        mainPanel(
            g3LollipopOutput("distPlot",width = "800px")
        )
    )
)

server <- function(input, output, session) {

    
    output$distPlot <- renderG3Lollipop({
    
        mutation.dat <- readMAF(mutation.csv,
                                gene.symbol.col = "Hugo_Symbol",
                                variant.class.col = "Variant_Classification",
                                protein.change.col = "amino_acid_change",
                                sep = ",")  # column-separator of csv file
        
        gene <- input$gene
        theme <- g3Lollipop.theme(theme.name = "cbioportal",
                         title.text = paste0(gene, " gene"),
                         y.axis.label = paste0("# of ", gene, " Mutations"))
        theme[['chartWidth']] <- "1600"
        
        g3Lollipop(mutation.dat,
                   gene.symbol = gene,
                   protein.change.col = "amino_acid_change",
                   plot.options = theme,
                   btn.style = "gray", 
                   output.filename = "customized_plot")
        
    })
}
shinyApp(ui = ui, server = server)

In this screenshot the unexpected behaviour is shown: after selecting two times a different gene, the second plot is created below the first one, instead of replacing it.

My current sessionInfo() is as follows:

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19.1

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=es_AR.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=es_AR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=es_AR.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] g3viz_1.1.1 shiny_1.3.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        rstudioapi_0.10   magrittr_1.5      xtable_1.8-3      R6_2.4.0         
 [6] rlang_0.3.4       stringr_1.4.0     tools_3.6.0       packrat_0.5.0     R.oo_1.22.0      
[11] htmltools_0.3.6   yaml_2.2.0        digest_0.6.18     crayon_1.3.4      cgdsr_1.2.10     
[16] later_0.8.0       htmlwidgets_1.4   promises_1.0.1    mime_0.6          stringi_1.4.3    
[21] compiler_3.6.0    R.methodsS3_1.7.1 jsonlite_1.6      httpuv_1.5.1
@phoeguo
Copy link
Contributor

@phoeguo phoeguo commented Apr 30, 2019

Fixed on Github, and it will be available on CRAN >= version 1.1.2.

Meanwhile, please use the development version from GItHub.

# install from github
devtools::install_github("g3viz/g3viz")

thanks

@phoeguo phoeguo closed this Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.