1
XCMS / Re: Get fold, p-value for set of EIC m/z values
Quote from: "Jan Stanstrup"
For post-integration filtering you can do the following. I have used pipes and dplyr syntax since I find that the easiest and cleanest.Code: [Select]library(xcms)
# sample data
library(faahKO)
filepath <- system.file("cdf", package = "faahKO")
xsg <- group(faahko)
xsg <- fillPeaks(xsg)
reporttab <- diffreport(xsg)
#target list
targets <- rbind(c(mz = 328.2000, rt= 3632.839),
c(mz = 466.2000, rt= 3695.437),
c(mz = 495.2131, rt= 3426.267)
)
targets <- as.data.frame(targets)
# hit tolerance
mz_tol=0.1
rt_tol=0.5*60
# filtering using pipes and dplyr
library(dplyr)
reporttab_filtered <- reporttab %>%
rowwise %>%
filter( any( abs(mzmed-targets$mz)<mz_tol & abs(rtmed-targets$rt)<rt_tol ) ) %>%
select(name,mzmed,rtmed,fold,pvalue) %>%
as.data.frame