nomspectra.recal module
- class nomspectra.recal.ErrorTable(table: Optional[pandas.core.frame.DataFrame] = None)[source]
Bases:
objectA class used to recallibrate mass spectrum
- __init__(table: Optional[pandas.core.frame.DataFrame] = None) None[source]
Init ErrorTable object
- Parameters
table (pandas Datarame) – consist error table: error in ppm for mass
- static assign_error(spec: nomspectra.spectrum.Spectrum, ppm: float = 3, brutto_dict={'C': (4, 30), 'H': (4, 60), 'O': (0, 20)}, mode='-', show_map: bool = True)[source]
Recallibrate by assign error
- Parameters
spec (Spectrum object) – Initial mass spectrum for recallibrate
ppm (float) – Permissible relative error in callibrate error. Default 3.
brutto_dict (dict) – Dictonary with elements ranges for assignment
mode (str) – Optional. Default ‘-’ negative mode. May be +, - or 0
show_error (bool) – Optional. Default True. Show process
- Return type
- static etalon_error(spec: nomspectra.spectrum.Spectrum, etalon: nomspectra.spectrum.Spectrum, quart: float = 0.9, ppm: float = 3, show_map: bool = True)[source]
Recallibrate by etalon
- Parameters
spec (Spectrum object) – Initial mass spectrum for recallibrate
etalon (Spectrum object) – Etalon mass spectrum
quart (float) – Optionaly. by default it is 0.9. Usualy it is enough for good callibration Quartile, which will be taken for calc recallibrate error
ppm (float) – Optionaly. Default 3. permissible relative error in ppm for seak peak in etalon
show_map (bool) – Optional. Default True. Show process
- Return type
- extrapolate(ranges: Optional[Tuple[float, float]] = None) nomspectra.recal.ErrorTable[source]
Extrapolate error data
- Parameters
ranges (Tuple(numeric, numeric)) – Optionaly. Default None - all width of mass in error table. For which diaposone of mass extrapolate data
- Return type
- static fit_kernel(f: numpy.array, mass: numpy.array, err_ppm: float = 3, show_map: bool = True) pandas.core.frame.DataFrame[source]
Fit max intesity of kernel density map
- Parameters
f (np.array) – keerndel density map in numpy array 100*100
show_map (bool) – Optional. Default true. Plot how fit kernel
- Return type
Pandas Dataframe
- static kernel_density_map(df_error: pandas.core.frame.DataFrame, ppm: float = 3) numpy.array[source]
Calculate and plot kernel density map 100*100 for data
- Parameters
df_error (pd.Dataframe) – error_table for generate kerle density map
ppm (float) – Optional. Default 3. treshould for generate
show_map (bool) – Optional. Default False. plot kde
- Return type
numpy array
- static massdiff_error(spec: nomspectra.spectrum.Spectrum, show_map: bool = True)[source]
Self-recallibration of mass-spectra by mass-difference map
- Parameters
spec (Spectrum object) – Initial mass spectrum for recallibrate
show_error (bool) – Optional. Default True. Show process
- Return type
References
Smirnov, K. S., Forcisi, S., Moritz, F., Lucio, M., & Schmitt-Kopplin, P. (2019). Mass difference maps and their application for the recalibration of mass spectrometric data in nontargeted metabolomics. Analytical chemistry, 91(5), 3350-3358.
- static md_error_map(spec: nomspectra.spectrum.Spectrum, ppm: float = 3) pandas.core.frame.DataFrame[source]
Calculate mass differnce map
- Parameters
spec (Spectrum) – data
ppm (float) – Optional. Default 3. Permissible error in ppm
show_map (bool) – Optional. Default False. Show error in ppm versus mass
- Return type
Pandas Dataframe
- nomspectra.recal.recallibrate(spec: nomspectra.spectrum.Spectrum, error_table: Optional[nomspectra.recal.ErrorTable] = None, how: str = 'assign', mode: str = '-', draw: bool = True) nomspectra.spectrum.Spectrum[source]
Recallibrate spectrum
Fine reccalabration based on self (assign or mass differnce map) or with external ethalon spectrum
- Parameters
spec (Spectrum object) – Mass spectrum for recallibration
error_table (ErrorTable object) – Optional. If None - calculate for spec. ErrorTable object contain table error in ppm for mass, default 100 string
how ({'assign', 'mdm', filename}) – Optional. Default ‘assign’. If error_table is None we can choose how to recalculate. ‘assign’ - by assign error, default. ‘mdm’ - by calculation mass-difference map. filename - path to etalon spectrum, treated and saved by nomspectra
mode (str) – Optional. Default ‘-’ negative mode. May be +, - or 0
draw (bool) – Plot error (fit of KDM)
- Return type