Open
Description
It can be useful to have blank samples in your final peaktable such that you can filter features that are not much higher in samples than in blanks.
But pre-processing blank samples gives major problems with retcor (at least with loess) since there are too few well-behaved peaks.
So one solution I see is if was possible to inject samples in the xcmsSet object and do a blind fillpeaks. The problem here is the retention time correction. Supposedly you'd want the inject samples to be corrected as much as possible.
What I have done so far is get the "average RT correction" and use that for the blank samples. More sophisticated idea would be to interpolate based on runorder.
If it is of any use here is my current workaround:
# Find blank files --------------------------------------------------------
files_blank <- factors %>%
filter(ionmode == c("pos","neg")[settings$general$mode]) %>%
filter(grepl("Blank",sample_type)) %>%
extract2("filepath")
# append phenoData and filepaths ------------------------------------------
add_phenoData <- files_blank %>%
basename %>%
gsub(".mzML","",.) %>%
{data.frame(class=rep("Blank",length(.)),row.names=.)} %>%
{rbind(phenoData(xset_g_r_g_fill),.)}
add_filepaths <- files_blank %>%
{c(filepaths(xset_g_r_g_fill),.)}
# Get mean rt correction for each scan ------------------------------------
# this assumes same number of scans in all files
# should interpolate to common scale
rt_diff <- xset_g_r_g_fill %>%
{map2(.@rt$raw,.@rt$corrected, ~..2-..1)} %>%
lapply(unname) %>%
as.data.frame %>%
t
cor_mean <- apply(rt_diff,2,mean)
# Get scan times for blank files ------------------------------------------
raw_blanks <- files_blank %>%
readMSData(mode = "onDisk")
fData <- fData(raw_blanks)
add_rawRT <- fData %>%
as.tbl %>%
select(fileIdx, seqNum, retentionTime) %>%
spread(fileIdx, retentionTime) %>%
select(-seqNum) %>%
as.list
# Get correct RTs
add_corRT <- add_rawRT %>%
map(~..1+cor_mean)
# Add the fixed data ------------------------------------------------------
xset_g_r_g_fill_blanks <- xset_g_r_g_fill
xset_g_r_g_fill_old <- xset_g_r_g_fill
phenoData(xset_g_r_g_fill_blanks) <- add_phenoData
filepaths(xset_g_r_g_fill_blanks) <- add_filepaths
xset_g_r_g_fill_blanks@rt$raw <- c(xset_g_r_g_fill@rt$raw, add_rawRT)
xset_g_r_g_fill_blanks@rt$corrected <- c(xset_g_r_g_fill@rt$corrected, add_rawRT)
# Do new fillPeaks --------------------------------------------------------
BPPARAM_fillpeaks <- SnowParam(min(detectCores()-2,4), progressbar = TRUE)
xset_g_r_g_fill_blanks_fill <- do.call(fillPeaks,list(object = xset_g_r_g_fill_blanks,BPPARAM = BPPARAM_fillpeaks))
xset_g_r_g_fill <- xset_g_r_g_fill_blanks_fill
Metadata
Metadata
Assignees
Labels
No labels