Get M/Z values in a msheatmap/msdotplot overlay with a pixel pseudocolor value greater than 120 (the range is 0 - 195)?
3 views (last 30 days)
Show older comments
Sindhuraj Mukherjee
on 19 Apr 2020
Commented: Sindhuraj Mukherjee
on 21 Apr 2020
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.
0 Comments
Accepted Answer
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
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
More Answers (0)
See Also
Categories
Find more on Read, Write, and Modify Image 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!