A couple questions re version 3.6 files and plotting

50 views
Skip to first unread message

aali...@gmail.com

unread,
Jul 23, 2024, 7:53:47 PM7/23/24
to Cardinal MSI Help
Hello,

We've been working on some workflow tools for Cardinal and I have been working on updates to be compatible with the new underlying structure of v. 3.6. A couple questions:

1. we have saved a number of MSContinuousImagingExperiment objects from the previous version as .rds files. Is there a way to convert these to be compatible or would they need to be reprocessed? Its not a huge deal as we are keeping both versions available at the moment but would simplify the workflow a bit.

2. In the old version the image() command has the 'colorscale' option to change the colormap. Does an equivalent exist with the 3.6 version?

Many thanks in advance for the help!

Aalim

kbemis

unread,
Jul 23, 2024, 8:11:33 PM7/23/24
to Cardinal MSI Help
Hi Aalim,

1. Yes, you can extract the necessary components to rebuild a 3.6-compatible MSImagingExperiment:

If all goes well, you should be able to simply call obj <- updateObject(obj) to return an updated MSImagingExperiment.

If that doesn't work, you can get the necessary components via:

spectra <- obj@imageData$data[[1L]]
coord <- obj@elementMetadata@coord
run <- obj@elementMetadata@run
mz <- obj@featureData@mz

and then follow the instructions here:


2. Yes, you can use the col argument, which now works for both discrete and continuous color scales.

I recommend using the provided dpal() and cpal() functions to generate the discrete and continuous color palettes, respectively.

You can see the supported discrete palettes via palette.pals() and the continuous palettes via hcl.pals().

For example, col=cpal("Cividis") to switch to the Cividis color palette.

-Kylie

kbemis

unread,
Jul 23, 2024, 8:20:50 PM7/23/24
to Cardinal MSI Help
I'll also add that--going forward---it will be better to use writeMSIData() to write an imzML file for long-term storage.

In >=3.6, any additional metadata columns in pixelData() or featureData() (besides the default required columns) will also get written as tab-delimited text files that get read back in when detected with readMSIData().

RDS is fine for short-term storage between R sessions, but is not intended for long-term stable storage.

-Kylie

aali...@gmail.com

unread,
Jul 23, 2024, 8:28:41 PM7/23/24
to Cardinal MSI Help
Thanks Kylie, this is super helpful, as is the info on read/writeMSIData. We will definitely switch to that.

Aalim

Matthew Smith

unread,
Jul 24, 2024, 10:16:42 AM7/24/24
to Cardinal MSI Help
This is a great feature that I hadn't realised. Does it also enable saving multiple  spectraData() channels (i.e 'intensity' and 'normalised_intensity' in the same imzML) - or do they need to be saved independently?

Best wishes,
Matt

kbemis

unread,
Jul 30, 2024, 3:00:06 PM7/30/24
to Cardinal MSI Help
Hi Matt,

It does not support writing multiple intensity channels currently. I am not sure that imzML can support that due to the expectations around the cvParam tags.

However, CardinalIO::writeImzML (which is used by Cardinal::writeImzML) allows specifying the intensity arrays:

writeImzML(obj, intensity=spectra(obj, "normalized_intensity"))

You would need to call writeImzML separately for each channel you want to export, giving multiple imzML files.

-Kylie
Reply all
Reply to author
Forward
0 new messages