Commit 938fa757 authored by Jean-Karim Heriche's avatar Jean-Karim Heriche

Fixed missing treatment info when using plate view. Removed some redundant...

Fixed missing treatment info when using plate view. Removed some redundant setting of reactive values.
parent 83b2edb3
......@@ -7,12 +7,12 @@ RUN apt-get install -y openjdk-8-jdk
# Install required R packages
RUN R CMD javareconf
RUN R -e "install.packages(c('rJava', 'remotes', 'rversions', 'roxygen2', 'xml2', 'devtools'), repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('BiocManager', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages(c('rJava', 'remotes', 'rversions', 'roxygen2', 'xml2', 'devtools'), repos=c('https://cloud.r-project.org/', 'https://ftp.gwdg.de/pub/misc/cran/'))"
RUN R -e "install.packages('BiocManager', repos=c('https://cloud.r-project.org/', 'https://ftp.gwdg.de/pub/misc/cran/'))"
RUN R -e "BiocManager::install('aoles/RBioFormats')"
RUN R -e "BiocManager::install('EBImage')"
RUN R -e "install.packages(c('DT', 'shiny', 'shinyFiles', 'shinycssloaders', 'shinydashboard', 'shinyjs', 'shinyWidgets', 'shinybusy', 'assertthat'), repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages(c('ggplot2', 'plotly', 'RANN', 'MASS', 'uwot'), repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages(c('DT', 'shiny', 'shinyFiles', 'shinycssloaders', 'shinydashboard', 'shinyjs', 'shinyWidgets', 'shinybusy', 'assertthat'), repos=c('https://cloud.r-project.org/', 'https://ftp.gwdg.de/pub/misc/cran/'))"
RUN R -e "install.packages(c('ggplot2', 'plotly', 'RANN', 'MASS', 'uwot', 'xgboost', 'Ckmeans.1d.dp', 'caret'), repos=c('https://cloud.r-project.org/', 'https://ftp.gwdg.de/pub/misc/cran/'))"
# Copy the app to the image
RUN mkdir -p /usr/local/app/image-data-explorer
......
......@@ -412,6 +412,7 @@ input_data_server <- function(input, output, session) {
Save_Variable_rv("plateCol")
Save_Variable_rv("wellCol")
Save_Variable_rv("fieldCol")
Save_Variable_rv("treatCol")
# Columns to hide / edit
Columns_event <- function(type){
......
......@@ -74,45 +74,42 @@ explore_image_server <-function(input, output, session, rv){
## Get table row(s) associated with clicked pixel(s)
## Use nearest neighbour
observe({
observeEvent(input$pixelPosition, {
clickPosition <- NULL
roiData <- NULL
nn.rows.idx <- NULL
if(!is.null(input$pixelPosition) && !is.null(rv$roiX ) && !is.null(rv$roiY) && rv$roiX != "" && rv$roiY != "") {
## Depends only on input$pixelPosition (input$roiX and input$roiY are not expected to change here).
## This prevents being run upon clearing row selection.
isolate({
rv$pixelPosition <- matrix(input$pixelPosition, ncol = 2, byrow = TRUE)
if(!is.null(rv$selectedFrame)) {
for(i in 1:nrow(rv$pixelPosition)) {
if(!is.null(rv$roiFrame) && rv$roiFrame != "") {
## rv$imgPath1 and rv$selectedFrame should always have a unique value even when length>1
## because the image has already been selected if we click on it
## so it's safe to use the first value
clickPosition <- data.frame(t(c(rv$pixelPosition[i,], rv$selectedFrame[1])))
## Make sure we're looking only for ROIs present in the frame currently displayed
## This assumes that we interact with imageViewer1
roiData <- rv$data[rv$data[,rv$fileCol1] == rv$imgPath1[1] & rv$data[,rv$roiFrame] == rv$selectedFrame[1],
c(rv$roiX, rv$roiY, rv$roiFrame)]
} else {
clickPosition <- data.frame(t(c(rv$pixelPosition[i,])))
roiData <- rv$data[,c(rv$roiX, rv$roiY)]
}
nn <- nn2(roiData,
clickPosition,
k = 1,
searchtype = "radius",
radius = 50) # Search within 50 pixels of the click
## nn$nn.idx indexes into roiData.
## When subsetting, the index into the full data is stored as rowname
## so rownames(roiData) contains the index into the original data.
nn.rows.idx <- c(nn.rows.idx, as.numeric(rownames(roiData[nn$nn.idx,]))[1])
rv$pixelPosition <- matrix(input$pixelPosition, ncol = 2, byrow = TRUE)
if(!is.null(rv$selectedFrame)) {
for(i in 1:nrow(rv$pixelPosition)) {
if(!is.null(rv$roiFrame) && rv$roiFrame != "") {
## rv$imgPath1 and rv$selectedFrame should always have a unique value even when length>1
## because the image has already been selected if we click on it
## so it's safe to use the first value
clickPosition <- data.frame(t(c(rv$pixelPosition[i,], rv$selectedFrame[1])))
## Make sure we're looking only for ROIs present in the frame currently displayed
## This assumes that we interact with imageViewer1
roiData <- rv$data[rv$data[,rv$fileCol1] == rv$imgPath1[1] & rv$data[,rv$roiFrame] == rv$selectedFrame[1],
c(rv$roiX, rv$roiY, rv$roiFrame)]
} else {
clickPosition <- data.frame(t(c(rv$pixelPosition[i,])))
roiData <- rv$data[,c(rv$roiX, rv$roiY)]
}
selectRows(rv$proxy, nn.rows.idx) # Set selected points in table
rv$selectedRows <- nn.rows.idx
runjs("Shiny.setInputValue('explore_module-image-pixelPosition', null);")
nn <- nn2(roiData,
clickPosition,
k = 1,
searchtype = "radius",
radius = 50) # Search within 50 pixels of the click
## nn$nn.idx indexes into roiData.
## When subsetting, the index into the full data is stored as rowname
## so rownames(roiData) contains the index into the original data.
nn.rows.idx <- c(nn.rows.idx, as.numeric(rownames(roiData[nn$nn.idx,]))[1])
}
}) # End isolate
selectRows(rv$proxy, nn.rows.idx) # Set selected points in table
runjs("Shiny.setInputValue('explore_module-image-pixelPosition', null);")
}
} # End if
}) # End observe
}
......@@ -25,6 +25,7 @@ plate_view_server <- function(input, output, session, rv) {
output$plate_view <- renderPlotly({
req(rv$data)
selectedPlates <- unique(rv$data[rv$selectedRows, rv$plateCol])
isolate({
req(length(selectedPlates)>0)
# Extract selected plate data
plateData <- rv$data[rv$data[,rv$plateCol] %in% selectedPlates,]
......@@ -97,6 +98,7 @@ plate_view_server <- function(input, output, session, rv) {
modeBarButtonsToRemove = c("sendDataToCloud", "hoverCompareCartesian", "select2d", "lasso2d")) %>% # Control Plotly's tool bar
toWebGL()
}
})
}) # End renderPlotly
### Interactions with the plate viewer
......
......@@ -71,9 +71,6 @@ plot_server <- function(input, output, session, rv) {
click <- event_data("plotly_click", priority = "event", source = "scatterPlot")
if(!is.null(click)) {
selectRows(rv$proxy, as.numeric(unlist(click$key))) # Set selected point in table
if(!is.null(rv$roiX) && rv$roiX != "" && !is.null(rv$roiY) && rv$roiY != ""){
rv$pixelPosition <- rv$data[unlist(click$key), c(rv$roiX, rv$roiY)]
}
# Reset event to avoid triggering updates when switching workspaces
runjs("Shiny.setInputValue('plotly_click-scatterPlot', null);")
}
......@@ -86,7 +83,6 @@ plot_server <- function(input, output, session, rv) {
brush <- event_data("plotly_selected", priority = "event", source = "scatterPlot")
if(!is.null(brush)) {
selectRows(rv$proxy, as.numeric(unique(unlist(brush$key))))
rv$selectedRows <- as.numeric(unique(unlist(brush$key)))
# Reset event to avoid triggering updates when switching workspaces
runjs("Shiny.setInputValue('plotly_selected-scatterPlot', null);")
}
......
......@@ -72,7 +72,7 @@ explore_table_server <- function(input, output, session, rv) {
rv$proxy <- dataTableProxy('dataTable')
# Interactions with the table
observe({
observeEvent( input$dataTable_rows_selected, {
rv$selectedRows <- input$dataTable_rows_selected
if(is.null(rv$roiX) || rv$roiX == "") { # No ROIs,we only deal with images
if(length(rv$selectedRows)!=1) {
......@@ -98,7 +98,7 @@ explore_table_server <- function(input, output, session, rv) {
}
}
updateFilters()
})
}, ignoreNULL = FALSE)
observeEvent(input$selectFiltered, {
selectRows(rv$proxy, input$dataTable_rows_all)
......
......@@ -10,13 +10,13 @@ options(shiny.maxRequestSize=500*1024^2)
## Increase amount of RAM allocated to the JVM to allow BioFormats to read large files. This needs to be done before loading rJava (or packages using it).
# options(java.parameters = "-Xmx8g")
cran.mirrors <- c('https://ftp.gwdg.de/pub/misc/cran/', 'https://cloud.r-project.org/')
cran.mirrors <- c('https://cloud.r-project.org/', 'https://ftp.gwdg.de/pub/misc/cran/')
## Install required packages if missing
## CRAN packages
pkg <- c("devtools", "BiocManager", "DT", "shiny", "shinyFiles", "shinycssloaders", "shinydashboard", "shinyjs",
"shinyWidgets", "shinybusy", "assertthat", "ggplot2", "plotly", "RANN", "MASS", "uwot", "xgboost", "Ckmeans.1d.dp",
"caret")
"e1071", "caret")
new.pkg <- pkg[!(pkg %in% installed.packages())]
if (length(new.pkg)) {
message(paste0("Installing ", new.pkg, "\n"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment