Classes
STOCSY_app
A Dash application for visualizing NMR spectra and performing STOCSY analysis.
Parameters:
spectrapd.DataFrameDataFrame containing the NMR spectra data.
ppmlistList of PPM (parts per million) values corresponding to the spectra.
Methods:
run_ui() -> dash.Dash: Sets up the Dash UI layout, initializes the application callbacks, and returns the app instance.
Example:
# Load your NMR spectra data df = pd.read_csv("https://raw.githubusercontent.com/aeiwz/example_data/main/dataset/Example_NMR_data.csv") spectra = df.iloc[:,1:] ppm = spectra.columns.astype(float).to_list()
# Create instance of the class with spectra and ppm data stocsy_app = STOCSY_app(spectra, ppm)
# Get the app instance app = stocsy_app.run_ui()
# Run the app app.run_server(debug=True, port=8051)
Methods
__init__(self, spectra: pd.DataFrame, ppm: list)
Initializes the STOCSY_app with NMR spectra and corresponding PPM values.
Parameters:
spectrapd.DataFrameA DataFrame containing the NMR spectra data, where each row represents a sample.
ppmlistA list of PPM values corresponding to the spectral data columns.
cached_stocsy(self, x_peak, pvalue_threshold)
Cache the STOCSY analysis results to avoid redundant computation.
Parameters:
x_peakfloatThe anchor PPM value for the STOCSY analysis.
pvalue_thresholdfloatThe p-value threshold used to filter correlated peaks.
Returns:
plotly.graph_objects.Figure A Plotly figure containing the STOCSY plot.
Examples:
>>> import pandas as pd >>> import numpy as np >>> spectra = pd.DataFrame(np.random.rand(20, 100)) >>> ppm = list(np.linspace(0.5, 9.5, 100)) >>> app_instance = STOCSY_app(spectra, ppm) >>> fig = app_instance.cached_stocsy(3.56, 0.05) >>> fig.show()
run_ui(self)
Sets up the Dash UI layout, registers callbacks, and returns the Dash app instance.
Returns:
dash.Dash A configured Dash application ready to be served.
Examples:
>>> import pandas as pd >>> import numpy as np >>> spectra = pd.DataFrame(np.random.rand(20, 100)) >>> ppm = list(np.linspace(0.5, 9.5, 100)) >>> stocsy_app = STOCSY_app(spectra, ppm) >>> app = stocsy_app.run_ui() >>> app.run_server(debug=True, port=8051) # doctest: +SKIP