API#
Alpinac package.
- alpinac.requires_sup(fallback_instructions: str)#
Decorator to check if alpinac_sups is available.
If not, it raises an ImportError.
- Parameters:
fallback_instructions – instructions to give to the user if alpinac_sups is not available
- Returns:
the decorator
- alpinac.mode_identification.main.make_identification(mass: list[float], mass_uncertainty: list[float] | float = 1.0, mass_cal_uncertainty: list[float] | float = 0.0, area: list[float] | float = 0.0, area_uncertainty: list[float] | float = 0.0, peak_width: list[float] | float = 1e-05, peak_alpha: list[float] | float = 0.0, retention_time: list[float] | float = 0.0, ionisation_type: list[str] | str = 'EI', limit_of_detection: list[float] | float = 0.0, signal_to_noise_ratio: list[float] | float = 0.0, compound_index: list[int] = [], spectrum_id: list[int] | None = None, adduct: list[str | list[str]] | str = '', target_elements: str | None = None, target_formula: str | None = None, show_plt_figures: bool = False, run_id=None, min_measured_mass: float = 23.0, max_opt_signal: float = 95.0, do_validation: bool = False, expected_compound_name: str | None = None, fitting_method: FittingMethod = FittingMethod.continuous) dict[int, alpinac.mode_identification.output_saver.IdentificationOutput]#
Make identification for data array.
- Parameters:
mass – measured masses (ionised, not corrected for electron loss). Unit [m/z].
mass_uncertainty – The measurement uncertainty (standard deviation) of the mass. Unit [ppm].
mass_cal_uncertainty – The uncertainty on the mass calibration. This value should be obtained frm the mass calibration routine. Unit [ppm].
area – signal intensity, value already integrated in the mass domain and in the retention time domain.
area_uncertainty – experimental standard deviation, usually better than 1%. Not used so far.
peak_width – width of the peak in the mass domain, can be computed beforehand based on TOF data. Ths value is used as tolerance to estimate if a candidate mass can be matched to a measured mass (see class isotopologue, function find_idx_meas_mass_from_exact_mass).
peak_alpha – contribution of lorentian signal to peak shape in the mass domain.
retention_time – A list of the retention time for each peak. This is optional at the moment and not used by alpinac.
ionisation_type – “EI” for electron ionisation and “CI” for chemical ionisation.
limit_of_detection – this value should be estimated by the user, based on experimental data. This LOD value will be automatically set as not more than the smallest area in the dataset, but the LOD given here can also be much smaller than the smallest area in the dataset.
signal_to_noise_ratio – not used.
compound_index – A list of integers containing for each peak an integer id that specifies to which spectrum the peak is included. Negative values are ignored.
spectrum_id – ID of the spectrum (or spectra). Needed to identify which mass belong to which spectra. Note that several replicate measurements with the exact same ionisation settings can be treated together, or data assumed to belong to the same substance but measured with different ionisation settings.
adduct – for each mass, list of formula of the adduct(s). If a peak contained no adduct, it must be specified by the empty string “”. If this is one formula, this is the “maximal” formula (e.g., H3) and alpinac will use H3, H2 or H.
target_elements – chemical element to use for the knapsack. If None, the default list is used.
target_formula – target chemical formula. This is used as the maximal possible formula.
min_measured_mass – The smallest possible measured mass. This is minimum mass that can be detected given the TOF experimental settings (high-pass filter settings). Only chemical formulae with a mass larger than this will be given by the algorithm.
do_validation – Whether to do the validation step.
expected_compound_name – The name of the compound expected for the validation.
- Return identification_output:
A dictionary mapping each compound_index given in the arguments to a
IdentificationOutput.
- class alpinac.compound.Compound(one_batch_fragment: list[list[float | str | int]], compound_number: int | str = '', LOD: float = inf, mass_u_k: float = 3.0, mass_u_k_loose: float = 3.0)#
A compound is what alpinac tries to identify.
At the beggining of the identification, a compound is a group of measured peaks (or measured fragments) belonging to the same RT index.
The most important measured data are the measured masses and their corresponding signal intensities.
A compund can be composed of different spectra, with usually different ionisation modes.
Sometimes coumpounds co-elute and therefore are likely to belong to the same chemical compound or they could also belong to several co-eluting chemical compounds.
Attributes#
logger: A logger object.
fragment_index: The index of the compound in the inputs. data: The measured data of the compound. It the the one_batch_fragment
argument of the __init__ method.
- unit_mass_resolution: If the masses are specified in unit of mass resolution.
Note
Identification of unit masses was performed during the developpement of alpinac. Now it is not used anymore and is not fully supported/tested in all the code.
- mass_u_k: Coverage factor for the mass uncertainty,
mutiply this to the mass uncertainty. See equation (1) in Guillevic et al.
- mass_u_k_loose: A parameter that scales the meas_mass_u_peak_width of a peak.
Not clear what it represents exactly. TODO: explain.
mass_axis_offset: The offset of the mass axis. Not clear what it represents. TODO: explain. alpha_pseudo_voigt: The mean of the alpha parameter of the pseudo-Voigt function.
The alpha parameter is found in the data. The alpha parameter is the Lorenzian contribution to peak shape. see pseudo-Voigt function.
- sigma_m_slope: The slope of the linear fit of the mass (x) vs peakwidth (y).
The peakwidth is the sigma of the peaks. (Assumes the sigma varies linearly with the mass)
sigma_m_b: The intercept of the linear fit.
meas_len: The number of measured peaks in the compound. meas_rt: The retention times of the center of each peaks. ionisation: The ionisation mode of the peaks. (EI or CI) meas_I: The signal intensity of the peaks (area of the peak). meas_LOD: The limit of detection of the peaks. meas_mass: The m/z ratio of the peaks. Unit: m/z. meas_mass_min: The minimum value of the m/z ration for the peaks
(part of the interval of possible masses).
- meas_mass_max: The maximum value of the m/z ration for the peaks
(part of the interval of possible masses).
- meas_mass_u: The uncertainty of the m/z values due to
measurement noise. Unit: m/z.
- meas_mass_u_cal: The uncertainty of the m/z values due to
the mass calibration. Unit: m/z.
- meas_mass_U_combined: The combined uncertainty (mass_u + mass_u_cal)
of the m/z values, multiplied by mass_u_k. Unit: m/z.
meas_mass_U_combined_ppm: The combined uncertainty of the m/z values. Unit: ppm. meas_mass_u_median: The median of the combined uncertainty of the m/z values. Unit: m/z. meas_mass_u_median_ppm: The median of the combined uncertainty of the m/z values. Unit: ppm of m/z. meas_mass_u_peak_width: The Uncertainty due to peak width in the mass domain. Unit: m/z.
The peak width is used for that and is the sigma of the peaks
average_rt: average retention time sum_I: sum of the signal intensity of the peaks meas_I_max: maximal intensity of all the peaks meas_I_min: minimal intensity of all the peaks
- spectras: A list of Spectra objects. Each Spectra object contains
the information about a the type of spectra (EI or CI). And the information about the adducts for CI spectra.
- spectra_ids: A list of the index of the spectra in :attr:spectras: for
each of the peaks.