Skip to content
Snippets Groups Projects
Commit d771ae93 authored by Todor Kondic's avatar Todor Kondic
Browse files

mix: Fixed ms2_sel calculation.

parent b5432030
No related branches found
No related tags found
No related merge requests found
...@@ -797,8 +797,10 @@ analyse_extracted_data <- function(extr,prescreen_param) { ...@@ -797,8 +797,10 @@ analyse_extracted_data <- function(extr,prescreen_param) {
qflg <- QA_FLAGS[!(QA_FLAGS %in% "qa_pass")] qflg <- QA_FLAGS[!(QA_FLAGS %in% "qa_pass")]
res[,qa_pass:=apply(.SD,1,all),.SDcols=qflg] res[,qa_pass:=apply(.SD,1,all),.SDcols=qflg]
res[.(T),del_rt:=abs(ms2_rt - ms1_rt),on="qa_pass",by='an'] res[.(T),del_rt:=abs(ms2_rt - ms1_rt),on="qa_pass",by='an']
res[.(T),qa_tmp_ms1_max:= ms1_int==max(ms1_int),on="qa_pass",by=BASE_KEY_MS2] resby <- BASE_KEY_MS2[! (BASE_KEY_MS2 %in% 'an')]
res[.(T,T),ms2_sel:= del_rt == del_rt[which.min(del_rt)],on=c("qa_pass","qa_tmp_ms1_max"),by=BASE_KEY_MS2] res[.(T),qa_tmp_ms1_max:= ms1_int==max(ms1_int),on="qa_pass",by=resby]
res[,ms2_sel:=F]
res[.(T,T),ms2_sel:= del_rt == del_rt[which.min(del_rt)],on=c("qa_pass","qa_tmp_ms1_max"),by=resby]
res[,qlt_ms1:=apply(.SD,1,function(rw) sum(c(5L,3L,2L)*rw)),.SDcol=c("qa_ms1_exists", res[,qlt_ms1:=apply(.SD,1,function(rw) sum(c(5L,3L,2L)*rw)),.SDcol=c("qa_ms1_exists",
"qa_ms1_above_noise", "qa_ms1_above_noise",
"qa_ms1_good_int")] "qa_ms1_good_int")]
...@@ -813,9 +815,11 @@ gen_summ <- function(comp,qa) { ...@@ -813,9 +815,11 @@ gen_summ <- function(comp,qa) {
comp_cols <- intersect(SUMM_COLS,colnames(comp)) comp_cols <- intersect(SUMM_COLS,colnames(comp))
rdcomp <- comp[,..comp_cols] rdcomp <- comp[,..comp_cols]
data.table::setkeyv(rdcomp,BASE_KEY) data.table::setkeyv(rdcomp,BASE_KEY)
summ <- qa[rdcomp,nomatch=NA] summ <- qa[rdcomp,nomatch=F] #We changed `nomatch' cases from NA
flgs <- c(QA_FLAGS,"ms2_sel") #to F, because NA does not work well
summ[is.na(qa_ms1_exists),(flgs):=F] #with X == F condition.
## flgs <- c(QA_FLAGS,"ms2_sel")
## summ[is.na(qa_ms1_exists),(flgs):=F]
data.table::setkeyv(summ,SUMM_KEY) data.table::setkeyv(summ,SUMM_KEY)
summ[.(F),c("qlt_ms1","qlt_ms2"):=0.,on="qa_ms1_exists"] summ[.(F),c("qlt_ms1","qlt_ms2"):=0.,on="qa_ms1_exists"]
summ summ
......
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