rietho / IPO

A Tool for automated Optimization of XCMS Parameters
http://bioconductor.org/packages/IPO/
Other
34 stars 20 forks source link

Error in .local(object, ...) : Dimensions of profile matrices do not match ! #43

Closed mheiser-md closed 7 years ago

mheiser-md commented 7 years ago

For a while now I've come across the following error message when running optimizeRetGroup in single core mode:

Error in .local(object, ...) : 
  Dimensions of profile matrices do not match !

I ignored for a while, up until my data processing pipeline crashed during the retcor.obiwarp step with the above message using optimized IPO parameters. Once I reran IPO in single core mode, I could see the message was being printed for every sample, which seems to be a rare case?

With the following script the error can be reproduced:

library(msdata)
library(IPO)
library(xcms)

mzdatapath <- system.file("mzData", package = "mtbls2")
mzdatafiles <- list.files(mzdatapath, recursive = TRUE, full.names=TRUE)

xset <- xcmsSet(
  mzdatafiles[1:12],  method = "centWave",  peakwidth = c(6.65, 25), ppm = 25, 
  mzdiff = -0.001, snthresh = 10, noise = 10000, prefilter = c(3, 100), nSlaves = 3
)

paramsRG <- getDefaultRetGroupStartingParams()

resultRG <- optimizeRetGroup(xset, paramsRG, nSlaves=1)

And this is the output: The retcor step seems to stop after sample MSpos-Ex1-cyp79-48h-Ag-1_1-B,1_01_9819 in every iteration.

starting new DoE with:

distFunc: cor_opt
gapInit: c(0, 0.4)
gapExtend: c(2.1, 2.7)
profStep: c(0.7, 1)
plottype: none
response: 1
factorDiag: 2
factorGap: 1
localAlignment: 0
retcorMethod: obiwarp
bw: c(22, 38)
minfrac: c(0.3, 0.7)
mzwid: c(0.015, 0.035)
minsamp: 1
max: 50
center: 10

center sample:  MSpos-Ex2-Col0-48h-Ag-2_1-A,3_01_9829 
Processing: MSpos-Ex1-Col0-48h-Ag-1_1-A,1_01_9818  MSpos-Ex1-Col0-48h-Ag-2_1-A,1_01_9820  MSpos-Ex1-Col0-48h-Ag-3_1-A,1_01_9822  MSpos-Ex1-Col0-48h-Ag-4_1-A,1_01_9824  MSpos-Ex1-cyp79-48h-Ag-1_1-B,1_01_9819  
Error in .local(object, ...) : 
  Dimensions of profile matrices do not match !

108 112 115 119 123 127 130 134 138 142 145 149 153 157 160 164 168 172 175 179 183 187 190 194 198 202 205 209 213 217 220 224 228 232 235 239 243 247 250 254 258 262 265 269 273 277 280 284 288 292 295 299 303 307 310 314 318 322 325 329 333 337 340 344 348 352 355 359 363 367 370 374 378 382 385 389 393 397 400 404 408 412 415 419 423 427 430 434 438 442 445 449 453 457 460 464 468 472 475 479 483 487 490 494 498 502 505 509 513 517 520 524 528 532 535 539 543 547 550 554 558 562 565 569 573 577 580 584 588 592 595 599 603 607 610 614 618 622 625 629 633 637 640 644 648 652 655 659 663 667 670 674 678 682 685 689 693 697 700 704 708 712 715 719 723 727 730 734 738 742 745 749 753 757 760 764 768 772 775 779 783 787 790 794 798 802 805 809 813 817 820 824 828 832 835 839 843 847 850 854 858 862 865 869 
center sample:  MSpos-Ex2-Col0-48h-Ag-2_1-A,3_01_9829 
Processing: MSpos-Ex1-Col0-48h-Ag-1_1-A,1_01_9818  MSpos-Ex1-Col0-48h-Ag-2_1-A,1_01_9820  MSpos-Ex1-Col0-48h-Ag-3_1-A,1_01_9822  MSpos-Ex1-Col0-48h-Ag-4_1-A,1_01_9824  MSpos-Ex1-cyp79-48h-Ag-1_1-B,1_01_9819  
Error in .local(object, ...) : 
  Dimensions of profile matrices do not match !

108 112 115 119 123 127 130 134 138 142 145 149 153 157 160 164 168 172 175 179 183 187 190 194 198 202 205 209 213 217 220 224 228 232 235 239 243 247 250 254 258 262 265 269 273 277 280 284 288 292 295 299 303 307 310 314 318 322 325 329 333 337 340 344 348 352 355 359 363 367 370 374 378 382 385 389 393 397 400 404 408 412 415 419 423 427 430 434 438 442 445 449 453 457 460 464 468 472 475 479 483 487 490 494 498 502 505 509 513 517 520 524 528 532 535 539 543 547 550 554 558 562 565 569 573 577 580 584 588 592 595 599 603 607 610 614 618 622 625 629 633 637 640 644 648 652 655 659 663 667 670 674 678 682 685 689 693 697 700 704 708 712 715 719 723 727 730 734 738 742 745 749 753 757 760 764 768 772 775 779 783 787 790 794 798 802 805 809 813 817 820 824 828 832 835 839 843 847 850 854 858 862 865 869 
center sample:  MSpos-Ex2-Col0-48h-Ag-2_1-A,3_01_9829 
Processing: MSpos-Ex1-Col0-48h-Ag-1_1-A,1_01_9818  MSpos-Ex1-Col0-48h-Ag-2_1-A,1_01_9820  MSpos-Ex1-Col0-48h-Ag-3_1-A,1_01_9822  MSpos-Ex1-Col0-48h-Ag-4_1-A,1_01_9824  MSpos-Ex1-cyp79-48h-Ag-1_1-B,1_01_9819  
Error in .local(object, ...) : 
  Dimensions of profile matrices do not match !

It looks to me like a xcms bug, but I was wondering if IPO can perform any retcor optimization with this error?

sneumann commented 7 years ago

@jotsetung, does that ring a bell ? Yours, Steffen

jorainer commented 7 years ago

what version of xcms are you running?

mheiser-md commented 7 years ago

thanks for the quick reply!

xcms - 1.48.0 IPO - 1.7.5

jorainer commented 7 years ago

OK, the error comes from the retcor.obiwarp. I'll have to look into this - but am pretty busy at the moment - this might take some time.

mheiser-md commented 7 years ago

great thank you very much! I've done some tests as well but couldn't find a solution as I'm not really familiar with how obiwarp works... what I did observe was running above files with the following obiwarp parameters (the same ones IPO uses):

gapInit = 0.0
gapExtend = 2.1
profStep = 0.7 

caused the error, wheres

gapInit = 0.0
gapExtend = 2.1
profStep = 1

does not.

rietho commented 7 years ago

I had a look into the issue. From IPO perspective I can tell the following:

IPO handles the issue as follows It seems that IPO works as intended. Here the parameter combination produces an error in the retcor.obiwarp method. IPO does not crash, as it skips the failed retention time correction and continues with grouping. The failed retention time correction is penalized in the optimisation process. Thus IPO continues to optimise. Due to the penalisation IPO tries to find parameters for which the retention time correction works, but of course this can't be guaranteed. You can check by the following code:

resultRG[[length(resultRG)-1]]$target_value

where resultRG is the return value from optimizeRetGroup(). If retcor_done is 1.1, then the retention time correction for the best_settings fails. If retention time correction works, retcor_done should be 1.

About the issue itself To me the issue seems xcms specific. If there is an issue with IPO itself, @jotsetung please let me know.