# gabrielhoffman/variancepartition architecture

> Architecture diagram of the GitHub repository gabrielhoffman/variancepartition, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gabrielhoffman/variancepartition
- Repository: https://github.com/gabrielhoffman/variancepartition

## Overview

##### Main Components

a) Core Analysis Modules:
- Variance Partition Analysis Module
- Dream Differential Expression Module
- Statistical Testing Module
- Visualization Module

b) Data Processing Layer:
- Input Data Handlers
- Quality Weight Processing
- Model Fitting Components

c) Statistical Components:
- Linear Mixed Models Engine
- Empirical Bayes Processing
- Variance Component Estimation

**[Data Input Layer]**
- ↓
**[Core Processing Layer]**
- ↓
**[Statistical Analysis Layer]**
- ↓
**[Visualization Layer]**

##### Component Relationships

- Bidirectional interactions where applicable

##### Specific Implementation Details

- Blue: Core statistical functions (dream, varPartition)
- Green: Data processing functions
- Orange: Visualization components
- Purple: Model fitting and testing components

##### Key Features to Highlight

a) Statistical Processing Pipeline:
**[Input Data] → [Quality Weights] → [Mixed Model Fitting] → [Variance Partitioning]**
- ↘ [Dream Analysis]

b) Visualization Pipeline:
**[Analysis Results] → [Plot Generation] → [Various Plot Types]**

##### Important Elements

- Integration with external R dependencies
- Empirical Bayes framework
- Contrast handling system
- Connection between variance partition and dream analysis

##### Technical Details

- dream()
- calcVarPart()
- fitExtractVarPartModel()
- voomWithDreamWeights()

##### Implementation Notes

- Use UML-style notation for class relationships
- Notes about key statistical methods
- Data transformation flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        DI[Data Input]
    end

    subgraph Processing["Data Processing Layer"]
        DH["Input Data Handlers"]:::processing
        QW["Quality Weight Processing"]:::processing
        DA["Data Annotation"]:::processing
        PC["Prior Count Augmentation"]:::processing
    end

    subgraph Core["Core Analysis Layer"]
        subgraph VP["Variance Partition Analysis"]
            VPC["Calc Var Part"]:::core
            VPE["Extract Var Part"]:::core
            VPF["Fit Var Part Model"]:::core
        end

        subgraph DE["Dream Differential Expression"]
            DRM["Dream Analysis"]:::core
            VDW["Voom Dream Weights"]:::core
            FMD["Mixed Model DE"]:::core
        end
    end

    subgraph Stats["Statistical Analysis Layer"]
        subgraph MM["Model Components"]
            FMM["Mixed Model Fitting"]:::stats
            VCE["Variance Component Estimation"]:::stats
            EBP["Empirical Bayes Processing"]:::stats
        end

        subgraph Testing["Statistical Testing"]
            MVT["Multivariate Testing"]:::stats
            TRT["Treatment Analysis"]:::stats
            CNT["Contrasts"]:::stats
            CI["Confidence Intervals"]:::stats
        end
    end

    subgraph Viz["Visualization Layer"]
        PVP["Plot Var Part"]:::viz
        PCM["Plot Corr Matrix"]:::viz
        PCS["Plot Corr Structure"]:::viz
        PSB["Plot Stratify By"]:::viz
        PCN["Plot Contrasts"]:::viz
        HMP["Heatmap"]:::viz
    end

    %% Connections
    DI --> DH
    DH --> QW
    DH --> DA
    DH --> PC

    QW --> VDW
    DA --> VPC
    PC --> VDW

    VPC --> VPE
    VPE --> VPF
    VDW --> DRM
    DRM --> FMD

    VPF --> FMM
    FMD --> FMM
    FMM --> VCE
    VCE --> EBP

    EBP --> MVT
    EBP --> TRT
    MVT --> CNT
    TRT --> CI

    VPF --> PVP
    FMM --> PCM
    VCE --> PCS
    CNT --> PCN
    CI --> PSB
    EBP --> HMP

    %% Styles
    classDef core fill:#3498db
    classDef processing fill:#2ecc71
    classDef stats fill:#9b59b6
    classDef viz fill:#e67e22

    %% Click Events
    click VPC "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/calcVarPart.R"
    click VPE "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/extractVarPart.R"
    click VPF "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/fitVarPartModel.R"
    click DRM "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/dream.R"
    click VDW "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/voomWithDreamWeights.R"
    click FMD "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/fitMixedModelDE.R"
    click MVT "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/mvTest.R"
    click TRT "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/treat.R"
    click CNT "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/contrasts.R"
    click CI "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/confidenceIntervals.R"
    click PVP "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/plotVarPart.R"
    click PCM "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/plotCorrMatrix.R"
    click PCS "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/plotCorrStructure.R"
    click PSB "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/plotStratifyBy.R"
    click PCN "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/plotContrasts.R"
    click HMP "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/heatmap.R"
    click QW "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/applyQualityWeights.R"
    click PC "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/augmentPriorCount.R"
    click DA "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/data_annotation.R"
    click FMM "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/fitMixedModel.R"
    click EBP "https://github.com/GabrielHoffman/variancePartition/blob/devel/R/ESS.R"
```
