3.2. Acquisition
This module implements the Acquisition object which is a set of data collected from a sample.
A sample in this case could mean a biologically-derived sample or a blank or any other unit that is analyzed for analysis.
Each analytical replicate is therefore its own acquisition.
- class pcpfm.Acquisition.Acquisition(name, source_filepath=None, metadata_tags=None, raw_filepath=None, mzml_filepath=None, ionization_mode=None, has_ms2=None, experiment=None)[source]
Bases:
SampleThe Acquisition object represents a single LC-MS run.
- TIC(mz=None, ppm=5, rt=None, rt_tol=2, title=None)[source]
This method generates TIC plots for the acquisition. If mz and rt is not provided, this will make the TIC including the entire rt range and all mz values. If mz and rt values are provided as co-indexed lists, then only those regions will be used IN ADDITION to the entire rt and mz range. These are saved as figures.
- Parameters:
mz (list, optional) – mz values to limit the TIC calculation to. Defaults to None.
ppm (int, optional) – mass tolerance in ppm for the mz values. Defaults to 5.
rt (list, optional) – rt values to limit the TIC caclulation to. Defaults to None.
rt_tol (int, optional) – rt_tolerance in seconds. Defaults to 2.
title (string, optional) – if provided, sets the title on TIC plot. Defaults to None.
- Returns:
path to the TIC plot
- Return type:
str
- static create_acquisition(name, source_filepath, metadata_dict, experiment=None)[source]
This is the primary constructor the acquisition object.
- Parameters:
name – the name of the acquisition
source_filepath – the original location of the data file
metadata_dict – the metadata associated with the file, provided by the .csv file.
- Returns:
Acquisition object
- filter(user_filter)[source]
This method filters acquisition based on their metadata keys.
The filter is organized as follows:
{ "key_1": { "includes": ["substr1", "substr2"], "lacks": ["substr3"] } ... }
In this case, key_1 must be a field in the metadata. It will pass the filter if and only if every substring (substr1, substr2) from includes is present in the metadata field’s value AND every substring in the lacks field (substr3) is not present in the field’s data.
Multiple keys can be specified in the filter. The results from the filter are AND’d for every key.
- Parameters:
filter – dictionary as described above
- Returns:
true if acquisition passed filter else false
- property has_ms2
Scan the mzml to detect if there are MS2 spectra
- Returns:
has_MS2, True or False
- property ionization_mode
This method determines the ionization mode of the acquisition
- Returns:
ionization mode, “pos” or “neg”
- property json_repr
This generates the dict representation of the acquisition, this is used when the experiment is saved or loaded.
- Returns:
a JSON-friendly dictionary for serialization during experiment saving and loading