Skip to main content
Topic: Find samples with high deviation in retentiontime, XCMS (Read 139 times) previous topic - next topic

Find samples with high deviation in retentiontime, XCMS

Hi,
The plot from "PlotadjustedRtime", show there is one sample with great deviation and I want to find which sample this is.

With adjustedRtime(df)
and rtime(df)
I can compare the adj rt for each feature.

I though I could check which features they are (the one with the extreme diff in rt) and then see in which sample they are present after correspondence, but then features are merged and they have got other names.

Does anyone have a suggestion on how I can identify the sample?

Many thanks!
:)

 

Re: Find samples with high deviation in retentiontime, XCMS

Reply #1
I did this a few days ago for a colleague exactly the way that you describe.
Replace `xcms_p_POS_g_r_g` with your object.


Code: [Select]
library(xcms)
library(dplyr)
library(tidyr)


investigate_data <- tibble(rtime =        rtime(xcms_p_POS_g_r_g, adjusted = FALSE, bySample = TRUE),
                          adjustedRtime = rtime(xcms_p_POS_g_r_g, adjusted = TRUE, bySample = TRUE),
                          file =          basename(fileNames(xcms_p_POS_g_r_g))
                          ) %>%
    unnest(c(rtime, adjustedRtime)) %>%
    mutate(diff =          adjustedRtime - rtime)


investigate_data %>%
    filter(abs(adjustedRtime-250)<1) %>% # <-- focus on a small RT range where the outlier is clear
    group_by(file) %>%
    arrange(diff) %>% # <-- use desc if looking for a positive difference
    slice(1) %>%
    ungroup %>%
    arrange(diff)     # <-- use desc if looking for a positive difference




Blog: stanstrup.github.io