Skip to content
Snippets Groups Projects
Commit 45699cf7 authored by Todor Kondić's avatar Todor Kondić
Browse files

Fix #97

Everything under Measurement Properties refreshes correctly now. The
reason why it did not was the overuse of req functions.
parent 992fdf48
No related branches found
Tags v1.2.3 v1.2.3-9000
No related merge requests found
Package: shinyscreen Package: shinyscreen
Title: Pre-screening of Mass Spectrometry Data Title: Pre-screening of Mass Spectrometry Data
Version: 1.2.2-0003 Version: 1.2.3
Author: Todor Kondić Author: Todor Kondić
Maintainer: Todor Kondić <todor.kondic@uni.lu> Maintainer: Todor Kondić <todor.kondic@uni.lu>
Authors@R: Authors@R:
......
...@@ -486,3 +486,21 @@ update_on_commit_chg <- function(summ,input,ptab,ltab) { ...@@ -486,3 +486,21 @@ update_on_commit_chg <- function(summ,input,ptab,ltab) {
summ[the_row,qa_pass:=apply(.SD,1,all),.SDcols=qflg] summ[the_row,qa_pass:=apply(.SD,1,all),.SDcols=qflg]
summ summ
} }
get_mprop_ms2_metadata <- function(ltab_entry) {
res <- list(rt=NA_real_,int=NA_real_,qa=character(0),ms2_sel=F)
if (NROW(ltab_entry)==0L) return(res)
res$rt = ltab_entry$ms1_rt
res$int = ltab_entry$ms1_int
z <- ltab_entry[.SD,.SDcols=patterns("qa_ms[12].*")]
lqa_vals <- as.list(ltab_entry[,.SD,.SDcols=patterns("qa_ms[12].*")])
qa_names <- names(lqa_vals)
res$qa <- qa_names[as.logical(lqa_vals)]
res$ms2_sel = ltab_entry$ms2_sel
res
}
...@@ -786,10 +786,17 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -786,10 +786,17 @@ mk_shinyscreen_server <- function(projects,init) {
}) })
rf_get_ltab <- reactive({ rf_get_ltab <- reactive({
tab <- req(rf_select_from_summ()) tab <- rf_select_from_summ()
if (NROW(tab)!=0) get_ltab(tab) else data.frame() if (NROW(tab)!=0) get_ltab(tab) else data.frame()
}) })
rf_get_ltab_entry <- reactive({
ltab <- rf_get_ltab()
if (NROW(ltab)>0L && isTruthy(input$sel_spec)) {
ltab[item==input$sel_spec]
} else data.frame()
})
## REACTIVE FUNCTIONS: PLOTS ## REACTIVE FUNCTIONS: PLOTS
...@@ -901,34 +908,6 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -901,34 +908,6 @@ mk_shinyscreen_server <- function(projects,init) {
}) })
## REACTIVE FUNCTIONS: MEASUREMENT PROPERTIES
rf_msrprop_get_vals <- reactive({
ptab <- rf_get_cindex_parents()
stab <- rf_select_from_summ()
res <- if (NROW(stab)==1L && is.na(stab[1,an])) {
x1 <- list(rt=stab[1,ms1_rt],int=stab[1,ms1_int])
x2 <- stab[1,.SD,.SDcols=patterns("qa_ms[12].*")]
qa <- as.logical(x2)
names(qa) <- names(x2)
c(x1,list(qa=qa),ms2_sel=F)
} else {
selMS2 <- req(input$sel_spec)
xx <- rf_get_ltab()
x1 <- list(rt=xx[item==(selMS2),ms1_rt],
int=xx[item==(selMS2),ms1_int])
x2 <- xx[item==(selMS2),.SD,.SDcols=patterns("qa_ms[12].*")]
qa <- as.logical(x2)
names(qa) <- names(x2)
x3 <- list(ms2_sel=xx[item==(selMS2),ms2_sel])
c(x1,list(qa=qa),x3)
}
res
})
## OBSERVERS ## OBSERVERS
...@@ -1326,22 +1305,14 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1326,22 +1305,14 @@ mk_shinyscreen_server <- function(projects,init) {
observe({ observe({
input$cmt_changes_b input$cmt_changes_b
res <- rf_msrprop_get_vals() ltab_entry <- rf_get_ltab_entry()
## TODO: FIXME: Uncomment after debug. ## res <- rf_msrprop_get_vals()
if (isTruthy(res)) { res <- get_mprop_ms2_metadata(ltab_entry)
valrt = res$rt valrt = res$rt
valint = res$int valint = res$int
valms2sel = res$ms2_sel valms2sel = res$ms2_sel
selqa <- res$qa[QABOX_VALS] selqa <- res$qa
selqa <- QABOX_VALS[selqa]
message("valms2sel: ", valms2sel)
message("selqa: ", paste(selqa,collapse=','))
} else {
valrt = NA_real_
valint = NA_real_
selqa <- character(0)
valms2sel = F
}
updateNumericInput(session = session, updateNumericInput(session = session,
inputId = "chg_ms1_rt", inputId = "chg_ms1_rt",
value = valrt) value = valrt)
...@@ -1360,18 +1331,18 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1360,18 +1331,18 @@ mk_shinyscreen_server <- function(projects,init) {
value = valms2sel) value = valms2sel)
}) })
## TODO: FIXME: Uncomment after debug?
## observeEvent(input$cmt_changes_b,{
## summ <- req(rvs$m$out$tab$summ)
## ptab <- req(rf_get_cindex_parents()) observeEvent(input$cmt_changes_b,{
## ltab <- req(rf_get_ltab()) summ <- req(rvs$m$out$tab$summ)
## rvs$m$out$tab$summ <- update_on_commit_chg(summ,
## input=input, ptab <- req(rf_get_cindex_parents())
## ptab=ptab, ltab <- req(rf_get_ltab())
## ltab=ltab) rvs$m$out$tab$summ <- update_on_commit_chg(summ,
input=input,
ptab=ptab,
ltab=ltab)
## }) })
...@@ -1600,33 +1571,33 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1600,33 +1571,33 @@ mk_shinyscreen_server <- function(projects,init) {
}) })
## FIXME: TODO: Uncomment after fixing.
## output$print_spec_tab <- renderPrint({ output$print_spec_tab <- renderPrint({
## notfound <- "No MS2 spectrum has been found for this entry." notfound <- "No MS2 spectrum has been found for this entry."
## ms2tabsel <- req(rf_get_ltab()) ms2tabsel <- rf_get_ltab()
## selMS2 <- req(input$sel_spec) selMS2 <- req(input$sel_spec)
## if (NROW(ms2tabsel)!=0L) { if (NROW(ms2tabsel)!=0L) {
## lval <- lapply(ms2tabsel[item==(selMS2)],function(x) x) lval <- lapply(ms2tabsel[item==(selMS2)],function(x) x)
## ms2 <- rvs$m$extr$ms2 ms2 <- rvs$m$extr$ms2
## kval <- rf_get_cindex_kval() kval <- rf_get_cindex_kval()
## allval <- c(kval,lval) allval <- c(kval,lval)
## ## There can be some duplicates. ## There can be some duplicates.
## common <- union(names(kval),names(lval)) common <- union(names(kval),names(lval))
## allval <- allval[common] allval <- allval[common]
## #Because in current implementation, kval may contain #Because in current implementation, kval may contain
## #more than the names existing in extr$ms2. Also, #more than the names existing in extr$ms2. Also,
## #BASE_KEY_MS2 does not contain `an', so we need to readd #BASE_KEY_MS2 does not contain `an', so we need to readd
## #it. #it.
## key <- unique(c(names(allval)[names(allval) %in% BASE_KEY_MS2],"an")) key <- unique(c(names(allval)[names(allval) %in% BASE_KEY_MS2],"an"))
## kval2 <- allval[key] kval2 <- allval[key]
## spec <- get_data_from_key(ms2,kval2)[,.(mz,intensity)] spec <- get_data_from_key(ms2,kval2)[,.(mz,intensity)]
## ## as.character(lapply(1L:NROW(spec),function(nr) paste0(spec[nr,mz]," ",spec[nr,intensity]))) ## as.character(lapply(1L:NROW(spec),function(nr) paste0(spec[nr,mz]," ",spec[nr,intensity])))
## print(as.data.frame(spec),row.names=F) print(as.data.frame(spec),row.names=F)
## } else { } else {
## notfound notfound
## } }
## }) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment