Skip to contents

foundr Developer Guide Overview & Architecture

Package Purpose & Ecosystem

foundr is an R package for analyzing and visualizing multiparent founder study data (specifically Collaborative Cross founder mouse crosses). It provides core statistical decomposition models, strain effect estimation, S3 trait object encapsulation, and customizable ggplot2 visualizations.

Related packages in the ecosystem:

  • foundr: Core data analysis algorithms, variance partitioning, statistical summaries, S3 trait classes, and plotting functions.
  • foundrShiny: Interactive Shiny web application providing modular UI components and reactive analysis panels.
  • foundrHarmony: Data harmonization across multi-tissue study datasets (in development).
  • modulr: Standardization and harmonization of WGCNA module objects.

High-Level Package Architecture & Data Flow

The foundr package structures founder data processing into an end-to-end analytical pipeline:

flowchart TD
    rawDF["Long-Format Data Frame (strain, sex, animal, trait, value)"]
    
    partition["partition() (Orthogonal Variance Partitioning)"]
    strainstats["strainstats() (Linear Models and F-Stats)"]
    bestcor["bestcor() (Spearman Trait Correlations)"]
    traitAncova["traitAncova() (ANCOVA Modeling)"]

    traitSolos["traitSolos S3 Object"]
    traitPairs["traitPairs S3 Object"]
    traitTimes["traitTimes S3 Object"]
    conditionContrasts["conditionContrasts S3 Object"]

    autoplot["autoplot() / plot() S3 Methods"]
    ggplotTemplate["ggplot_template() Design System"]
    biplot["biplot_signal() / biplot_pca() (ordr)"]
    volcano["volcano() Effect vs Significance"]

    rawDF --> partition
    rawDF --> strainstats
    rawDF --> bestcor

    partition --> traitSolos
    partition --> traitPairs
    partition --> traitTimes
    strainstats --> conditionContrasts

    traitSolos --> autoplot
    traitPairs --> autoplot
    traitTimes --> autoplot
    conditionContrasts --> autoplot

    autoplot --> ggplotTemplate
    traitSolos --> biplot
    strainstats --> volcano

    classDef input fill:#1f77b4,stroke:#333,stroke-width:2px,color:#fff
    classDef model fill:#ff7f0e,stroke:#333,stroke-width:2px,color:#fff
    classDef s3 fill:#2ca02c,stroke:#333,stroke-width:2px,color:#fff
    classDef plot fill:#d62728,stroke:#333,stroke-width:2px,color:#fff

    class rawDF input
    class partition,strainstats,bestcor,traitAncova model
    class traitSolos,traitPairs,traitTimes,conditionContrasts s3
    class autoplot,ggplotTemplate,biplot,volcano plot

Developer Quick Start

Local Development Workflow

# Load local package sources dynamically
devtools::load_all()

# Re-generate documentation & NAMESPACE
devtools::document()

# Run R package checks
devtools::check(vignettes = FALSE)

For detailed information on individual function groups, parameter handling, and statistical modeling algorithms, explore the sub-guides: