Commit a8cf2366 authored by Jean-Karim Heriche's avatar Jean-Karim Heriche

Highlight currently selected well.

parent 45e96f1a
......@@ -37,7 +37,7 @@ info_server <- function(input, output, session, rv) {
# TODO: Figure out which plot we're in
if(length(rv$selectedVar) > 0 && length(rv$selectedVar) <= 2) {
hover <- event_data("plotly_hover", source = "scatterPlot")
if(is.null(hover)) {
if(is.null(hover)) { # we may be on the plate viewer
hover <- event_data("plotly_hover", source = "plateView")
}
df <- head(rv$data[,c(rv$selectedVar, rv$colsOnHover), drop = FALSE], n = 1)
......
......@@ -62,7 +62,7 @@ plate_view_server <- function(input, output, session, rv) {
plateSize <- min(plate.sizes[nb.wells/plate.sizes<=1])
validate(need(plateSize>=4 && plateSize<=1536, "Unrecognized plate size/format."))
nb.rows <- plate.formats[[as.character(plateSize)]]["nb.rows"]
row.labels <- c(LETTERS, "AA", "AB", "AC", "AD", "AE", "AF")[1:nb.rows]
row.labels <- c(LETTERS, "AA", "AB", "AC", "AD", "AE", "AF")[1:nb.rows] # Expand alphabet for 1536-well plates
nb.cols <- plate.formats[[as.character(plateSize)]]["nb.cols"]
col.labels <- 1:nb.cols
plateData <- cbind(plateData[, c("ide.id", rv$wellCol,rv$selectedVar[1]), drop = FALSE], rows = NA, cols = NA)
......@@ -76,12 +76,17 @@ plate_view_server <- function(input, output, session, rv) {
plateData$rows <- factor(plateData$rows, rev(levels(plateData$rows)))
plateData$cols <- factor(plateData$cols)
# Draw plate
# Make sure that well size is small enough to fit in the available space
# Make sure that well size is small enough to fit plate in the available space
well.size <- 1536/(2*plateSize)
plateView <- ggplot(plateData, aes(y = rows, x = cols, key = ide.id)) +
geom_point(aes_string(colour = rv$selectedVar[1]), size = 1536/(2*plateSize)) +
geom_point(aes_string(colour = rv$selectedVar[1]), size = well.size) +
theme(legend.title = element_blank()) +
labs(x = NULL, y = NULL, title = NULL)
# Highlight selected well
plateView <- plateView + geom_point(data = plateData[plateData$ide.id == rv$selectedRows[1],],
shape = 21, stroke = well.size/8, size = well.size,
colour = "red")
ggplotly(plateView, tooltip = "none", source = "plateView") %>% event_register("plotly_hover") %>%
config(p = ., staticPlot = FALSE, doubleClick = "reset+autosize", autosizable = TRUE, displayModeBar = TRUE,
sendData = FALSE, displaylogo = FALSE,
......
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