# zahrasattari-hub/proteomics_pca_app architecture

> Architecture diagram of the GitHub repository zahrasattari-hub/proteomics_pca_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zahrasattari-hub/proteomics_pca_app
- Repository: https://github.com/zahrasattari-hub/proteomics_pca_app

## Overview

1. This repository is a small, single-app R/Shiny project centered on interactive PCA exploration of proteomics data.

2. The main application logic appears to live in `PCA-Tool.R`. With no separate `ui.R`/`server.R` files present, the architecture is likely a single-file Shiny app that combines data loading, UI definition, and server-side reactive logic in one script.

3. `mer_proteins.xlsx` is the bundled input dataset. The app reads this file locally and uses it as the source for PCA computation, sample grouping, and protein-level contribution analysis.

4. The core data flow is:
   - load proteomics measurements from the Excel file
   - preprocess the matrix into a PCA-ready form
   - compute principal components
   - expose the results through interactive controls and plots
   - let the user inspect which proteins drive separation between samples

5. The interactive boundary is between the app UI and the PCA analytics. Users can change principal component combinations, and the reactive layer updates clustering views and protein-contribution summaries accordingly.

6. The main analytical outputs are:
   - sample clustering/separation in PCA space
   - loading or contribution information for proteins on selected components
   - comparison of control versus treated groups, as described in the README

7. The project is not service-oriented; there is no evidence of a database, API backend, or external runtime dependency. It is a local analytical application intended to be run in R/RStudio via the Shiny framework.

8. The `.Rproj` file indicates the repo is organized as an RStudio project, which mainly affects development workflow rather than runtime architecture.

9. The README frames the application as an extension of a published static PCA figure. That means the app’s purpose is exploratory visualization rather than model training, persistence, or batch processing.

10. From an architecture-diagram perspective, the important boxes are:
   - Shiny app shell
   - local Excel data source
   - PCA computation/analysis layer
   - interactive visualization layer for samples and protein drivers

11. The main dependency boundary is therefore simple: local data in, reactive PCA computation in the middle, interactive plots/tables out. There are no additional subsystem tiers visible in the repository contents.

Main entry points: [`PCA-Tool.R`](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R) (PCA engine), [`mer_proteins.xlsx`](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/mer_proteins.xlsx) (mer_proteins.xlsx), [`proteomics_pca_app.Rproj`](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/proteomics_pca_app.Rproj) (RStudio project)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Shiny App"]
  node_pca_tool["PCA-Tool.R<br/>shiny app<br/>[PCA-Tool.R]"]
  node_shiny_shell["App shell<br/>ui+server<br/>[PCA-Tool.R]"]
  node_data_loader["Data load<br/>excel ingest<br/>[PCA-Tool.R]"]
  node_pca_prep["Prep matrix<br/>preprocessing<br/>[PCA-Tool.R]"]
  node_pca_model(("PCA engine<br/>analysis<br/>[PCA-Tool.R]"))
  node_protein_loadings["Protein drivers<br/>contribution analysis<br/>[PCA-Tool.R]"]
  node_component_controls["PC controls<br/>reactive inputs<br/>[PCA-Tool.R]"]
  node_sample_view(("Sample map<br/>scatter plot<br/>[PCA-Tool.R]"))
  node_comparison_view["Group compare<br/>summary view<br/>[PCA-Tool.R]"]
  node_contrib_view["Loading view<br/>detail view<br/>[PCA-Tool.R]"]
end

subgraph group_data["Local Data"]
  node_proteins_xlsx[("mer_proteins.xlsx<br/>input dataset<br/>[mer_proteins.xlsx]")]
  node_rproj["RStudio project<br/>dev workspace"]
end

node_rproj -->|"opens"| node_pca_tool
node_proteins_xlsx -->|"input"| node_data_loader
node_pca_tool -->|"defines"| node_shiny_shell
node_shiny_shell -->|"triggers"| node_data_loader
node_data_loader -->|"feeds"| node_pca_prep
node_pca_prep -->|"computes"| node_pca_model
node_pca_model -->|"renders"| node_sample_view
node_pca_model -->|"derives"| node_protein_loadings
node_component_controls -->|"selects"| node_sample_view
node_component_controls -->|"selects"| node_comparison_view
node_component_controls -->|"selects"| node_contrib_view
node_pca_model -->|"supports"| node_comparison_view
node_protein_loadings -->|"renders"| node_contrib_view
node_sample_view -.->|"cross-ref"| node_comparison_view
node_sample_view -.->|"cross-ref"| node_contrib_view

click node_pca_tool "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_shiny_shell "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_data_loader "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_pca_prep "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_pca_model "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_protein_loadings "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_component_controls "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_sample_view "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_comparison_view "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_contrib_view "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R"
click node_proteins_xlsx "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/mer_proteins.xlsx"
click node_rproj "https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/proteomics_pca_app.Rproj"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pca_tool,node_shiny_shell,node_data_loader,node_pca_prep,node_pca_model,node_protein_loadings,node_component_controls,node_sample_view,node_comparison_view,node_contrib_view toneBlue
class node_proteins_xlsx,node_rproj toneAmber
```

## Components

### Shiny App

Single-file interactive PCA application logic

- [PCA-Tool.R](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): shiny app · Single-script Shiny application combining UI, reactivity, and PCA analysis · `PCA-Tool.R`
- [App shell](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): ui+server · Top-level Shiny structure and reactive wiring · `PCA-Tool.R`
- [Data load](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): excel ingest · Reads the bundled proteomics spreadsheet into the app · `PCA-Tool.R`
- [Prep matrix](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): preprocessing · Cleans and reshapes measurements into PCA-ready form · `PCA-Tool.R`
- [PCA engine](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): analysis · Computes principal components and sample scores · `PCA-Tool.R`
- [Protein drivers](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): contribution analysis · Derives protein loading and contribution information for selected components · `PCA-Tool.R`
- [PC controls](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): reactive inputs · Lets users choose principal component combinations · `PCA-Tool.R`
- [Sample map](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): scatter plot · Interactive PCA space view for sample separation and clustering · `PCA-Tool.R`
- [Group compare](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): summary view · Contrasts control and treated groups across selected components · `PCA-Tool.R`
- [Loading view](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/PCA-Tool.R): detail view · Shows proteins contributing to separation on the chosen axes · `PCA-Tool.R`

### Local Data

Bundled input files used by the app

- [mer_proteins.xlsx](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/mer_proteins.xlsx): input dataset · Bundled proteomics measurements used as the PCA source data · `mer_proteins.xlsx`
- [RStudio project](https://github.com/zahrasattari-hub/proteomics_pca_app/blob/main/proteomics_pca_app.Rproj): dev workspace · Project file for opening and running the app in RStudio · `proteomics_pca_app.Rproj`

## Connections

- RStudio project → PCA-Tool.R: opens · RStudio project centers the single app script
- mer_proteins.xlsx → Data load: input · Excel data is read locally by the app
- PCA-Tool.R → App shell: defines · The script contains the Shiny application shell
- App shell → Data load: triggers · App startup initiates data ingestion
- Data load → Prep matrix: feeds · Loaded measurements are prepared for PCA
- Prep matrix → PCA engine: computes · Prepared matrix is used for PCA computation
- PCA engine → Sample map: renders · PC scores drive the sample separation plot
- PCA engine → Protein drivers: derives · Model outputs are used to calculate protein contributions
- PC controls → Sample map: selects · User component choices update the PCA map
- PC controls → Group compare: selects · User component choices update group comparison summaries
- PC controls → Loading view: selects · Chosen axes update protein loading displays
- PCA engine → Group compare: supports · PCA results support control-versus-treated comparison
- Protein drivers → Loading view: renders · Contribution analysis feeds the protein-driver view
- Sample map → Group compare: cross-ref · Sample separation and group comparison are linked views
- Sample map → Loading view: cross-ref · Users can inspect drivers behind visible separation
