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

Towards MS2 chromatograms.

parent a16ca355
No related branches found
No related tags found
No related merge requests found
...@@ -313,7 +313,6 @@ mk_tol_funcs <- function(m) { ...@@ -313,7 +313,6 @@ mk_tol_funcs <- function(m) {
} }
##' @export
extr_data2 <-function(m) { extr_data2 <-function(m) {
message("Stage: extract") message("Stage: extract")
if (is.null(m$conf$serial) || !m$conf$serial) { if (is.null(m$conf$serial) || !m$conf$serial) {
...@@ -324,6 +323,7 @@ extr_data2 <-function(m) { ...@@ -324,6 +323,7 @@ extr_data2 <-function(m) {
} }
} }
##' @export
extr_data <-function(m) { extr_data <-function(m) {
fine = create_fine_table(m) fine = create_fine_table(m)
...@@ -335,11 +335,6 @@ extr_data <-function(m) { ...@@ -335,11 +335,6 @@ extr_data <-function(m) {
dpath = m$run$paths$data dpath = m$run$paths$data
## Open all files. ## Open all files.
fns = fine[,unique(file)] fns = fine[,unique(file)]
lms = lapply(fns,function(fn) read_data_file(file.path(dpath,fn))) lms = lapply(fns,function(fn) read_data_file(file.path(dpath,fn)))
...@@ -360,14 +355,37 @@ extr_data <-function(m) { ...@@ -360,14 +355,37 @@ extr_data <-function(m) {
setkey(cgram_ms1,file,precid) setkey(cgram_ms1,file,precid)
## Extract MS2 chromatograms. ## Extract MS2 chromatograms.
cgram_ms2 = data.table(precid=integer(0),
an=integer(0), ## Create the "coarse" table. Parent masses are known with
ce=numeric(0), ## "coarse". We will prefilter our ms2 results based on that...x
rt=numeric(0), coarse = create_coarse_table(m)
intensity=numeric(0))
## 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)) { for (fn in names(lfdata)) {
browser() 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 1+1
......
...@@ -634,7 +634,7 @@ create_coarse_table <- function(m) { ...@@ -634,7 +634,7 @@ create_coarse_table <- function(m) {
"rt_min", "rt_min",
"rt_max", "rt_max",
"file"), "file"),
keyby=c("file","isocoarse")] keyby=c("file","isocoarse","precid")]
} }
...@@ -688,6 +688,8 @@ get_fdata <- function(ms) { ...@@ -688,6 +688,8 @@ get_fdata <- function(ms) {
res$ms2 = fdata[msLevel==2L,.(scan, res$ms2 = fdata[msLevel==2L,.(scan,
idx=spIdx, idx=spIdx,
an=acquisitionNum, an=acquisitionNum,
rt=retentionTime,
intensity=basePeakIntensity,
ce=collisionEnergy, ce=collisionEnergy,
prec_mz=precursorMZ, prec_mz=precursorMZ,
prec_idx=precursorScanNum)] prec_idx=precursorScanNum)]
......
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