diff --git a/R/api.R b/R/api.R index 617efbbe4db45485e72e6ab585881b433c00db4b..b29adef892c288f40caa66415e50864bff3d2b0a 100644 --- a/R/api.R +++ b/R/api.R @@ -355,9 +355,12 @@ extr_data <-function(m) { ## Extract MS2 spectra. spectra = empty_spectra_table() - + for (fn in names(lfdata)) { - rtab = relate_ms2_to_precid(coarse=coarse,ms2=lfdata[[fn]]$ms2,cgram_ms1=cgram_ms1) + rtab = relate_ms2_to_precid(coarse=coarse[.(fn),on=.(file)], + ms2=lfdata[[fn]]$ms2, + cgram_ms1=cgram_ms1[.(fn), + on=.(file)]) sptab = extract_spectra(lms[[fn]],rtab) cgram_ms2 = rbind(cgram_ms2,rtab) spectra = rbind(spectra,sptab) @@ -368,7 +371,6 @@ extr_data <-function(m) { m$db$extr$cgm$ms1 = cgram_ms1 m$db$extr$cgm$ms2 = cgram_ms2 m$db$extr$spectra = spectra - m } diff --git a/R/extraction.R b/R/extraction.R index 538662cdfaaac1176e29a7d56465a0edebc22acf..73d126e12af41f040a57f987ada18c0e8b982e06 100644 --- a/R/extraction.R +++ b/R/extraction.R @@ -114,10 +114,11 @@ relate_ms2_to_precid <- function(coarse,ms2,cgram_ms1) { ## parent that finely matches something in the chromatogram (and ## this is by ensuring that a `precid' with the correct scan (idx) ## shows up in the chromatogram. - cgram_ms1[res,on=.(precid,idx==prec_idx), - .(precid,ce,scan=i.scan, - idx=i.idx,rt=i.rt, - intensity=i.intensity),nomatch=NULL] + x = cgram_ms1[!is.na(intensity)] + x[res,on=.(precid,idx==prec_idx), + .(precid,ce,scan=i.scan, + idx=i.idx,rt=i.rt, + intensity=i.intensity),nomatch=NULL] } diff --git a/R/plotting.R b/R/plotting.R index 0a7df0bcf5737a7e63cd051c2cb9d9154271513d..e7ad265a1897ffd0e4e2755d337eb1d023e59a2d 100644 --- a/R/plotting.R +++ b/R/plotting.R @@ -445,9 +445,11 @@ make_eic_ms2_plot <- function(db,summ,kvals,labs,axis="linear",rt_range=NULL,asp } + + + make_spec_ms2_plot <- function(db,summ,kvals,labs,axis="linear",asp=1, colrdata=NULL) { - ## Only the chosen ones. mdata = get_data_from_key(db=db, tab=summ,