m/z sort assumption violated January 05, 2015, 09:09:53 AM Hi,I have the same problem as many people have had, and I found posts relevant to this topic but was not able to get the code to work. So I have HILIC UPLC-MS data. I tried running xcms but received this error saying that m/z sort assumption was violated. I tried running the following code but I got no output and no .CDF files were corrected; can you please advise me on what I should do next:## Notes: This program will check the m/z vector for a single file for sort violation## If a sort violation is found the m/z vector is reorganised along with the Intensity## vector. Finally a new CDF file is made which is fixed.## !!!NB!!! : Parallel version does not report progressrequire(xcms)checkAllcdfs<-function(Ftype="mzXML", nSlaves=1){ AllCDFs<-list.files(recursive=TRUE, pattern=Ftype, ignore.case=TRUE, full.names=TRUE) if(nSlaves >1){ if(require(snow)){ cl <- makeCluster(nSlaves, type = "SOCK") } clusterEvalQ(cl, library(xcms)) unlist(clusterApply(cl, AllCDFs, checkCDFfile)) stopCluster(cl) } else{ sapply(AllCDFs, checkCDFfile) cat("n") }}checkCDFfile<-function(file, type=".mzXML"){ cat("n") cat(paste("Loading File:", file, sep="")) xr<-xcmsRaw(file, profstep=0) for(i in 1:length(xr@scanindex)){ scan<-getScan(xr, scan=i) if(is.unsorted(scan[,"mz"]) == TRUE){ cat(" x ") newfile<-sub(type, "-Fixed.mzdata", file, ignore.case=TRUE) write.mzdata(xr, newfile) file.copy(file, sub(type, ".OLD", file, ignore.case=TRUE)) unlink(file) rm(list=ls()) gc() return(1) } if(i == length(xr@scanindex)){ cat(" O ") rm(list=ls()) gc() return(0) } }} Quote Selected
Re: m/z sort assumption violated Reply #1 – January 05, 2015, 01:56:18 PM Basically I can get this code to work for correcting individual .CDF files, but how can I loop this code through all of my .CDF files?> xr<-xcmsRaw("mh141210xg2_sccs_00101.CDF", profstep=0)> write.mzdata(xr, file="mh141210xg2_sccs_00101.CDF")Thanks so much for your help!-Majda Quote Selected
Re: m/z sort assumption violated Reply #2 – April 01, 2016, 06:35:00 AM Hi,There is now an automatic fix in https://github.com/sneumann/xcms/tree/f ... assumptionwhich I'll pull into a Bioconductor version after the next release in April.Yours,Steffen Quote Selected