Cardinal Version 3.6

94 views
Skip to first unread message

Marco Fidaleo

unread,
May 4, 2024, 6:04:07 AMMay 4
to Cardinal MSI Help
Hello Everybody,

I updated both R (R 4.4.0) and Cardinal (3.6) but I am currently facing some challenges with basic commands, such as image(), which seem to be malfunctioning after the update. 

> image(pig206, mz=885.5, tolerance=0.5, units="mz")
Error in image.default(pig206, mz = 885.5, tolerance = 0.5, units = "mz"):
  argument must be a matrix or similar

It seems to me that there is a conflict with the Matrix package... I probably messed something up during the update!
Is there someone who is having the same issue? How to solve?
How to go back to the old package of Cardinal?!
Ciao,
M

kbemis

unread,
May 4, 2024, 11:41:09 AMMay 4
to Cardinal MSI Help
Please provide the output of sessionInfo()

Marco Fidaleo

unread,
May 4, 2024, 12:04:45 PMMay 4
to Cardinal MSI Help
  Thanks for replying. Here the output of sessionInfo():

> sessionInfo() R version 4.4.0 (2024-04-24 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 11 x64 (build 22631) Matrix products: default locale: [1] LC_COLLATE=Italian_Italy.utf8 LC_CTYPE=Italian_Italy.utf8 LC_MONETARY=Italian_Italy.utf8 [4] LC_NUMERIC=C LC_TIME=Italian_Italy.utf8 time zone: Europe/Rome tzcode source: internal attached base packages: [1] stats4 stats graphics grDevices utils datasets methods base other attached packages: [1] Cardinal_3.6.0 S4Vectors_0.42.0 BiocParallel_1.38.0 BiocGenerics_0.50.0 ProtGenerics_1.36.0 loaded via a namespace (and not attached): [1] nlme_3.1-164 cli_3.6.2 rlang_1.1.3 DBI_1.2.2 tiff_0.1-12 [6] png_0.1-8 RCurl_1.98-1.14 htmltools_0.5.8.1 ontologyIndex_2.12 Biobase_2.64.0 [11] locfit_1.5-9.9 grid_4.4.0 abind_1.4-5 bitops_1.0-7 fastmap_1.1.1 [16] BiocManager_1.30.23 compiler_4.4.0 codetools_0.2-20 CardinalIO_1.2.0 irlba_2.3.5.1 [21] htmlwidgets_1.6.4 fftwtools_0.9-11 EBImage_4.46.0 lattice_0.22-6 digest_0.6.35 [26] matter_2.6.0 parallel_4.4.0 Matrix_1.7-0 tools_4.4.0 jpeg_0.1-10 [31] biglm_0.9-2.1

kbemis

unread,
May 4, 2024, 12:04:51 PMMay 4
to Cardinal MSI Help
That looks fine.

Can you run just the following two lines in a fresh new R session:

pig206 <- CardinalWorkflows::exampleMSIData("pig206")
Cardinal::image(pig206, mz=885.5, tolerance=0.5, units="mz")


If that doesn't work please share the output of:

print(pig206)

-Kylie

Marco Fidaleo

unread,
May 4, 2024, 12:29:50 PMMay 4
to Cardinal MSI Help
Now, the line works for the pig206 dataset. However, when I run my command on a dataset that I analyzed before using a previous version of Cardinal, I encounter this issue:

> mse_DRG_NEG_10UM_5SS <- readMSIData(DRG_NEG_10UM_5SS)

parsing imzML file: ‘C:\Users\ACER\Desktop\DRG_YS_NEG_10UM_5SS_TEST1 Analyte 1_1.imzml’
detected 'processed' imzML
detected 'profile' spectra
returning MSImagingArrays
done


> Cardinal::image(mse_DRG_NEG_10UM_5SS, mz=200.00, tolerance=0.5, units="mz")

Error in image.default(mse_DRG_NEG_10UM_5SS, mz = 200, tolerance = 0.5, :
the argument must be a matrix or similar


> print(mse_DRG_NEG_10UM_5SS)
MSImagingArrays with 160200 spectra
spectraData(2): mz, intensity
pixelData(3): x, y, run
coord(2): x = 1...890, y = 1...180
runNames(1): 2022_12_01_DRG_YS_NEG_10UM_5SS_TEST1_YOUNG Analyte 1_1
experimentData(10): spectrumType, spectrumRepresentation, instrumentModel, ..., scanType, lineScanDirection, pixelSize
centroided: FALSE
continuous: FALSE 

kbemis

unread,
May 4, 2024, 12:38:54 PMMay 4
to Cardinal MSI Help
Ah, yes, there is not currently an image() method for MSImagingArrays, only for MSImagingExperiment.

The new default for readMSIData() is to import "processed" imzML files as MSImagingArrays, which is for MS data that has not been aligned or centroided yet. The intended purpose is to give you greater control over the pre-processing for profile mass spectra.

If you want Cardinal to guess m/z bins for you like before so it can be represented as an MSImagingExperiment without further processing, then you can either set as="MSImagingExperiment" in readMSIData() or use convertMSImagingExperiment2Arrays() after importing it.

-Kylie

kbemis

unread,
May 4, 2024, 12:41:17 PMMay 4
to Cardinal MSI Help
Oh, passing in an expected mass.range and/or resolution to readMSIData() will also trigger importing it as an MSImagingExperiment.

kbemis

unread,
May 4, 2024, 12:46:05 PMMay 4
to Cardinal MSI Help
Oh, also I should have said convertMSImagingArrays2Experiment() above. See ?convertMSImagingArrays2Experiment for more details. This will guess appropriate m/z bins for the data and convert to MSImagingExperiment if you need it in that format before peak picking and alignment is done.

Marco Fidaleo

unread,
May 4, 2024, 12:59:44 PMMay 4
to Cardinal MSI Help
Thanks for the suggestions. By the way, when I run:

```r
mse_DRG_NEG_10UM_5SS <- readMSIData(DRG_NEG_10UM_5SS, mass.range = c(49, 1001))
```

and then the line:

```r

Cardinal::image(mse_DRG_NEG_10UM_5SS, mz=200.00, tolerance=0.5, units="mz")
```

I can now plot the image.

However, I'm surprised by the reading part of my file. Why do I have only 50 items for chunk now, whereas before when I ran the same command, I had 1000 (and it took hours)? I'm using the same command as before.

Cheers,
M

kbemis

unread,
May 4, 2024, 1:04:58 PMMay 4
to Cardinal MSI Help
Rather than read through the m/z values of all spectra in the dataset, it now uses a subset of spectra. The default is guess.max=1000, so the m/z bins are guessed from 1000 spectra. You can change it to more or less if you want, or manually set both the mass.range and resolution to skip the guessing and use whatever you provide for those.

-Kylie

Marco Fidaleo

unread,
May 4, 2024, 1:53:41 PMMay 4
to Cardinal MSI Help
Thanks Kylie, very clear, as usual!
Best,
M

Reply all
Reply to author
Forward
0 new messages