Dear mixOmics team,
I’m trying to display a plotIndiv graph in a shiny dashboard tabPanel.
I declare a function to load and parse my dataset, compute a PCA to finaly plot individuals (mixOmics pca and plotIndiv).
Independently, this function works well, but when is integrated in shiny it doesn’t.
Any tricks ? Thanks.
Xavier.
Ubuntu 18.04
R4.0.5
Rstudio
Hi @xgrand ,
Are you sure you set up the shiny input/output correctly? This does work just fine for me using the following app:
library(shiny)
library(mixOmics)
# Define UI for application that draws a histogram
ui <- fluidPage(
titlePanel("plotIndiv"),
sidebarLayout(
sidebarPanel(
numericInput('pc1', 'First PC', value=1,
min=1, max=5, step=1),
numericInput('pc2', 'Second PC', value=2,
min=1, max=5, step=1)
),
mainPanel(plotOutput("plotIndiv"))
)
)
server <- function(input, output) {
output$plotIndiv <- renderPlot({
data(multidrug)
comp <- c(input$pc1, input$pc2)
pca.res <- pca(multidrug$ABC.trans, ncomp = 5, scale = TRUE)
# biplot(pca.res, group = multidrug$cell.line$Class, legend.title = 'Class')
# samples representation
plotIndiv(pca.res, comp = comp, ind.names = multidrug$cell.line$Class,
group = as.numeric(as.factor(multidrug$cell.line$Class)))
})
}
# Run the application
shinyApp(ui = ui, server = server)
Can you check and see if it works on your machine as well?
Best,
Al
xgrand
June 24, 2021, 4:08pm
3
Yes, it was something like input/output setup. Many thanks !
Xavier.