Skip to content

Add Peak Detection and Deconvolution #36

Open
pbulsink wants to merge 13 commits into
mainfrom
troubled-foe
Open

Add Peak Detection and Deconvolution #36
pbulsink wants to merge 13 commits into
mainfrom
troubled-foe

Conversation

@pbulsink

Copy link
Copy Markdown
Collaborator

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.

pbulsink and others added 11 commits June 3, 2026 11:41
- 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
Copilot AI review requested due to automatic review settings July 18, 2026 18:11
Comment thread R/PlotFTIR-package.R

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread R/peak-fit.R Outdated
Comment thread R/peak-fit.R
Comment thread R/peak-fit.R Outdated
Comment thread R/peak-fit.R Outdated
Comment thread R/peak-fit.R Outdated
Comment thread R/peak-fit.R Outdated
Comment thread R/utils.R
Comment thread R/utils.R
Comment thread tests/testthat/test-peak-fit.R
Comment thread DESCRIPTION Outdated
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:::`.
@pbulsink pbulsink changed the title Add Peak Detection and Deconvolution Deconvolution Add Peak Detection and Deconvolution Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants