Skip to main content
Topic: Error when executing xcmsset (Read 5221 times) previous topic - next topic

Error when executing xcmsset

Hi,

I'm very new in R and using xcms for analysis.
I have LCMS data in mzxml which contains two groups (A and B) in seperate sub directories. for example, inside folder "neg" contains two subfolders "A" and "B".
i have loaded the library and create the path to where my file contains using the command as below.
When i execute the xcmsset i get error.

Code: [Select]
library(BiocStyle)
library(multtest)
library(xcms)
path <- "G://mzxml/np/neg"
files <- system.file(path, full.names=TRUE, pattern="mzxml", recursive = TRUE)
xset <- xcmsSet(files,
                method="centWave",
                ppm = 10,
                peakwidth = c(20, 50),
                snthresh = 6,
                prefilter = c(3, 100),
                integrate = 1,
                mzdiff = 0.01
)

The error is as below.

Code: [Select]
Error in if (any(info$isdir)) { : missing value where TRUE/FALSE needed

May i know is it caused by in-correct filepath or something else ?

Thank you

Regards,
goo

Re: Error when executing xcmsset

Reply #1
Check what is in "files". I am guessing something strange got in there or it is empty.
Blog: stanstrup.github.io

Re: Error when executing xcmsset

Reply #2
Hi,
Thanks for the advice.
I have looked the "files" under the environment tab. seems like there is 112B but i couldnt open it nor locate it under my working directory.

I have ran the "files" in my R console and there is nothing there just "" was displayed.
 I have attached a snopshot of the environment tab in rstudio and my global setting.
My working directory is on my cpu but all the data in G drive.
Fyi, the G drive is a external hdd, could this be the cause ?



[attachment deleted by admin]

Re: Error when executing xcmsset

Reply #3
It means the "files" variable is empty (or technically that it contains one string of length zero).

There are several possible errors in your code.

The double forward slash might be causing trouble if you are sure the path is otherwise correct. Try this (I think this might be a non-issue though):
Code: [Select]
path <- "G:/mzxml/np/neg"


"system.file" is meant to find files included with some package. Since you are using your own files you should be using "list.files" instead. Also keep in mind that the pattern is case sensitive.
If you write "files" (without quotes) in the console you should see the list of your files.

Variables are kept in memory. They are not written to files. Anything you want written to a file you need to do it explicitly.

An external drive should not be a problem, no.

Btw.: Best practice is to create a project in Rstudio and have a dedicated folder for each project. You then keep your scripts (and smaller support files if you have any) here.
Blog: stanstrup.github.io

Re: Error when executing xcmsset

Reply #4
Thanks for the advice, will create a specific project for it. But it just save the scripts only, doesnt save the files in the "environment tabs".

I figured out my mistake is when specifying the "mzxml" file type. When i changed it to "mzXML" it works.

However, i encounter another error when im trying to use retcor

Code: [Select]
 > xset2 <- retcor(
+   xset,
+   method = "obiwarp",
+   profStep = 1,
+   family = "symmetric",
+   plottype = "mdevden",
+ )
Error in .local(object, ...) : unused argument (family = "symmetric")
>

Code: [Select]
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Malaysia.1252
[2] LC_CTYPE=English_Malaysia.1252  
[3] LC_MONETARY=English_Malaysia.1252
[4] LC_NUMERIC=C                    
[5] LC_TIME=English_Malaysia.1252   

attached base packages:
[1] parallel  stats     graphics  grDevices utils   
[6] datasets  methods   base    

other attached packages:
 [1] magrittr_1.5        pander_0.6.1      
 [3] RColorBrewer_1.1-2  faahKO_1.20.0     
 [5] xcms_3.2.0          MSnbase_2.6.1     
 [7] ProtGenerics_1.12.0 mzR_2.14.0        
 [9] Rcpp_0.12.17        BiocParallel_1.14.1
[11] Biobase_2.40.0      BiocGenerics_0.26.0

loaded via a namespace (and not attached):
 [1] BiocInstaller_1.30.0   compiler_3.5.1       
 [3] pillar_1.2.3           plyr_1.8.4           
 [5] iterators_1.0.9        zlibbioc_1.26.0      
 [7] tools_3.5.1            MALDIquant_1.17      
 [9] digest_0.6.15          evaluate_0.10.1      
[11] tibble_1.4.2           preprocessCore_1.42.0
[13] gtable_0.2.0           lattice_0.20-35      
[15] rlang_0.2.1            Matrix_1.2-14        
[17] foreach_1.4.4          yaml_2.1.19          
[19] stringr_1.3.1          knitr_1.20           
[21] IRanges_2.14.10        S4Vectors_0.18.3     
[23] multtest_2.36.0        stats4_3.5.1         
[25] rprojroot_1.3-2        grid_3.5.1           
[27] impute_1.54.0          snow_0.4-2           
[29] survival_2.42-3        XML_3.98-1.11        
[31] RANN_2.5.1             rmarkdown_1.10       
[33] limma_3.36.2           ggplot2_3.0.0        
[35] splines_3.5.1          backports_1.1.2      
[37] scales_0.5.0           pcaMethods_1.72.0    
[39] codetools_0.2-15       htmltools_0.3.6      
[41] MASS_7.3-50            MassSpecWavelet_1.46.0
[43] mzID_1.18.0            BiocStyle_2.8.2      
[45] colorspace_1.3-2       affy_1.58.0          
[47] stringi_1.1.7          doParallel_1.0.11    
[49] lazyeval_0.2.1         munsell_0.5.0        
[51] vsn_3.48.1             affyio_1.50.0


I have tried changed the scripts here and there, retype it and the error still the same.
i get the following error when i removed the "family"

Code: [Select]
> xset2 <- retcor(
+   xset,
+   method = "obiwarp",
+   profStep = 1,
+   plottype = "mdevden"
+ )
Error in match.arg(plottype) : 'arg' should be one of “none”, “deviation”
>

I think something does'nt installed or loaded ?

Re: Error when executing xcmsset

Reply #5
family is a parameter for retcor.peakgroups not for retcor.obiwarp (e.g. method="obiwarp"). See the help of the individual methods.
Blog: stanstrup.github.io

Re: Error when executing xcmsset

Reply #6
Thanks for the help.
I'm able to complete the lcms analysis until the diffreports. However, in between there are some problems that i coulldn't figured out.
1. error when i proceed to runtime correction as below. Moreover, when i did not include a command in R does it means it will choose the default setting which is "NULL" for centerSample ?
the help for retcor does shows that "center=NULL" can be included.

Code: [Select]
> #RUN RETENTION TIME CORRECTION
> xset2 <- retcor(
+   xset,
+   method = "obiwarp",
+   profStep = 1,
+   plottype = c("none","deviation"),
+   centerSample = NULL,
+   col = NULL,
+   ty = NULL,
+   response = 1,
+   distFun = "cor_opt",
+   gapInit = NULL,
+   factorDiag = 2,
+   factorGap = 1,
+   localAlignment = 0,
+   initPenalty = 0)
Error in .local(object, ...) : unused argument (centerSample = NULL)

when i use "center" instead of "centerSample" a different error came up.
Code: [Select]
> #RUN RETENTION TIME CORRECTION
> xset2 <- retcor(
+   xset,
+   method = "obiwarp",
+   profStep = 1,
+   plottype = c("none","deviation"),
+   center = NULL,
+   col = NULL,
+   ty = NULL,
+   response = 1,
+   distFun = "cor_opt",
+   gapInit = NULL,
+   factorDiag = 2,
+   factorGap = 1,
+   localAlignment = 0,
+   initPenalty = 0)
center sample:  
Processing: Error in if (!file.exists(object)) stop("xcmsSource: file not found: ",  :
  argument is of length zero

2. when i remove the centerSample, it does runs completely, but no plots was produced under the 'plots' tab in Rstudio. could not find it in my working directory as well.

xset shows that data are inside.
Code: [Select]
> xset
An "xcmsSet" object with 46 samples

Time range: 97.3-756.4 seconds (1.6-12.6 minutes)
Mass range: 105.0697-975.5754 m/z
Peaks: 6117 (about 133 per sample)
Peak Groups: 116
Sample classes: CASE, CONTROL

Feature detection:
 o Peak picking performed on MS1.
Profile settings: method = bin
                  step = 0.1

Memory usage: 2.29 MB

Is the command incorrectly typed ?

Re: Error when executing xcmsset

Reply #7
center is the correct argument for retcor.obiwarp.
XCMS is transitioning to a new interface (new functions with different arguments, but that basically does the same) where centerSample is an argument to ObiwarpParam. That it doesn't work with center=NULL but does when you don't specify might be a bug; it should work I think.

I think the reason you don't get a plot is because you have specified plottype = c("none","deviation"). You should only use one of the two. Otherwise the first option is used i.e. none.

Yes, default values are used if you don't specify explicitly.
Blog: stanstrup.github.io

Re: Error when executing xcmsset

Reply #8
I'm attaching the traceback and some of the data in xset below. There are files, but after i try the few

First i ran the scripts as below
Code: [Select]
> xset2 <- retcor(
+   xset,
+   method = "obiwarp",
+   profStep = 1,
+   plottype = "deviation",
+   center = NULL,
+   col = NULL,
+   ty = NULL,
+   response = 1,
+   distFun = "cor_opt",
+   gapInit = NULL,
+   factorDiag = 2,
+   factorGap = 1,
+   localAlignment = 0,
+   initPenalty = 0)
center sample:  
Processing: Error in if (!file.exists(object)) stop("xcmsSource: file not found: ",  :
  argument is of length zero

> traceback()
11: .local(object, ...)
10: xcmsSource(filename)
9: xcmsSource(filename)
8: xcmsRaw(object@filepaths[center], profmethod = "bin", profstep = 0)
7: .local(object, ...)
6: retcor.obiwarp(object, ...)
5: retcor.obiwarp(object, ...)
4: do.call(method, alist(object, ...))
3: .local(object, ...)
2: retcor(xset, method = "obiwarp", profStep = 1, plottype = "deviation",
       center = NULL, col = NULL, ty = NULL, response = 1, distFun = "cor_opt",
       gapInit = NULL, factorDiag = 2, factorGap = 1, localAlignment = 0,
       initPenalty = 0)
1: retcor(xset, method = "obiwarp", profStep = 1, plottype = "deviation",
       center = NULL, col = NULL, ty = NULL, response = 1, distFun = "cor_opt",
       gapInit = NULL, factorDiag = 2, factorGap = 1, localAlignment = 0,
       initPenalty = 0)

Then i inspect the data in xset.

Code: [Select]
> str(xset, max.level = 2)
Formal class 'xcmsSet' [package "xcms"] with 15 slots
  ..@ peaks           : num [1:6117, 1:11] 379 421 397 471 235 ...
  .. ..- attr(*, "dimnames")=List of 2
  ..@ groups          : num [1:116, 1:9] 181 236 249 255 279 ...
  .. ..- attr(*, "dimnames")=List of 2
  ..@ groupidx        :List of 116
  ..@ filled          : int(0)
  ..@ phenoData       :'data.frame': 46 obs. of  1 variable:
  ..@ rt              :List of 2
  ..@ filepaths       : chr [1:46] "G:/tissue/mzxml/np/neg/CASE/D N 1.mzXML" "G:/tissue/mzxml/np/neg/CASE/D N 2.mzXML" "G:/tissue/mzxml/np/neg/CASE/D N 3.mzXML" "G:/tissue/mzxml/np/neg/CASE/DN 4.mzXML" ...
  ..@ profinfo        :List of 2
  ..@ dataCorrection  : int(0)
  ..@ polarity        : chr(0)
  ..@ progressInfo    :List of 15
  ..@ progressCallback:function (progress) 
  ..@ mslevel         : num(0)
  ..@ scanrange       : num(0)
  ..@ .processHistory :List of 46
> head(xset@peaks)
           mz    mzmin    mzmax      rt   rtmin   rtmax
[1,] 379.1944 379.1942 379.1948  97.324  79.794 112.823
[2,] 421.2051 421.2044 421.2053 108.454  87.215 119.562
[3,] 397.1605 397.1600 397.1609 112.486  92.272 124.966
[4,] 471.1973 471.1968 471.1977 112.823  92.609 121.588
[5,] 235.1809 235.1807 235.1810 120.573 105.423 128.338
[6,] 463.2157 463.2154 463.2162 121.249 108.454 129.683
          into      intb  maxo   sn sample
[1,]  63585.88  63243.50 18469  281      1
[2,] 126455.21 125712.75 20504  184      1
[3,] 112149.18 112028.20 16132  697      1
[4,] 111377.42 111166.17 19105  354      1
[5,] 128713.22 128676.36 31172 1242      1
[6,]  62646.78  62619.22 10310  509      1
>

I still couldn't find out where is the bug you mentioned.
However, If i dont run the specify center=NULL, is it safe to say its running in NULL ?

Thanks.

Re: Error when executing xcmsset

Reply #9
Yes that should be a safe assumption.
Blog: stanstrup.github.io

Re: Error when executing xcmsset

Reply #10
Thanks Jan, couldn't have done it without your help!

Btw, i did saw the new XCMS interface. Since i'm still new in this i will play around with the old scripts and functions for sometime before trying out the new one.