Question: Error 'names' attribute must be the same length as the vector xcms
0
gravatar for goh
9 months ago by
goh0
goh0 wrote:

Hi,

I have a total of 50 mzXML ms files (20 treated, 30 un-treated organized into two different subfolders). Then, i have successfully performed LCMS analysis according the the guide huntil when i execute mzs the error as below appeared.

 

path <- "H:/mzxml"
files <- list.files(path, full.names=TRUE, pattern="mzXML", recursive = TRUE)

## Create a phenodata data.frame
pd <- data.frame(sample_name = sub(basename(files), pattern = ".mzXML",
                                   replacement = "", fixed = TRUE),
                 sample_group = c(rep("TREATED", 20), rep("UNTREATED", 30)),
                 stringsAsFactors = FALSE)

raw_data <- readMSData(files = files, pdata = new("NAnnotatedDataFrame", pd),
                       mode = "onDisk")  

> mzs <- mz(raw_data)

Error in names(res) <- nms : 
  'names' attribute [50] must be the same length as the vector [25]
In addition: Warning message:
stop worker failed:
  'clear_cluster' receive data failed:
  reached elapsed time limit 

 

I understand the error occurs because the attribute/number of mzXML files is not same as the vector.

Therefore, under the environments tab i checked the number of mzXML in the 'files' is 50. 

Then i check the pd data.frame, correctly assigns my mzXML files into TREATED and UNTREATED. 

I have also ran the faahKO data and there is no error appeared.

Any advice ? Does anyone face this problem before ? 

Thank you. 

Regards,

Goh

 

xcms xcms3 mzxml • 329 views
ADD COMMENTlink modified 9 months ago • written 9 months ago by goh0

Dear Goh,

can you please provide the output of sessionInfo()?

The reason for the failure might be the warning that you got. This sounds like some problem with the parallel processing setup (something like a connection timeout if you used SnowParam/sock-based parallel processing). Try running the analysis disabling parallel processing (i.e. after calling register(SerialParam()) ).

jo

ADD REPLYlink written 9 months ago by Johannes Rainer1.4k

Hi Johannes,

I did saw ur recommendations in a few github posts ask ppl to disable parallel processing and tried tht, but another error as below appeared. If i'm not mistaken, it means my RAM ran out of space ? Is there any workaround this ?

> register(SerialParam())
> mzs <- mz(raw_data)
Error: cannot allocate vector of size 209.5 Mb


> 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  LC_CTYPE=English_Malaysia.1252   
[3] LC_MONETARY=English_Malaysia.1252 LC_NUMERIC=C                     
[5] LC_TIME=English_Malaysia.1252    

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

other attached packages:
 [1] magrittr_1.5        pander_0.6.2        RColorBrewer_1.1-2  faahKO_1.20.0      
 [5] xcms_3.2.0          MSnbase_2.6.2       ProtGenerics_1.12.0 mzR_2.14.0         
 [9] Rcpp_0.12.18        BiocParallel_1.14.2 Biobase_2.40.0      BiocGenerics_0.26.0

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.4       purrr_0.2.5            splines_3.5.1         
 [4] lattice_0.20-35        colorspace_1.3-2       stats4_3.5.1          
 [7] yaml_2.2.0             vsn_3.48.1             XML_3.98-1.13         
[10] survival_2.42-6        rlang_0.2.1            pillar_1.3.0          
[13] glue_1.3.0             affy_1.58.0            bindrcpp_0.2.2        
[16] affyio_1.50.0          foreach_1.4.4          bindr_0.1.1           
[19] plyr_1.8.4             mzID_1.18.0            zlibbioc_1.26.0       
[22] munsell_0.5.0          pcaMethods_1.72.0      gtable_0.2.0          
[25] codetools_0.2-15       IRanges_2.14.10        doParallel_1.0.11     
[28] BiocInstaller_1.30.0   MassSpecWavelet_1.46.0 preprocessCore_1.42.0 
[31] scales_0.5.0           limma_3.36.2           S4Vectors_0.18.3      
[34] RANN_2.6               impute_1.54.0          ggplot2_3.0.0         
[37] digest_0.6.15          dplyr_0.7.6            grid_3.5.1            
[40] tools_3.5.1            lazyeval_0.2.1         tibble_1.4.2          
[43] crayon_1.3.4           pkgconfig_2.0.1        MASS_7.3-50           
[46] Matrix_1.2-14          assertthat_0.2.0       rstudioapi_0.7        
[49] iterators_1.0.10       R6_2.2.2               MALDIquant_1.18       
[52] multtest_2.36.0        compiler_3.5.1        

Thanks.

Regards,

Goh

 

ADD REPLYlink modified 9 months ago • written 9 months ago by goh0

I posted the traceback below as well.

> traceback()
16: stop(e)
15: value[[3L]](cond)
14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
13: tryCatchList(expr, classes, parentenv, handlers)
12: tryCatch({
        FUN(...)
    }, error = handle_error)
11: withCallingHandlers({
        tryCatch({
            FUN(...)
        }, error = handle_error)
    }, warning = handle_warning)
10: FUN(X[[i]], ...)
9: lapply(X, FUN, ...)
8: bplapply(fDataPerFile, FUN = .applyFun2SpectraOfFileMulti, filenames = fNames, 
       queue = theQ, APPLYFUN = FUN, fastLoad = fast_load, BPPARAM = BPPARAM, 
       ...)
7: bplapply(fDataPerFile, FUN = .applyFun2SpectraOfFileMulti, filenames = fNames, 
       queue = theQ, APPLYFUN = FUN, fastLoad = fast_load, BPPARAM = BPPARAM, 
       ...)
6: .local(object, ...)
5: spectrapply(object, FUN = mz, BPPARAM = BPPARAM)
4: spectrapply(object, FUN = mz, BPPARAM = BPPARAM)
3: .local(object, ...)
2: mz(raw_data)
1: mz(raw_data)

ADD REPLYlink written 9 months ago by goh0

Yes, the error means you are running out of memory. There is not much you can do apart from closing all other running applications and trying again.

On the other hand, you don't need to extract the m/z values of all of your 50 files. I'd skip that as in the vignette it just illustrates how you can access these values. The chromatographic peak detection and all other following preprocessing steps should be OK as they are performed on a per-file basis (i.e. you'll then not load the m/z values of all files).
 

ADD REPLYlink written 9 months ago by Johannes Rainer1.4k

Thanks Johannes, it work through.

If say i would like to extract the m/z values of certain files, such as 5 from each sample group. What commands need to be added to the command below when i wan to extract the m/z values ? Like filter commands ?

mzs <- mz(raw_data)

## Split the list by file mzs_by_file <- split(mzs, f = fromFile(raw_data)) length(mzs_by_file)

## Get the base peak chromatograms. This reads data from the files. bpis <- chromatogram(raw_data, aggregationFun = "max") ## Define colors for the two groups group_colors <- brewer.pal(3, "Set1")[1:2] names(group_colors) <- c("KO", "WT") ## Plot all chromatograms. plot(bpis, col = group_colors[raw_data$sample_group])

 

I did found the command below. but that is more to extracting a certain mz or rt.

## Define the mz slice. mzr <- c(305.05, 305.15)

## Extract and plot the chromatograms chr_mzr <- chromatogram(xdata, mz = mzr, rt = c(2500, 4000)) par(mfrow = c(3, 1), mar = c(1, 4, 1, 0.5)) cols <- group_colors[chr_mzr$sample_group] plot(chr_mzr, col = cols, xaxt = "n", xlab = "")

 

Btw, i encounter an error when i use the XCMSnnExp to a xcmsSet as below.

> xset <-as(xdata, "xcmsSet")
Note: you might want to set/adjust the 'sampclass' of the returned xcmSet object before proceeding with the analysis.

> #CREATE REPORTS
> reporttab<- diffreport(
+   xset,
+   "CONTROL", "CASE",
+   "PNEG",
+   10,
+   metlin = 0.15,
+   h = 480,
+   w = 640,
+   mzdec = 3
+ )
Error in .local(object, ...) : Incorrect Class Labels

When i check the class labels in the phenoData in the xset it is correct.

ADD REPLYlink modified 9 months ago • written 9 months ago by goh0

To extract m/z from a certain file (e.g. the second one) you can use mz(filterFile(raw_data, 2)).

Regarding the error you encounter. The Note says you have to set the sampclass using e.g. sampclass(xset) <- raw_data$sample_group, eventually you forget that? Also, the parameters of the diffreport function do not match, metlin should be either TRUE or FALSE and not 0.15.

BTW I strongly suggest to NOT use the diffreport anymore. There are way better and more flexible approaches available in R/Bioconductor to identifiy features with difference in abundances (from a simple t.test to anova or using the limma package).

ADD REPLYlink written 9 months ago by Johannes Rainer1.4k

Ok, Thanks for pointing our the metlin error.

I have another inquiry after i execute the command below. Are we suppose to fillpeaks again ? because in the previous steps i have ran the fillchrompeaks? Looks weird.

## 5_Filling missing peaks using default settings.
xdata <- fillChromPeaks(xdata)

##Convert to XCMSnExp to xset
xset <-as(xdata, "xcmsSet")
sampclass(xset) <- raw_data$sample_group

> #CREATE REPORTS
> reporttab<- diffreport(
+   xset,
+   "CONTROL", "CASE",
+   "PNEG",
+   10,
+   metlin = TRUE,
+   h = 480,
+   w = 640,
+   mzdec = 3
+ )
Error in .local(object, ...) : NA values in xcmsSet. Use fillPeaks()

 

Then i proceeded to run fillpeaks as below and diffreport, but it still gives me the fillpeaks error.

> #FILL PEAK
> xset3 <- fillPeaks(xset, method = "chrom")
Loading required package: xcms
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

H:\blood\mzxml\POLARPOS\CONTROL\Polar 1 Control2.mzXML 
method:  bin 
step:  0.1 

> #CREATE REPORTS
> reporttab<- diffreport(
+   xset,
+   "CONTROL", "CASE",
+   "PNEG",
+   10,
+   metlin = TRUE,
+   h = 480,
+   w = 640,
+   mzdec = 3
+ )
Error in .local(object, ...) : NA values in xcmsSet. Use fillPeaks()
> 

 

Yes, i have used the XCMS to metaboanalyst command before and plan to use for the current data.

#xcms to metaboanalyst
xcms:::.write.metaboanalyst(xset3, "metpolarpos.csv" )

I know you're moving to xcms 3.3.3. Im still in xcms 3.2.0 installed via bioconductor. I did tried to install xcms 3.3.3 via github but stopped at the beginning because it developmental version and i'm a still unfamiliar with all these commands.

 

ADD REPLYlink modified 9 months ago • written 9 months ago by goh0

The thing with the missing fillPeaks is that fillPeaks just inserts 0 values if no signal could be filled-in while fillChromPeaks leaves them out (thus you'll get NA in this case - which in my opinion is the correct approach if something is missing). The reason why you still got the error is that you did run diffreport on the xset, not the xset3 object.

Regarding metaboanalyst export: you can export the XCMSnExp object (xdata) using the exportMetabAnalyst method - but you'll need version 3.3.3

ADD REPLYlink written 9 months ago by Johannes Rainer1.4k

Hi, i did try to install xcms 3.3.3 and encounter an error then i use the workaround but still failed to install. So, what im doing now is obtain the xset3 file and from there use the xcms3.2 write.metaboanalyst.

> library(devtools)
> library(pkgbuild)

Attaching package: ‘pkgbuild’

The following objects are masked from ‘package:devtools’:

    build, clean_dll, compile_dll, compiler_flags, find_rtools, has_devel, setup_rtools,
    with_debug

> find_rtools()
[1] TRUE
> devtools::install_github("sneumann/xcms")
Downloading GitHub repo sneumann/xcms@master
from URL https://api.github.com/repos/sneumann/xcms/zipball/master
WARNING: Rtools is required to build R packages, but no version of Rtools compatible with R 3.5.1 was found. (Only the following incompatible version(s) of Rtools were found:3.5)

Please download and install the appropriate version of Rtools from http://cran.r-project.org/bin/windows/Rtools/.
Installing xcms
"C:/PROGRA~1/R/R-35~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD  \
  INSTALL  \
  "C:/Users/UMSBIOTECH/AppData/Local/Temp/RtmpIPsMnn/devtools2a98569359a7/sneumann-xcms-f1eecf6"  \
  --library="C:/Users/UMSBIOTECH/Documents/R/win-library/3.5" --install-tests 

* installing *source* package 'xcms' ...
** libs
Warning in system(cmd) : 'make' not found
ERROR: compilation failed for package 'xcms'
* removing 'C:/Users/UMSBIOTECH/Documents/R/win-library/3.5/xcms'
* restoring previous 'C:/Users/UMSBIOTECH/Documents/R/win-library/3.5/xcms'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
  problem copying C:\Users\UMSBIOTECH\Documents\R\win-library\3.5\00LOCK-sneumann-xcms-f1eecf6\xcms\libs\x64\xcms.dll to C:\Users\UMSBIOTECH\Documents\R\win-library\3.5\xcms\libs\x64\xcms.dll: Permission denied
In R CMD INSTALL
Installation failed: Command failed (1)
ADD REPLYlink modified 8 months ago • written 8 months ago by goh0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 199 users visited in the last hour