Skip to content

Commit

Permalink
Merge pull request #11 from cremerlab/10-small-issue-in-correct_basel…
Browse files Browse the repository at this point in the history
…ine-method

Bug fix for: #10 small issue in correct baseline method
  • Loading branch information
gchure authored Jan 23, 2024
2 parents 8ce5223 + 24a56b3 commit 14bb8d9
Show file tree
Hide file tree
Showing 13 changed files with 11,211 additions and 8,138 deletions.
73 changes: 33 additions & 40 deletions docs/source/getting_started/algorithm.ipynb

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/source/methodology/baseline.ipynb

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions docs/source/methodology/fitting.ipynb

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions docs/source/methodology/peak_detection.ipynb

Large diffs are not rendered by default.

100 changes: 58 additions & 42 deletions docs/source/methodology/problem.ipynb

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions docs/source/methodology/scoring.ipynb

Large diffs are not rendered by default.

333 changes: 197 additions & 136 deletions docs/source/quickstart.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions hplc/quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,8 @@ def correct_baseline(self,
for i in iter:
tform_new = tform.copy()
for j in range(i, len(tform) - i):
tform_new[j] = min(tform_new[j], 0.5 *
(tform_new[j+i] + tform_new[j-i]))
tform_new[j] = min(tform[j], 0.5 *
(tform[j+i] + tform[j-i]))
tform = tform_new

# Perform the inverse of the LLS transformation and subtract
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import pathlib

__version__ = "0.2.2"
__version__ = "0.2.3"

# The directory containing this file
HERE = pathlib.Path(__file__).parent
Expand Down
8 changes: 6 additions & 2 deletions tests/generate_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@
# ##############################################################################
# TEST DATA FOR MANY PEAKS IN A WINDOW
# ##############################################################################
x = np.arange(0, 70, dt)
locs = np.linspace(10, 55, 10)
x = np.arange(0, 100, dt)
_locs = np.linspace(20, 55, 10)
locs = [10]
for _l in _locs:
locs.append(_l)
locs.append(70)
sig = np.zeros_like(x)
for i in range(len(locs)):
sig += 100 * scipy.stats.norm(locs[i], 1).pdf(x)
Expand Down
13 changes: 6 additions & 7 deletions tests/test_chromatogram.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# %%

import importlib
import hplc.quant
import pandas as pd
import numpy as np
Expand Down Expand Up @@ -107,25 +105,26 @@ def test_bg_estimation():
tol = 1.5E-2
data = pd.read_csv('./tests/test_data/test_SNIP_chrom.csv')
chrom = hplc.quant.Chromatogram(data, cols={'time': 'x', 'signal': 'y'})
_df = chrom.correct_baseline(window=0.5, return_df=True)
_df = chrom.correct_baseline(window=0.75, return_df=True)
# return (chrom, _df, data)
with pytest.warns():
__df = chrom.correct_baseline(window=0.5, return_df=False)
__df = chrom.correct_baseline(window=0.75, return_df=False)

# Ensure that dataframe returning is working.
assert _df is not None
assert __df is None

window = int(0.5 / np.mean(np.diff(data['x'].values)))
window = int(0.75 / np.mean(np.diff(data['x'].values)))
assert np.isclose(chrom.df['estimated_background'].values[window:-window],
data['bg'].values[window:-window], rtol=tol).all()

with pytest.warns():
chrom.correct_baseline(window=0.5)
chrom.correct_baseline(window=0.75)

data['y'] -= 100
chrom = hplc.quant.Chromatogram(data, cols={'time': 'x', 'signal': 'y'})
with pytest.warns():
chrom.correct_baseline(window=0.5)
chrom.correct_baseline(window=0.75)


def test_shouldered_peaks():
Expand Down
Loading

0 comments on commit 14bb8d9

Please sign in to comment.