1D Plotting

Since visualization in higher dimensions can be difficult, it is essential when assesing experiment quality to visualize precursors in 1D where one axis is intensity and the other axis is a separation (e.g. retention time, ion mobility or m/z)

Warning

We are currently migrating the plotting library over to pyopenms_viz, current plotting interface is unstable.

As seen previously TransitionGroup stores 1D data including a chromatogram, mobilogram or spectrum. If a chromatogram loader is used, only the TransitionGroup will always hold a Chromatogram. If a SpectrumLoader is used, the TransitionGroup may hold a Chromatogram, Mobilogram or Spectrum. This can always be checked using the TransitionGroup.type variable

Loading data

[4]:
from massdash.loaders import MzMLDataLoader
from massdash.structs import TargetedDIAConfig

# Initate TargetedDIAConfig and set parameters
extraction_config = TargetedDIAConfig()
extraction_config.im_window = 0.2
extraction_config.rt_window = 50
extraction_config.mz_tol = 20

# Initiate loader object
loader = MzMLDataLoader(dataFiles="mzml/ionMobilityTest.mzML",
                        rsltsFile=["osw/ionMobilityTest.osw", "diann/ionMobilityTest-diannReport.tsv"])

# fetch transitionGroup for target peptide - Will always return a chromatogram object
transitionGroup = loader.loadTransitionGroups("AFVDFLSDEIK", 2, extraction_config)['ionMobilityTest'] # ionMobilityTest is the run name

# fetch featureMap for target peptide
featureMap = loader.loadFeatureMaps("AFVDFLSDEIK", 2, extraction_config)['ionMobilityTest']

# fetch transition group features
transitionGroupFeatures = loader.loadTransitionGroupFeatures("AFVDFLSDEIK", 2)['ionMobilityTest']
Initializing valid scores for selection
[2024-10-08 16:34:14,378] MzMLDataAccess - INFO - Opening mzml/ionMobilityTest.mzML file...: Elapsed 0.07661747932434082 ms
[2024-10-08 16:34:14,379] MzMLDataAccess - INFO - There are 50 spectra and 0 chromatograms.
[2024-10-08 16:34:14,380] MzMLDataAccess - INFO - There are 25 MS1 spectra and 25 MS2 spectra.

If this above code looks unfamilliar, please look at previous python documentation.

Plotting Chromatograms

Chromatograms can be plotted directly from a TransitionGroup by calling the plot() function.

[5]:
transitionGroup.plot()
Loading BokehJS ...
[5]:
transitionGroup.plot(transitionGroupFeatures=transitionGroupFeatures)
Loading BokehJS ...

Plotting Mobilograms

If spectra contain ion mobility, plotting ion mobilograms is helpful in evaluting the quality of a precursor. Ideally, the ion mobilogram should look similar to the chromatogram with clean coelution of the different transitions.

The ion mobilogram can be fetched from a FeatureMap and plotted as shown below.

[6]:
featureMap.to_mobilograms().plot()
Loading BokehJS ...

Plotting Spectra

MassDash can also plot an almagated spectrum across retention time and ion mobility of just the extracted ion traces as shown below.

[7]:
featureMap.to_spectra().plot()
Loading BokehJS ...

Note

This is not a complete spectrum, it only contains traces corresponding to the transitions in the library.