wkumler / MS_metrics

5 stars 0 forks source link

Floating point errors when using corrected retention times #4

Closed wkumler closed 1 year ago

wkumler commented 1 year ago

I'm extracting the retention times before and after xcms's correction so that I can plot the raw data in a corrected RT space instead of looking at them all in raw, original space.

Uncorrected betaine: image

Corrected betaine: image

This means that I construct a data frame per file of the mapping between the original and the corrected retention times. Easy enough to do with xcms output:

init_rts <- msnexp_filled %>%
  dropAdjustedRtime() %>%
  rtime() %>%
  as.data.frame() %>%
  rownames_to_column() %>%
  set_names(c("scanid", "init_rt"))
rt_corrections <- msnexp_filled %>%
  rtime() %>%
  as.data.frame() %>%
  rownames_to_column() %>%
  set_names(c("scanid", "new_rt")) %>%
  mutate(filename=basename(mzML_files[as.numeric(str_extract(scanid, "\\d+"))])) %>%
  left_join(init_rts, by="scanid") %>% 
  mutate(new_rt=new_rt/60, rt=init_rt/60) %>%
  select(-init_rt, -scanid)

However, I'm getting some NAs introduced by this process where the original RT values don't have a match in the output from xcms.

image

image

wkumler commented 1 year ago

No NAs after correcting the retention times anymore! image