Giter Site home page Giter Site logo

cremerlab / hplc-py Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 4.0 47.81 MB

A Python utility for the processing and quantification of chromatography data

Home Page: https://cremerlab.github.io/hplc-py/

License: GNU General Public License v3.0

Python 100.00%
analytical-chemistry chromatography-analysis hplc

hplc-py's People

Contributors

florian-huber avatar gchure avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hplc-py's Issues

Help with peak fitting parameters

Hello, I'm having some difficulty understanding the hplc-py peak fitting parameters and tuning them appropriately. It could be helpful to offer more examples of how changing them affects the results.

What parameters would you suggest to integrate this chromatogram?
Default:
image

Using approx_peak_width=0.25 (uncommented the line in the above codeblock):
image

Neither of the two examples seems to be visually valid, and I'm not finding a combination of parameters that would make sense.

For reference, this is what Chemstation returns:
image

Setting `fit_peaks` prominence below 0.2 results in upper bounds with lower value than lower bounds.

I am testing the application of fit_peaks to my dataset, whose profile you can see below:

output

The behavior is as expected unless I set peak prominence below 0.2, at which point I receive an error from least_squares informing me that at least one upper bound is less than the corresponding lower bound.

The error is below:

Traceback (most recent call last):
  File "/Users/jonathan/mres_thesis/wine_analysis_hplc_uv/src/wine_analysis_hplc_uv/dataset_eda/peak_analysis.py", line 125, in <module>
    main()
  File "/Users/jonathan/mres_thesis/wine_analysis_hplc_uv/src/wine_analysis_hplc_uv/dataset_eda/peak_analysis.py", line 122, in main
    HPLCPy(data)
  File "/Users/jonathan/mres_thesis/wine_analysis_hplc_uv/src/wine_analysis_hplc_uv/dataset_eda/peak_analysis.py", line 103, in __init__
    peaks = chm.fit_peaks(
            ^^^^^^^^^^^^^^
  File "/Users/jonathan/Library/Caches/pypoetry/virtualenvs/wine-analysis-hplc-uv-F-SbhWjO-py3.11/lib/python3.11/site-packages/hplc/quant.py", line 801, in fit_peaks
    peak_props = self.deconvolve_peaks(verbose=verbose,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonathan/Library/Caches/pypoetry/virtualenvs/wine-analysis-hplc-uv-F-SbhWjO-py3.11/lib/python3.11/site-packages/hplc/quant.py", line 671, in deconvolve_peaks
    popt, _ = scipy.optimize.curve_fit(self._fit_skewnorms, v['time_range'],
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonathan/Library/Caches/pypoetry/virtualenvs/wine-analysis-hplc-uv-F-SbhWjO-py3.11/lib/python3.11/site-packages/scipy/optimize/_minpack_py.py", line 974, in curve_fit
    res = least_squares(func, p0, jac=jac, bounds=bounds, method=method,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jonathan/Library/Caches/pypoetry/virtualenvs/wine-analysis-hplc-uv-F-SbhWjO-py3.11/lib/python3.11/site-packages/scipy/optimize/_lsq/least_squares.py", line 814, in least_squares
    raise ValueError("Each lower bound must be strictly less than each "
ValueError: Each lower bound must be strictly less than each upper bound.

The bounds in question are below, where 'lb' is lower bound, 'ub' is upper bound:

lb ub
0 0.000378979 0.0378979
1 0 0
2 0.0004896 0
3 -inf inf

As I understand it, the prominence is the normalized prominence, i.e. the percentage of the maxima as a threshold for inclusion of a given peak. For the same dataset i've been using a value of 0.05 to ignore the smallest peaks with no problem.

Replace SNIP implementation with broad integration of `pybaselines`

I've developed hplc-py using only one baseline estimation algorithm (SNIP), but there are many options that can be used. These are nicely tested and developed in the pybaselines package. A development goal of hplc-py would be to deprecate the correct_baseline method of a Chromatogram with a call to the broad pybaselines API.

Small issue in correct_baseline method

Hi, cool library! I noticed a small issue in the correct_baseline method in quant.py.

hplc-py/hplc/quant.py

Lines 884 to 885 in 8ce5223

tform_new[j] = min(tform_new[j], 0.5 *
(tform_new[j+i] + tform_new[j-i]))

Within the inner loop, the values of tform need to be used for the minimum comparison rather than tform_new. Since tform_new is being written to within the loop, using its values for the comparison will cause some unforseen issues. To help compare with Morhác's original SNIP implementation, the working vector (w in the paper) is tform_new and the current vector (v in the paper) is tform.

The suggested change is show below:

for i in iter:
    tform_new = tform.copy()
    for j in range(i, len(tform) - i):
        tform_new[j] = min(tform[j], 0.5 * (tform[j+i] + tform[j-i]))  # changed here
    tform = tform_new

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.