metbit.take_intensity
Visualization and apps module in metbit 8.3.0.
import metbit.take_intensityClasses
get_intensity
A class to display and interact with NMR spectral data, enabling users to pick peaks from an interactive plot.
Parameters: - spectra (pd.DataFrame): A DataFrame containing NMR spectral data with rows representing different spectra and columns representing intensity values at each chemical shift (ppm). - ppm (list): A list of ppm values corresponding to the columns in the `spectra` DataFrame.
Methods: - run_ui: Launches a Dash web application with a user interface to visualize NMR spectra, select peaks interactively, and export peak positions.
Example: ```python # Load your NMR spectra data df = pd.read_csv("https://raw.githubusercontent.com/aeiwz/example_data/main/dataset/Example_NMR_data.csv") #If plot with single spectra spectra = df.iloc[[1],1:] #If plot with multiple spectra spectra = df.iloc[:,1:] ppm = spectra.columns.astype(float).to_list() label = df['Group']
# Create instance of the class with spectra and ppm data picker_ui = get_intensity(spectra, ppm, label)
# Get the app instance app = picker_ui.run_ui()
# Run the app app.run_server(debug=True, port=8051) ```
Usage: 1. **Plot Visualization**: Displays the spectra using an interactive Plotly graph. 2. **Peak Selection**: Allows users to click on the plot to select peaks, storing their positions. 3. **Export Functionality**: Offers options to export selected peak positions as a CSV file.
Methods
__init__(self, spectra: pd.DataFrame, ppm: list, label: list)
run_ui(self)
Launches the Dash application for visualizing and selecting NMR spectral peaks.
Components: - Interactive Plot: Displays NMR spectra with options to click on peaks. - Peak Selection: Allows users to store selected peak positions. - Export Data: Provides an option to download selected peak positions as a CSV file.
Returns: - Dash app: An interactive web application with plot, data selection, and export features.