Get M/Z values in a msheatmap/msdotplot overlay with a pixel pseudocolor value greater than 120 (the range is 0 - 195)?

1 view (last 30 days)
I have an LCMS acquisition with 1897 time variables and a varying range of M/Z variables. The mzXML file was imported using 'mzXMLread' which works well.
I used the 'mzxml2peaks' function to get the M/Z spectrum for each of the 1987 time variables and a time vector for my file, which works well.
I saved my data in a struct like 'newdata' with the fields 'peaks', 'time', which is all thats needed to visualise the data. Peaks can be accessed via 'newdata(1).peaks' and
the time vector can be accessed via 'newdata(1).time'.
Next I proceeded with the steps as mentioned in the msdotplot help section
[MZ,Y] = msppresample(newdata(1).peaks,5000);
msheatmap(MZ,newdata(1).time,log(Y))
after which, I overlayed this heatmap with the dotplot to highlight features of interest
msdotplot(newdata(1).peaks,newdata(1).time,'Quantile',0.95)
axis([400 1700 903 1626])
where, 400 to 1700 is the x axis (M/Z range) and 903 to 1626 is the y axis (time range). This is the range I am interested in seeing.
I have attached the resulting figure as 'Figure n1.png' which gets me a pseudocolor range of values [0 195].
I am interested to get the x axis coordinates (and exact M/Z values) of those pixels whose color value is greater than 120. I have been scrambling to use functions like findobj, get, set, gca, gcf but couldnt quite get it working. I also tried imtool, but imtool compresses the image and appears to lose the actual X and Y data. Furthermore, there appear to be too many pixels to pick by hand.
Can someone point me to the right direction for this please, I would be obliged? Thank you.

Accepted Answer

Tim DeFreitas
Tim DeFreitas on 20 Apr 2020
Edited: Tim DeFreitas on 21 Apr 2020
Rather than inspecting the range of colors in the heatmap after it's produced, I'd suggest finding the values in Y that are above a certain threshold. Something like the following:
Yind = log(Y) > someValue; % Select an appropriate threshold and index into Y
% Filter heatmap data first
MZfilt = MZ(any(Yind, 2)); % Select MZ where any value is above threshold
Timefilt = newdata(1).time(any(Yind,1)) % Select times where any value is above threshold
Yfilt = log(Y(Yind)); % **EDIT -- this selects the correct values but is the wrong shape, see comment**
% Now plot results, all values should match.
% The heatmap may look strange if there are very few values meeting your threshold.
msheatmap(MZfilt, Timefilt, Yfilt)
  3 Comments
Tim DeFreitas
Tim DeFreitas on 21 Apr 2020
Edited: Tim DeFreitas on 21 Apr 2020
Hi Sindhuraj,
The sizes should be compatible, I made a mistake in my code above creating Yfilt. This should produce the correct sized matrix:
Yfilt = Y(any(Yind,2), :);
Yfilt = Yfilt(:,any(Yind,1)');
Yfilt = log(Yfilt);
msdotplot uses the quantile function internally, so the results should be the same. Unfortunately I'm not aware of any specific papers using these functions, though it's possible that papers are using these plots and not mentioning these functions by name.
Hope this helps,
-Tim
Sindhuraj Mukherjee
Sindhuraj Mukherjee on 21 Apr 2020
Thanks for the updated code Tim, I do indeed get the corrected heatmap.
I can use the MZfilt matrix now to get the M/Z values I need (which was possible with your earlier bit of code).
The heatmap I have is from a mixture (component + solvent). If I wanted to get M/Z values unique to the component, would you recommend following the same steps of MZfilt, Timefilt and Yfilt for my solvent, extracting those values and subtracting them in a new heatmap argument? My objective is to find solvent removed M/Z values.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!