Classes
annotate_peak
A Dash application for annotating NMR spectra with interactive features. This application allows users to visualize NMR spectra, add annotations, style lines, and export annotations in HTML and JSON formats. Parameters: - spectra: DataFrame containing NMR spectra data. - ppm: List of ppm values corresponding to the spectra. - label: Series or DataFrame containing labels for the spectra. Usage: ```python import pandas as pd df = pd.read_csv('path_to_your_data.csv') spectra = df.iloc[:, 1:] # Assuming first column is not part of spectra ppm = spectra.columns.astype(float).to_list() label = df['Group'] # Assuming 'Group' is the label column annotator = annotate_peak(label, spectra, ppm, label) annotator.run(debug=True, port=8050) ```
Examples: >>> import pandas as pd >>> import numpy as np >>> ppm = np.linspace(0.5, 9.5, 200) >>> spectra = pd.DataFrame(np.random.randn(10, 200), columns=ppm) >>> label = pd.Series(['A'] * 5 + ['B'] * 5, name='Group') >>> app = annotate_peak(meta=label, spectra=spectra, label=label) >>> app.run(debug=False, port=8050) # doctest: +SKIP
Methods
__init__(self, meta, spectra, ppm=None, label=None, colour_dict: dict=None)
run(self, debug=True, port=8050)
Launch the Dash server for the NMR annotator application.
Args: debug (bool): Enable Dash debug mode with hot-reloading. Defaults to True. port (int): Port number to serve the application on. Defaults to 8050.
Examples: >>> import pandas as pd >>> import numpy as np >>> ppm = np.linspace(0.5, 9.5, 200) >>> spectra = pd.DataFrame(np.random.randn(10, 200), columns=ppm) >>> label = pd.Series(['A'] * 5 + ['B'] * 5, name='Group') >>> app = annotate_peak(meta=label, spectra=spectra, label=label) >>> app.run(debug=False, port=8050) # doctest: +SKIP