commonMZ icon indicating copy to clipboard operation
commonMZ copied to clipboard

MZ_CAMERA -- Error in FUN(X, Y, ...) : object 'res' not found

Open etrh opened this issue 7 years ago • 3 comments

Jan, first of all, thank you for the extremely useful package.

I am experiencing problems when using the MZ_CAMERA function. I am not sure whether I am using it in the proper way, but I get this error:

Error in FUN(X, Y, ...) : object 'res' not found

This happens when I do this:

xsaFA <- findAdducts(xsaFI, polarity = "positive", rules = commonMZ::MZ_CAMERA(mode = "positive", warn_clash = T, clash_ppm = 30))

Also when I do this:

rules <- commonMZ::MZ_CAMERA(mode = "positive", warn_clash = T, clash_ppm = 30)

Any idea how to solve this issue?

I am using R 3.5.0 on an Ubuntu 18.04 machine.


My other question is about the usage of commonMZ alongside CAMERA. When is the appropriate time to run CAMERA with the rules provided in commonMZ? Should it be after the common CAMERA::annotate workflow? Does the following approach/order make any sense, for example?

xsa <- xsAnnotate(xset_conv, polarity = "positive", sample = c(1:dim(xset_conv@phenoData)[1]))
xsaF <- groupFWHM(xsa, perfwhm=0.6)
xsaC <- groupCorr(xsaF)
xsaFI <- findIsotopes(xsaC)
xsaFA <- findAdducts(xsaFI, polarity="positive")
xsaPL_default_CAMERA_rules <- getPeaklist(xsaFA)

positive_rule <- system.file('extdata/CAMERA_rules_pos.xlsx', package = "commonMZ")
positive_rule <- as.data.frame(readxl::read_xlsx(positive_rule))

xsaFA_contamin <- findAdducts(xsaFI, polarity = "positive", rules = positive_rule)
xsaPL_commonMZ <- getPeaklist(xsaFA_contamin)

Or is there a better approach to doing this?

etrh avatar Jun 05 '18 12:06 etrh

Sorry about that. Happy it is useful.

It should be "pos" and not "positive". There is no safety check for that.

The order in your workflow is correct. But you don't need to run findAdducts more than once. I assume that was just for comparison.

stanstrup avatar Jun 05 '18 12:06 stanstrup

Thanks a lot. It works without a problem now.

I would just mention one small detail that might be useful for people in the future who will be looking at this page. MZ_CAMERA returns a tibble, but findAdducts expects a dataframe. I was receiving a strange error when providing the tibble to findAdducts. So here's how to avoid that:

pos_rules <- commonMZ::MZ_CAMERA(mode = "pos", warn_clash = T, clash_ppm = 5)
pos_rules_df <- as.data.frame(pos_rules)
adducts_contaminants <- findAdducts(xsAn, polarity = "positive", rules = pos_rules_df)

etrh avatar Jun 05 '18 13:06 etrh

Thanks! I should indeed add that to the help page. I think you can also pass a numeric matrix.

stanstrup avatar Jun 05 '18 13:06 stanstrup