Add Peak Detection and Deconvolution #36
Open
pbulsink wants to merge 13 commits into
Open
Conversation
Skills updates
…o deconvolution
- Created documentation for `find_ftir_peaks` to detail peak finding in FTIR spectra. - Added `fit_peaks` documentation to explain peak fitting methods and parameters. - Introduced `fit_peak_df` for converting fitted peak objects to data frames. - Documented `get_fit_method` and `get_fit_spectra` for retrieving fitting details. - Added `plot_components`, `plot_fit_ftir_peaks`, and `plot_fit_residuals` for visualizing peak fitting results. - Included French translations for all documentation entries to support bilingual users.
Renames several peak-fitting helper functions to internal-style names (prefixed with `.`) and updates call sites, tightens `method` validation in `fit_peaks()` with `rlang::arg_match()`, and refreshes roxygen tags/parameter docs. Test coverage is updated to match fitted peak expectations, add validation for even `sg_n_norm`, and make plot-label assertions less brittle.
… fn calls, standardize cli errors, add @inheritParams for call param
pbulsink
commented
Jul 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds peak detection, peak fitting (deconvolution), and related plotting utilities to PlotFTIR, bringing in peak-shape EM optimizers and a comprehensive test suite to support qualitative peak analysis workflows.
Changes:
- Introduces
find_ftir_peaks(),fit_peaks(),fit_peak_df(), and plotting helpers for fitted sums, residuals, and components. - Adds internal peak-shape EM optimization implementations and supporting helpers.
- Updates package exports/imports, documentation (Rd), and development/config files (lintr/ignores/skills/NEWS).
Reviewed changes
Copilot reviewed 14 out of 29 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/testthat/test-peak-fit.R | Adds extensive tests for peak finding, fitting, plotting, and EM optimizer behavior. |
| R/utils.R | Adds .process_language() helper and adjusts printing formatting. |
| R/PlotFTIR-package.R | Adds tibble::as_tibble import for new tibble-based outputs. |
| R/peak-fit.R | New peak detection/fitting/plotting implementation and embedded EM optimizer code. |
| R/aaa-shared_params.R | Extends shared roxygen params to include fitted_peaks. |
| NEWS.md | Documents new peak fitting feature addition. |
| NAMESPACE | Exports new public API functions and imports tibble::as_tibble. |
| man/read_ftir.Rd | Fixes Rd link target for utils::read.csv(). |
| man/read_ftir_directory.Rd | Fixes Rd link target for utils::read.csv(). |
| man/PlotFTIR-package.Rd | Updates package-level author metadata output. |
| man/plot_fit_residuals.Rd | Adds generated documentation for residual plotting. |
| man/plot_fit_ftir_peaks.Rd | Adds generated documentation for fitted-peak plotting. |
| man/plot_components.Rd | Adds generated documentation for component plotting. |
| man/optimization.Rd | Adds generated documentation topic for EM optimization helpers. |
| man/fit_peaks.Rd | Adds generated documentation for fit_peaks(). |
| man/fit_peak_df.Rd | Adds generated documentation for fit_peak_df(). |
| man/find_ftir_peaks.Rd | Adds generated documentation for find_ftir_peaks(). |
| man/dot-shared-params.Rd | Regenerates shared-params Rd with new parameter. |
| man/dot-process_language.Rd | Adds generated documentation for .process_language(). |
| man/dot-get_fit_spectra.Rd | Adds generated documentation for .get_fit_spectra(). |
| man/dot-get_fit_method.Rd | Adds generated documentation for .get_fit_method(). |
| DESCRIPTION | Adds dependencies needed by new functionality and tooling metadata. |
| .Rbuildignore | Tightens ignore patterns and adds additional ignored files. |
| .lintr | Adds lintr configuration. |
| .gitignore | Ignores additional local/dev artifacts. |
| .github/skills/tdd-workflow/SKILL.md | Updates testing workflow guidance. |
| .github/skills/r-code/SKILL.md | Updates R coding guidance (validation/deps/check expectations). |
| .github/skills/implement-issue/SKILL.md | Updates issue-implementation workflow guidance. |
| .github/skills/document/SKILL.md | Updates documentation workflow guidance. |
Files not reviewed (14)
- man/PlotFTIR-package.Rd: Generated file
- man/dot-get_fit_method.Rd: Generated file
- man/dot-get_fit_spectra.Rd: Generated file
- man/dot-process_language.Rd: Generated file
- man/dot-shared-params.Rd: Generated file
- man/find_ftir_peaks.Rd: Generated file
- man/fit_peak_df.Rd: Generated file
- man/fit_peaks.Rd: Generated file
- man/optimization.Rd: Generated file
- man/plot_components.Rd: Generated file
- man/plot_fit_ftir_peaks.Rd: Generated file
- man/plot_fit_residuals.Rd: Generated file
- man/read_ftir.Rd: Generated file
- man/read_ftir_directory.Rd: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds explicit `signal` dependency checks in peak detection, preserves validated `ftir` objects across peak-fit plotting helpers, and fixes auto-peak argument forwarding in `fit_peaks()` via `do.call()`. It also removes `tibble::as_tibble()` usage from `fit_peak_df()` and cleans up package imports accordingly. Additional updates tighten `.process_language()` handling for `NULL`/empty inputs and make peak-fit tests call internal EM helpers explicitly through `PlotFTIR:::`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR merges the peak-fit.R file (and associated tests) from FTIRtools, an unpublished companion package. It permits users to detect and fit peaks using a variety of peak shapes, and plit fitted/residual curves. These techniques are used often in qualitative work.