Optimize alignment and introduce new configuration options#162
Merged
Conversation
Introduce a 'classic' logical parameter across kinship2 alignment functions to toggle between the original algorithm and a new optimized alignment. Implement a new optimized routine (kinship2_alignped4_optimized) that builds quadratic penalty matrices more efficiently and uses quadprog to solve positioning; kinship2_alignped4 now dispatches to the optimized implementation when classic = FALSE. Update internal API, man pages, and tests to exercise both modes, add benchmarking scripts and results (data-raw/benchmarks_align.R, benchmark_alignment_results.csv), and bump package version and Suggests (mockery). This change improves alignment performance while preserving the classic behavior for compatibility.
Introduce a fast_threshold option and refactor coordinate calculation to support piecewise layout for large pedigrees. calculateCoordinates was modularized (extractCoordinatesFromAlignedPedigree, alignAndExtractComponent) and now splits big pedigrees into connected components (splitPedigreeComponents), computes layouts per component, and offsets/combines them (stitchComponents). Default config/getDefaultPlotConfig and documentation updated to include fast_threshold, new man pages added for the helper functions, and the test expectation adjusted for the added default parameter.
Make rowMeans ignore NA parents (na.rm = TRUE) to avoid spurious NA x positions. Propagate the config argument into alignAndExtractComponent and update its calls so relation-based alignment uses the provided config. In splitPedigreeComponents, switch the ped2fam family id key from ".comp" to "famID" and use that column when splitting components. Update documentation: add config = NULL to alignPedigreeWithRelations Rd and raise the getDefaultPlotConfig fast_threshold default from 300 to 1000.
Add fast_threshold option and refactor pedigree layout calculations
Introduce configurable lineage-based coloring for connecting segments. Adds new config options (segment_lineage_*) to getDefaultPlotConfig and docs/vignette entries, implements addSegmentLineageColumn to compute per-person lineage values, and integrates lineage-aware rendering in ggPedigree.core. New helpers .addSegmentLayer and .add_segment_lineage_scales handle conditional aesthetic mapping and color scales (with optional ggnewscale support for independent node/segment scales). Updates include man pages, unit tests for segment lineage behavior, NEWS entry, and DESCRIPTION (suggesting ggnewscale); interactive (plotly) plots fall back to fixed segment colors with a warning when two color scales cannot be preserved.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Introduce a new config option `fixed_positions` and internal helper `.applyFixedPositions()` to pin specific individuals to absolute layout-slot coordinates (x/y) that compose with generation scaling and radial layouts. Pinning updates connection anchors automatically; an option `fixed_positions_update_family` controls whether pinning a parent recomputes children family anchors. Adds documentation (man page and vignette section), NEWS entry, default config entries, and unit tests; updates test expectations and example vignette/html accordingly.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Enable backwards-compatible segment lineage coloring for interactive plots and add debug-friendly behavior and messages. Changes: - defaultPlotConfig: set segment_lineage_palette default to focal_fill_color_values. - ggPedigreeInteractive: wrap optimizePlotlyPedigree in tryCatch to warn and return unoptimized plotly object on error. - ggpedigreeCore: add debug messages when segment_lineage is requested but not supported (interactive/ggnewscale cases); adjust logic to allow debug-driven behavior and reorder node_mode so sex_color is evaluated last. - ggpedigreeCoreScales: fix manual scale value handling to ensure named color for single-entry palettes. - ggpedigreeCoreSegments: add legacy handling when segment_lineage_include = TRUE: build a palette (brewer/paletteer or provided vector), map colors to segment_lineage values, and pass explicit colors to geom_segment; add explanatory prints and input validation. - Other minor tweaks: overlay shape mapping adjustments, formatting fixes. - Add tests/tests.R with interactive/static examples and update vignette to demonstrate segment_lineage and focal_fill config options. Why: these changes restore a legacy pathway for coloring segments when interactive constraints prevent the preferred lineage color scale, provide clearer debug output to guide users, and make scale/color handling more robust.
Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Add fixed_positions config and applyFixedPositions
Export renumberPedigreeIDs and expose it via @export/NAMESPACE. Change internal ID coercion from integer to numeric for personID, momID, dadID, twinID and spouseID. Update documentation to include twinID and spouseID args. Add/extend tests to cover twin and spouse columns, custom column names, unknown references, ordering behavior, and update expected types from integer/NA_integer_ to numeric/NA_real_. These changes ensure consistent handling of twin/spouse relationships and numeric NA semantics.
Introduce founder_order_seed, founder_order_tries and layout_score_method to calculateCoordinates to allow shuffling pedigree row order (reproducible via seed) and to search multiple shufflings for the best layout. Implement new internal scoring functions (.layoutScore, .layoutScoreCrossings, .layoutScoreTwinPenalty) and integrate a .doOneLayout helper that runs the layout pipeline; when enabled the code evaluates candidate layouts and keeps the lowest-scoring result. Update default config (including return_best_seed and default reposition_founders = TRUE), man pages, NEWS, vignette and add comprehensive tests for the new behaviour and scoring methods. Also include minor code style and test whitespace cleanups.
Add configurable penalty/weight parameters to layout scoring: .layoutScoreTwinPenalty now accepts cross_gen_penalty (default 10) and .layoutScore accepts cross_gen_penalty, twin_penalty_weight (default 20) and duplication_weight (default 100). Replace hard-coded penalty multipliers in composite scoring and twin-penalty usage with these new parameters and update internal calls. Update roxygen documentation for the new parameters. Also remove a block of commented-out default_config lines from defaultPlotConfig.R.
Update plot config naming to match ggplot2 conventions: rename focal_fill_na_value to focal_fill_na_color across getDefaultPlotConfig (roxygen param, internal variables, and core_list key). NEWS.md updated to document the rename. Also make segment_lineage_na_color reference focal_fill_na_color so NA segment color follows the new setting. Note: an accidental stray "s" was introduced in one branch and should be removed to avoid a syntax error.
Add unit tests for ggpedigree core behavior: tests/testthat/test-ggpedigreeCoreLabels.R and tests/testthat/test-ggpedigreeCoreLayout.R. The new tests cover .addLabels (geom_text, geom_label, ggrepel integration and fallback, and invalid methods) and layout functions (.adjustSpacing and .applyRadialLayout) for cartesian and radial configurations, plus integration checks via ggPedigree. Also add 'cowplot' to DESCRIPTION Suggests.
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 pull request introduces several new features, optimizations, and bug fixes to the
ggpedigreepackage, with a focus on improving pedigree plotting flexibility, alignment, and lineage visualization. It also updates dependencies and documentation to reflect these enhancements.Major new features and improvements:
renumberPedigreeIDsfunction to consistently renumber pedigree IDs and update parent-child relationships, aiding in plotting and analysis. [1] [2]fixed_positions), coloring connecting segments by lineage (segment_lineage_*), and optimizing founder ordering and layout scoring (founder_order_seed,founder_order_tries,layout_score_method).Bug fixes:
reduce_variables = FALSEby carrying all extra pedigree columns forward and avoiding duplicate joins, preventing silent failures in segment coloring. [1] [2] [3]ggplot2.Dependency and documentation updates:
ggnewscaleandmockerytoDESCRIPTIONto support new plotting features and unit testing. [1] [2]1.2.0.90and documented all changes inNEWS.md. [1] [2]benchmark_alignment_results.csvto.Rbuildignorefor build hygiene.These changes collectively enhance the package's flexibility for complex pedigree visualization, ensure more robust and reproducible layouts, and improve overall code maintainability.