Documentation Center

  • Trials
  • Product Updates





Open Data Repositories and mzXML File Format


Most of the current mass spectrometers can translate or save the acquisition data using the mzXML schema. This standard is an XML (eXtensible Markup Language)-based common file format developed by the Sashimi project to address the challenges involved in representing data sets from different manufacturers and from different experimental setups into a common and expandable schema. mzXML files used in hyphenated mass spectrometry are usually very large, the MZXMLINFO function allows you to obtain basic information about the dataset without reading it into memory, for instance the number of scans, the range of the retention time, and the number of tandem MS instruments (levels):

info = 

                            Filename: '7MIX_STD_110802_1.mzXML'
                            FileSize: 26789612
                       NumberOfScans: 7161
                           StartTime: 'PT0.00683333S'
                             EndTime: 'PT200.036S'
       DataProcessingIntensityCutoff: 'N/A'
            DataProcessingCentroided: 'false'
            DataProcessingDeisotoped: 'N/A'
    DataProcessingChargeDeconvoluted: 'N/A'
       DataProcessingSpotIntegration: 'N/A'
                    NumberOfMSLevels: 2


Starting to parse document...
Building mzXML substructure...
Building scan substructure...
Building index substructure...

mzXML_struct = 

     scan: [2387x1 struct]
    mzXML: [1x1 struct]
    index: [1x1 struct]



ans = 

         scanCount: 7161
         startTime: 'PT0.00683333S'
           endTime: 'PT200.036S'
        parentFile: [1x1 struct]
      msInstrument: [1x1 struct]
    dataProcessing: [1x1 struct]

To facilitate the handling of the data, the MZXML2PEAKS function extracts the list of peaks from each scan into a cell array (peaks]) and their respective retention time into a column vector (time). You can extract only the spectra of certain level by setting the LEVEL input parameter:

[peaks,time] = mzxml2peaks(mzXML_struct);
numScans = numel(peaks)
numScans =



title('5 Percent Overall Most Intense Peaks')

You can also filter the peaks individually for each scan using a percentile of the base peak intensity. The base peak is the most intense peak found in each scan [3]. This parameter is given automatically by most of the spectrometers. This operation requires querying into the mxXML structure to obtain the base peak information. Note that you could also find the base peak intensity by iterating the MAX function over the peak list:

basePeakInt = [mzXML_struct.scan.basePeakIntensity]';
peaks_fil = cell(numScans,1);
for i = 1:numScans

  Name                Size               Bytes  Class     Attributes

  basePeakInt      2387x1                19096  double              
  peaks            2387x1             14050896  cell                
  peaks_fil        2387x1               308664  cell                

You can customize a 3-D overview of the filtered peaks using the STEM3 function. The STEM3 function requires to put the data into three vectors where respective entries form the triplets (the retention time, the mass/charge, and the intensity value) that represent every stem.

peaks_3D = cell(numScans,1);
for i = 1:numScans
peaks_3D = cell2mat(peaks_3D);

axis([0 12000 400 1500 0 1e9])
xlabel('Retention Time (seconds)')
zlabel('Relative Ion Intensity')

You can plot colored stems using the PATCH function. For every triplet in peaks_3D, interleave a new triplet with the intensity value set to zero. Then create a color vector dependent on the intensity of the stem, a logarithmic transformation enhances dynamic range of the colormap. For the interleaved triplets assign a NaN, this will force PATCH to do not draw lines connecting contiguous stems.

peaks_patch = sortrows(repmat(peaks_3D,2,1));

col_vec = log(peaks_patch(:,3));
col_vec(2:2:end) = NaN;

axis([0 12000 400 1500 0 1e9])
xlabel('Retention Time (seconds)')
zlabel('Relative Ion Intensity')


Creating Heat Maps of LC/MS Data Sets

Common techniques in the industry work with peak information (a.k.a. centroided data) instead of raw signals, this saves memory, but some important details are not visible, especially when it is necessary to inspect samples with complex mixtures. To further analyze of this data set MATLAB can create a common grid in the mass/charge dimension. Since not all of the scans have enough information to reconstruct the original signal, we use a peak preserving resampling method. By choosing the appropriate parameters for the MSPPRESAMPLE function you can ensure that the resolution of the spectra is not lost and that the maximum values of the peaks correlate to the original peak information.

  Name         Size                 Bytes  Class     Attributes

  MZ        5000x1                  20000  single              
  Y         5000x2387            47740000  single              

With this matrix of ion intensities, Y, you can create a colored heat map. The MSHEATMAP function automatically adjusts the colorbar utilized to show the statistically significant peaks with hot colors and the noisy peaks with cold colors. The algorithm is based on clustering significant peaks and noisy peaks by estimating a mixture of Gaussians with an Expectation-Maximization approach. Additionally, if desired, you can use the MIDPOINT input parameter to select an arbitrary threshold to separate noisy peaks from significant peaks, or, you can interactively shift the colormap to hide or unhide peaks. When working with heat maps, it is common to display the logarithm of the ion intensities, which enhances the dynamic range of the colormap.

title('Original LC/MS Data Set')


axis([527 539 385 496])

You can overlay the original peak information of the LC/MS data set. This allows you evaluate the performance of the peak-preserving resampling operation. You can use the returned handle to hide/unhide the dots.

dp1 = msdotplot(peaks,time);

Calibrating the Mass/Charge Location of Peaks to a Common Grid


[CMZ, peaks_CMZ] = mspalign(peaks);

Repeat the visualization process with the aligned peaks: perform peak preserving resampling, create a heat map, overlay the aligned peak information and zoom into the same region of interest as before. Note: when the spectra is re-calibrated, it is possible to distinguish the isotope patterns of some of the peptides.

dp2 = msdotplot(peaks_CMZ,time);
axis([527 539 385 496])

Calibrating the Mass/Charge Location of Peaks Locally




peaks_FMZ = cell(numScans,1);
for i = 1:numScans
    % show progress
    if ~rem(i,250), fprintf(' %d...',i); end
    % align peaks in current scan to LAI
    % updating the LAI buffer
    LAI = LAI*.25;
    %save the alignment

Repeat the visualization process and zoom to the region of interest:

dp3 = msdotplot(peaks_FMZ,time);
axis([527 539 385 496])


title('Final Enhanced LC/MS Data Set')
dp4 = msdotplot(peaks_FMZ,time);
axis([527 539 385 496])


axis([521 538 266 617])

Extracting Spectra Using the Total Ion Chromatogram


TIC = mean(YF);
numPeaks = size(pt,1)
numPeaks =


Create a 3-D plot of the selected spectra.


figure; hold on; box on
set(gcf,'Position',get(gcf,'Position')+[0 -200 0 200])
axis([500 900 0 numPeaks 0 1e8])
zlabel('Relative Ion Intensity')
title('Extracted Spectra Subset')

Overlay markers for the extracted spectra over the enhanced heatmap:

hold on
for i = 1:numPeaks
axis([500 900 100 925])


[1] F. Desiere, E.W. Deutsch, N.L. King, A.I. Nesvizhskii, P. Mallick, J. Eng, S. Chen, J. Eddes, S.N. Loevenich, and R. Aebersold, "The Peptide Atlas Project", Nucleic Acids Research, 34, D655-D658, 2006.

[2] J.A. Falkner, J.W. Falkner, and P.C. Andrews, " JAF: reference information and tools for proteomics", Bioinformatics 22(5):632-633, 2006

[3] S. Purvine, N. Kolker, and E. Kolker, "Spectral Quality Assessment for High-Throughput Tandem Mass Spectrometry Proteomics", OMICS A Journal of Integrative Biology, 8(3), pp 255-265, 2004

[4] A.S. Kazmi, S. Ghosh, D-G. Shin, D.W. Hill, and F.D. Grant, "Alignment of high resolution mass spectra: Development of a heuristic approach for metabolomics", Metabolomics, 2(2), pp 75-83, 2006.

[5] Jeffries, N. "Algorithms for alignment of mass spectrometry proteomic data", Bioinformatics, 21(14):3066-3073, 2005.

[6] W. Yu, X. Li, J. Liu, B. Wu, K. Williams, H. Zhao. "Multiple peak alignment in sequential data analysis: A scale-space based approach", IEEE®/ACM Trans. Computational Biology and Bioinformatics, 3(3), pp 208-219, 2006.

[7] H. Sakoe and S. Chiba. "Dynamic programming algorithm optimization for spoken word recognition", IEEE Trans. Acoustics, Speech and Signal Processing, ASSP-26(1), pp 43-49, 1978.

Suggest an enhancement for this example.

Was this topic helpful?