Error in convertMSImagingArrays2Experiment / estimateDomain in Cardinal
0
0
Entering edit mode
Mark Dunning ★ 1.1k
@mark-dunning-3319
Last seen 10 hours ago
Sheffield, Uk

Hello all,

I've been given some MALDI imaging data to analyse in .imzML format and I'd just like to make some initial images for particular masses of interest and compare to results given by the manufacturer. This is my first time analysing these data

I'm able to read the data using Cardinal and the readlmxML function

sf <- readImzML("sf_161224-root mean square.imzML")
sf
MSImagingArrays with 249130 spectra 
spectraData(2): mz, intensity
pixelData(7): x, y, z, ..., 3DPositionX, 3DPositionY, 3DPositionZ
coord(3): x = 1...2518, y = 1...300, z = 1...1
runNames(1): sf_161224-root mean square
experimentData(10): spectrumType, instrumentModel, ionSource, ..., scanType, lineScanDirection, pixelSize
centroided: NA 
continuous: FALSE

However, it seems like I need to convert to MSImagingExperiement so I can use the image function and for further processing. I try the convertMSImagingArrays2Experiment function and get the following

mse <- convertMSImagingArrays2Experiment(sf)
estimating profile m/z-axis from 1000 sample spectra
processing chunk 1/20 (50 items)
processing chunk 2/20 (50 items)
processing chunk 3/20 (50 items)
processing chunk 4/20 (50 items)
processing chunk 5/20 (50 items)
processing chunk 6/20 (50 items)
processing chunk 7/20 (50 items)
processing chunk 8/20 (50 items)
processing chunk 9/20 (50 items)
processing chunk 10/20 (50 items)
processing chunk 11/20 (50 items)
processing chunk 12/20 (50 items)
processing chunk 13/20 (50 items)
processing chunk 14/20 (50 items)
processing chunk 15/20 (50 items)
processing chunk 16/20 (50 items)
processing chunk 17/20 (50 items)
processing chunk 18/20 (50 items)
processing chunk 19/20 (50 items)
processing chunk 20/20 (50 items)
Error in seq_len(length.out) : 
  argument must be coercible to non-negative integer

I've tracked the error to the estimateDomain function which has the following lines of code:-

units <- match.arg(units)
  ref <- switch(units, relative = "x", absolute = "abs")
  FUN <- function(x) {
    x <- x[!is.na(x)]
    res <- unname(estres(x, ref = ref))
    if (length(x) > 0 && is.finite(res)) {
      c(min = min(x), max = max(x), res = res)
    }
    else {
      c(min = NA_real_, max = NA_real_, res = res)
    }
  }
  ans <- chunkLapply(xlist, FUN, nchunks = nchunks, verbose = verbose, 
    BPPARAM = BPPARAM, ...)

When debugging, I see that my ans data frame has all 0 entries in the 3rd column, so the by argument gets set to zero.

head(ans)
                   min      max res
spectrum=0    307.2180 1496.157   0
spectrum=249  307.2180 1496.157   0
spectrum=498  307.2164 1496.157   0
spectrum=748  304.2995 1496.157   0
spectrum=997  304.3041 1496.157   0
spectrum=1246 307.2180 1494.146   0

all(ans[,3]==0)
TRUE

Consequently, the line to make a sequence seq_rel(from, to, by = by) errors as the by argument is zero.

  from <- floor(min(ans[, 1L], na.rm = TRUE))
  to <- ceiling(max(ans[, 2L], na.rm = TRUE))
  by <- median(ans[, 3L], na.rm = TRUE)
  by <- switch(units, relative = round(2 * by, digits = 6L) 
    0.5, absolute = round(by, digits = 4L))
  ans <- switch(units, relative = seq_rel(from, to, by = by), 
    absolute = seq.default(from, to, by = by))

Is this something I'm doing wrong (bearing in mind this is my first time analysing these data!)? Are there extra arguments I need to tweak when reading the data initially.

Any help gratefully appreciated!

Mass Cardinal • 54 views
ADD COMMENT

Login before adding your answer.

Traffic: 718 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6