image(ssc) returns no image

101 views
Skip to first unread message

Davide G. Franchina

unread,
Jul 31, 2023, 12:05:20 PM7/31/23
to Cardinal MSI Help
Hi all,

trying to plot the result of ssc but I get a warning (see code below) and the function image(ssc) does not print (see attachment).

Has anyone seen this before? thanks!

here is the code I am using:
setCardinalBPPARAM(BPPARAM = MulticoreParam(progressbar=TRUE))
mydata <- readMSIData(test_50um.imzML,  attach.only = T)

#convert to cont
mydata_cont <- as(mydata, "MSContinuousImagingExperiment")

set.seed(1)
ssc <- spatialShrunkenCentroids(mydata_cont,
                                   r = 1,
                                   s = 1, 
                                   k = 4)
ssc
An object of class 'SpatialShrunkenCentroids2'
  <18311 feature, 42841 pixel> imaging dataset
    imageData(0):
    featureData(0):
    pixelData(0):
    metadata(3): mapping method dist
    run(1): test_50um_continuous
    raster dimensions: 325 x 233 x 1
    coord(3): x = 1..325, y = 1..233, z = 0..0
    resultNames(6): class probability ... statistic sd
    resultData(1): ''
    modelData(3): r k s

image(ssc)
Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf



image_ssc.pdf

kbemis

unread,
Jul 31, 2023, 12:14:51 PM7/31/23
to Cardinal MSI Help
SSC currently has a known issue when a dataset contains a degenerate (constant) z-dimension (usually added by Bruker tools). That is (probably) the culprit.

Remove the unnecessary z-coordindate with coord(mydata_cont)$z <- NULL and try again. I would also recommend peak-picking or binning before segmenting.

-Kylie

Davide G. Franchina

unread,
Jul 31, 2023, 3:46:06 PM7/31/23
to Cardinal MSI Help
Hi Kylie,

thanks for the quick feedback. Unfortunately coord(mydata_cont)$z <- NULL did not do the trick and I keep getting the same warning warning/no image printed.

Davide G. Franchina

unread,
Aug 8, 2023, 2:53:12 PM8/8/23
to Cardinal MSI Help
I have tried to follow the user guide/your suggestion but calling peakPick() (on both processed and continuous data) before segmenting, but it returns an error:
mydata <- readMSIData(test_50um.imzML,  attach.only = T)

mydata <- peakPick(mydata, method="mad") %>%
                   process(mydata)
Error in get(as.character(FUN), mode = "function", envir = envir) :
  object 'fun' of mode 'function' was not found


I would greatly appreaciate any feedback to understand what is going on with this data set.
thank you!

kbemis

unread,
Aug 8, 2023, 2:57:56 PM8/8/23
to Cardinal MSI Help
Does this error occur on other datasets, or is it only this one?

Does the error still happen if using SerialParam()?

Davide G. Franchina

unread,
Aug 8, 2023, 4:24:36 PM8/8/23
to Cardinal MSI Help
With other data works fine (code used as in my first message in this conversation)

I have tried with SerialParam() and the error persists.

However,  peakPick() (also smoothSignal(), reduceBaseline()) works without using the pipe operator, as follows:

mydata <- peakPick(mydata, method="mad")
mydata <- process(mydata) 

So now the code looks like this:
setCardinalBPPARAM(BPPARAM = MulticoreParam(progressbar=TRUE)) #SerialParam() does not make a difference
mydata <- readMSIData(test_50um.imzML,  attach.only = T)
coord(mydata)$z <- NULL

mydata <- smoothSignal(mydata)
mydata <- reduceBaseline(mydata, method="locmin")
mydata <- peakPick(mydata, method="mad")
mydata <- process(mydata)

mydata_cont <- as(mydata, "MSContinuousImagingExperiment")

set.seed(1)
ssc <- spatialShrunkenCentroids(mydata_cont,
                                   r = 1,
                                   s = 1, 
                                   k = 4)
ssc
An object of class 'SpatialShrunkenCentroids2'
  <10987 feature, 9846 pixel> imaging dataset
    imageData(0):
    featureData(0):
    pixelData(3): 3DPositionX 3DPositionY 3DPositionZ

    metadata(3): mapping method dist
    run(1): test_50
    raster dimensions: 93 x 107
    coord(2): x = 1..93, y = 1..107

    resultNames(6): class probability ... statistic sd
    resultData(1): ''
    modelData(3): r k s
  
when i try to image this rough segmentation it throws the same warning and prints the empty plot (showing only the legend - as attached in the first message of this conversation)
image(ssc)
Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

Marco Fidaleo

unread,
Mar 7, 2024, 5:18:22 PMMar 7
to Cardinal MSI Help
Hello everyone,

I'm encountering the same issue while using Cardinal V3. Specifically, when I utilize the command `image(scc)`, no image is returned, and I receive the following warning messages:

1. "No non-missing arguments to min; returning Inf."
2. "No non-missing arguments to max; returning -Inf."

Interestingly, I can successfully generate the m/z plot using the `plot(scc)` command.

Could anyone advise on how to resolve this issue?

Best regards,
Marco

kbemis

unread,
Mar 10, 2024, 12:48:23 PMMar 10
to Cardinal MSI Help
This error means that there are some segments did not produce any valid probabilities. Which *may* mean the number of segments may have been over-specified in a way that the regularization could not overcome for the given data. Especially for a dataset with ten thousand peaks, the regularization (s) may need to be much higher.

For the current results, try plotting with values="class" and see if that produces anything. You can also try to plot each of the segments individually and see if it only happens for one of them. At least one segment may not have any pixels assigned to it.

-Kylie

Marco Fidaleo

unread,
Mar 10, 2024, 7:52:12 PMMar 10
to Cardinal MSI Help
Thank you, Kylie! It worked perfectly!
Cheers,
M

Reply all
Reply to author
Forward
0 new messages