diff --git a/R/api.R b/R/api.R index 10049f6b9855fe5d27e29f28e50c58bcc0ec7505..0d24d07f6e93afc5144accb0be84b47b8ef13bd4 100644 --- a/R/api.R +++ b/R/api.R @@ -313,7 +313,6 @@ mk_tol_funcs <- function(m) { } -##' @export extr_data2 <-function(m) { message("Stage: extract") if (is.null(m$conf$serial) || !m$conf$serial) { @@ -324,6 +323,7 @@ extr_data2 <-function(m) { } } +##' @export extr_data <-function(m) { fine = create_fine_table(m) @@ -335,11 +335,6 @@ extr_data <-function(m) { dpath = m$run$paths$data - - - - - ## Open all files. fns = fine[,unique(file)] lms = lapply(fns,function(fn) read_data_file(file.path(dpath,fn))) @@ -360,14 +355,37 @@ extr_data <-function(m) { setkey(cgram_ms1,file,precid) ## Extract MS2 chromatograms. - cgram_ms2 = data.table(precid=integer(0), - an=integer(0), - ce=numeric(0), - rt=numeric(0), - intensity=numeric(0)) + + ## Create the "coarse" table. Parent masses are known with + ## "coarse". We will prefilter our ms2 results based on that...x + coarse = create_coarse_table(m) + + ## Filter ms2 based on coarse. TODO + ## coarse_ms2 = coarse[,filter_coarse(lms[[file]],.SD,lfdata[[file]]), + ## by="file"] + + + ## Join ms1 chromatogram data to ms2, connecting by the parent scan. TODO + ## cgram_ms2 = coarse_ms2[,filter_parent_scans(lms[[file]],.SD,lfdata[[file]])] + + + ## cgram_ms2 = data.table(precid=integer(0), + ## an=integer(0), + ## ce=numeric(0), + ## rt=numeric(0), + ## intensity=numeric(0)) for (fn in names(lfdata)) { browser() - x = lfdata[[file]]$ms2[cgram_ms1,.(an,ce,precid=i.precid),on="prec_idx==idx"] + x = lfdata[[fn]]$ms2[cgram_ms1, + .(an, + ce, + precid=i.precid, + rt, + intensity), + on=c(prec_idx="idx"), + nomatch=NULL, + allow.cartesian=T] + 1+1 } 1+1 diff --git a/R/extraction.R b/R/extraction.R index 6fcc0d8a5bc6c6f98b8255c60ed4c0a23cba7b4d..298b8ab358fbffe73e77a384fe13cec3960c5873 100644 --- a/R/extraction.R +++ b/R/extraction.R @@ -634,7 +634,7 @@ create_coarse_table <- function(m) { "rt_min", "rt_max", "file"), - keyby=c("file","isocoarse")] + keyby=c("file","isocoarse","precid")] } @@ -688,6 +688,8 @@ get_fdata <- function(ms) { res$ms2 = fdata[msLevel==2L,.(scan, idx=spIdx, an=acquisitionNum, + rt=retentionTime, + intensity=basePeakIntensity, ce=collisionEnergy, prec_mz=precursorMZ, prec_idx=precursorScanNum)]