chemistry_tools.spectrum_similarity
Mass spectrum similarity calculations.
Classes:
|
Calculate the similarity score for two mass spectra. |
Functions:
|
Create a |
|
Returns the normalised intensity for each rows of a |
|
Calculate the similarity score for two mass spectra. |
-
class
SpectrumSimilarity(spec_top, spec_bottom, b=1, xlim=(50, 1200))[source] Calculate the similarity score for two mass spectra.
- Parameters
spec_top (
ndarray) – Array containing the experimental spectrum’s peak list with the m/z values in the first column and corresponding intensities in the secondspec_bottom (
ndarray) – Array containing the reference spectrum’s peak list with the m/z values in the first column and corresponding intensities in the secondb (
float) – numeric value specifying the baseline threshold for peak identification. Expressed as a percent of the maximum intensity. Default1.xlim (
Tuple[int,int]) – tuple of length 2, defining the beginning and ending values of the x-axis. Default(50, 1200).
New in version 1.0.0.
Methods:
plot([top_label, bottom_label, filter])Plot the mass spectra head to tail.
Print the dataframe giving aligned peaks in the top and bottom spectra.
score()Returns the similarity score.
-
create_array(intensities, mz)[source] Create a
numpy.ndarray, in a format appropriate forSpectrumSimilarity, from a list of intensities and a list of m/z values.
-
normalize(row, max_val)[source] Returns the normalised intensity for each rows of a
pandas.DataFrame.
-
spectrum_similarity(spec_top, spec_bottom, t=0.25, b=10, top_label=None, bottom_label=None, xlim=(50, 1200), x_threshold=0, print_alignment=False, print_graphic=True, output_list=False)[source] Calculate the similarity score for two mass spectra.
Attention
The
SpectrumSimilarityclass is recommended over this function.- Parameters
spec_top (
ndarray) – Array containing the experimental spectrum’s peak list with the m/z values in the first column and corresponding intensities in the secondspec_bottom (
ndarray) – Array containing the reference spectrum’s peak list with the m/z values in the first column and corresponding intensities in the secondt (
float) – numeric value specifying the tolerance used to align the m/z values of the two spectra. Default0.25.b (
float) – numeric value specifying the baseline threshold for peak identification. Expressed as a percent of the maximum intensity. Default10.top_label (
Optional[str]) – string to label the top spectrum. DefaultNone.bottom_label (
Optional[str]) – string to label the bottom spectrum. DefaultNone.xlim (
Tuple[int,int]) – tuple of length 2, defining the beginning and ending values of the x-axis. Default(50, 1200).x_threshold (
float) – Default0.print_alignment (
bool) – whether the intensities should be printed. DefaultFalse.output_list (
bool) – whether the intensities should be returned as a third element of the tuple. DefaultFalse.
- Return type