Extract intensity for selected mz list and ROI

253 views
Skip to first unread message

Frédéric Fournelle

unread,
Jun 10, 2020, 2:55:13 PM6/10/20
to Cardinal MSI Help

Hi,

First of all, what a wonderful update with Cardinal 2.2 !


I started to dig into it and, unfortunately, I ran into some issue with some old functions and a piece of code that are no more valid into Cardinal 2 and R 3.6.2 (I was using R version 3.4.4). I want to stay in R 3.6.2 to keep all the new update of Cardinal 2.2 !

I wonder if there is a built-in function in Cardinal 2 to extract the intensity of a series of selected mz and separate them according to their region of interest (ROI). My ROI are already selected and named in flexImaging.


We already had a homemade piece of code to do that, but it used functions that are no more support by Cardinal 2.2 and R 3.6.2. Our output was a table with all the selected mz values and the intensity of all the pixels and the attribution to their respective ROI. This allows us to perform some statistical manipulations with Tidyr packages and visualize these results with ggplot function and separate the result according to their ROI. If a built-in function or code already exists, this will be really helpful!

 

Thank you for your help,

Frédéric 

Frédéric Fournelle

unread,
Jun 11, 2020, 3:25:57 PM6/11/20
to Cardinal MSI Help

 

Here is an example of our problem.

We ran an experiment with 10 sections of a brain homogenate on which we deposit matrix with 5 different conditions (2 technical duplicates in each row). We want to evaluate which protocol can give the maximum intensity for some selected mz values. We can surely do that visually for some on the conditions, but we would like to have some results and show graphs.

 

The problem is that we ran most of our analysis in one flexImaging file which doesn’t separate sample by run.

Dataset

An object of class 'MSContinuousImagingExperiment'

  <10000 feature, 2117 pixel> imaging dataset

    imageData(1): intensity

    featureData(0):

    pixelData(0):

    metadata(11): ibd binary type universally unique identifier ... files name

    run(1): 2020_06_10_optiDAN_7-10pass

    raster dimensions: 407 x 98

    coord(2): x = 158..564, y = 79..176

    mass range: 439.9412 to 997.9918

    centroided: FALSE

 

I used select() to separate my dataset in region using x/y position, but I am not able to reattribute the run()  .

subset_A = select(data, x<=200,y<=100)
subset_A
 
An object of class 'MSContinuousImagingExperiment'
  <10000 feature, 180 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(0):
    metadata(11): ibd binary type universally unique identifier ... files name
    run(1): 2020_06_10_optiDAN_7-10pass
    raster dimensions: 12 x 15
    coord(2): x = 169..180, y = 79..93
    mass range: 439.9412 to 997.9918 
    centroided: FALSE 

 

Is there way to reattribute the run() name for each region?

Is there a way through Cardinal to automatically recognize and separate the regions?

I try to use meansTest, but it doesn’t run. Is it because I only have one run?

Message has been deleted

Gordon Luu

unread,
Jun 11, 2020, 4:21:42 PM6/11/20
to Cardinal MSI Help
Hi Frédéric,

If you look at the pixel count the subset pulls out the ROI you specified. You can set a new run name by assigning it to like so:
run(dataset) <- as.factor('new_run_name')

But as far as I know, there is no function to do so automatically right now.

I've written a function called updateMetadata in my own small package that takes the Spot List exported from flexImaging (File > Export > Spot List) and a .csv file you can make yourself (example in the data folder of my repo).


The name of each ROI as seen in flexImaging is defined in the .csv file along with the condition(s). The Spot File provides the x-y coordinates for each ROI, and a new column in pixelData() is made for each condition. Here is an example:

In this example you can run:
meansTest(x, ~ condition, groups=pixelData(x)$run)

Hope this helps!

- Gordon

Frédéric Fournelle

unread,
Jun 15, 2020, 2:07:33 PM6/15/20
to Cardinal MSI Help

Hi Gordon,

Thank you for your help ! I was thinking about possible solution way more complex than this one !

I did use your code to update my Dataset’s metadata and it works well!

Unfortunately, I am still running into errors.

My dataset was previously pre-process (normalized, smooth, reduce baseline and peakBin).

Data_bin
An object of class 'MSContinuousImagingExperiment'
  <550 feature, 819 pixel> imaging dataset
    imageData(1): intensity
    featureData(0):
    pixelData(2): position run
    metadata(11): ibd binary type universally unique identifier ... files name
    processing complete(4): normalize smoothSignal reduceBaseline peakBin
    processing pending(0):
    run(4): 11pass_TOP 11pass_Bottom 7pass_Top 7pass_Bottom
    raster dimensions: 407 x 92
    coord(2): x = 158..564, y = 79..170
    mass range: 700.0811 to 899.9101 
    centroided: TRUE

 

> pData(Data_bin)
PositionDataFrame with 819 rows and 2 columns
           :run:   coord:x   coord:y position          run
        <factor> <integer> <integer> <factor>     <factor>
1     11pass_TOP       171        82      top   11pass_TOP
2     11pass_TOP       178        87      top   11pass_TOP
3     11pass_TOP       170        82      top   11pass_TOP
4     11pass_TOP       169        93      top   11pass_TOP
5     11pass_TOP       179        91      top   11pass_TOP
...          ...       ...       ...      ...          ...
815 7pass_Bottom       549        86      top 7pass_Bottom
816 7pass_Bottom       559        81      top 7pass_Bottom
817 7pass_Bottom       550        79      top 7pass_Bottom
818 7pass_Bottom       564        83      top 7pass_Bottom
819 7pass_Bottom       559        82      top 7pass_Bottom

 

The name of the positions are either ‘top’ or ‘bottom’.

The name of the runs are either ‘11pass_top’, ‘11pass_bottom’, ‘7pass_top’ and ‘7pass_bottom’

As you suggest, I tried this line of code : mtest <- meansTest(Data_bin, ~ position , groups= pixelData(Data_bin)$run)

After processing chunk 1-20, I received this error.

summary(mtest)

Error in as.vector(x, mode = "numeric") :

  no method for coercing this S4 class to a vector

In addition: Warning message:

In mean.default(x) : argument is not numeric or logical: returning NA

Called from: as.vector(x, mode = "numeric")

Error during wrapup: unimplemented type (29) in 'eval'

 

Error: no more error handlers available (recursive errors?); invoking 'abort' restart

Error during wrapup: INTEGER() can only be applied to a 'integer', not a 'unknown type #29'

Error: no more error handlers available (recursive errors?); invoking 'abort' restart

Browse[1]>

I used R (v 4.0.1) and Cardinal (v 2.6.0)

Do you have an idea explaining why I am consistently running into this error?

Fred

gl...@uic.edu

unread,
Jun 21, 2020, 10:46:38 PM6/21/20
to Cardinal MSI Help

Hi Frédéric,

Not sure if you've figured this out yet but: I've personally never seen that error so I can't really say how we might be able to fix it. I did notice that the "position" column in pixelData(Data_bin) has the value "top" even for runs like "7pass_Bottom". It's possible that may be causing it? Might be worth checking to see if any of the values are actually "bottom".

As for my updateMetadata() function, the pixelData() table looks different than it should. If you're willing to share the .csv table and Spot File from fleximaging, I could help with getting that together. I suspect the .csv table is missing an important column.

- Gordon

fourn...@gmail.com

unread,
Aug 24, 2020, 4:29:13 PM8/24/20
to Cardinal MSI Help

Hi Gordon, 

I worked throught your suggestions and corrected all my codes. 
I am able to use meanstest and your updateMetadata() function works perfectly ! Thanks a lot for this very helpful function. 

-Frédéric
Reply all
Reply to author
Forward
0 new messages