rformassspectrometry / Spectra

Low level infrastructure to handle MS spectra
https://rformassspectrometry.github.io/Spectra/
34 stars 24 forks source link

Error compareSpectra with type = "inner" #131

Closed jorainer closed 3 years ago

jorainer commented 3 years ago

compareSpectra with type = "inner" throws an error:

> compareSpectra(sps[1:10], type = "inner")
Error in FUN(map[[1L]], map[[2L]], ...) : 
  unused argument (type = "inner")
jorainer commented 3 years ago

Internally compareSpectra calls first the MAPFUN (peak mapping) and subsequently the FUN (similarity calculation) passing all additional parameters ... to them. And that's where the error comes from: the MAPFUN = join has a parameter type so all works fine, but then the type = "inner" is also passed to FUN = ndotproduct which does not have a parameter type.

What I would suggest is to add ... to the function definition of both join and ndotproduct (and all other similarity calculation functions) to avoid this.

@lgatto @sgibb , any objections or better ideas (e.g. how to fix that already in Spectra)?

lgatto commented 3 years ago

Another solution I see would be to have two arguments, funargs = list() and mapfunargs = list() to set and pass the function respective arguments. The calls would them be do.call(FUN, args = funargs) and do.call(MAPFUN, args = mapfunargs).

This would however make passing these extra arguments much more verbose and much less user-friendly. I prefer simply having ... as you suggest.

jorainer commented 3 years ago

This should be fixed with the updates we did in MsCoreUtils version 1.1.5.