# core-bioinformatics/magpie architecture

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

- Interactive diagram: https://gitdiagram.com/core-bioinformatics/magpie
- Repository: https://github.com/core-bioinformatics/magpie

## Overview

MAGPIE aligns spatial metabolomics (MSI) with Visium transcriptomics and tissue morphology. The documented workflow is to provide per-sample MSI/Visium data, optionally select landmarks in the Shiny app, then run the Snakemake pipeline for coregistration. The source excerpts show coordinate transformation and MSI-to-Visium aggregation/formatting responsibilities, but do not include Snakefile rules, so detailed dispatch and output-stage links are omitted. The graph also includes input validation and the two Space Ranger-format generation modules; their runtime wiring is not established by the excerpts.

Main entry points: [`Snakefile`](https://github.com/core-bioinformatics/magpie/blob/main/Snakefile) (Snakemake pipeline), [`magpie_shiny_app.py`](https://github.com/core-bioinformatics/magpie/blob/main/magpie_shiny_app.py) (Landmark app), [`scripts/alter_data.py`](https://github.com/core-bioinformatics/magpie/blob/main/scripts/alter_data.py) (Coordinate alignment), [`scripts/create_perbarcode_matrix.py`](https://github.com/core-bioinformatics/magpie/blob/main/scripts/create_perbarcode_matrix.py) (Spot aggregation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs and validation"]
  node_inputcheck["Input checks<br/>[check_inputs.py]"]
end

subgraph group_landmarks["Landmark selection"]
  node_shiny["Landmark app"]
  node_landmarksfiles["Landmark files"]
end

subgraph group_alignment["Alignment and mapping"]
  node_snakemake["Snakemake pipeline"]
  node_coordinatealign["Coordinate alignment<br/>[alter_data.py]"]
end

subgraph group_integration["Spatial integration"]
  node_mockformat["MSI format conversion"]
  node_spatialaggregate["Spot aggregation"]
  node_aggregatedformat["Aggregated format"]
end

node_researcher(("Researcher"))
node_sampledata["Sample data"]

node_researcher -->|"provides"| node_sampledata
node_researcher -->|"selects landmarks"| node_shiny
node_shiny -->|"downloads landmarks"| node_landmarksfiles
node_sampledata -.->|"validates files"| node_inputcheck
node_researcher -->|"runs pipeline"| node_snakemake
node_landmarksfiles -->|"supplies landmarks"| node_snakemake
node_snakemake -.->|"dispatches alignment"| node_coordinatealign
node_coordinatealign -.->|"provides coordinates"| node_spatialaggregate
node_spatialaggregate -.->|"creates format"| node_aggregatedformat

click node_inputcheck "https://github.com/core-bioinformatics/magpie/blob/main/scripts/check_inputs.py"
click node_shiny "https://github.com/core-bioinformatics/magpie/blob/main/magpie_shiny_app.py"
click node_snakemake "https://github.com/core-bioinformatics/magpie/blob/main/Snakefile"
click node_coordinatealign "https://github.com/core-bioinformatics/magpie/blob/main/scripts/alter_data.py"
click node_mockformat "https://github.com/core-bioinformatics/magpie/blob/main/scripts/create_mock_spaceranger.py"
click node_spatialaggregate "https://github.com/core-bioinformatics/magpie/blob/main/scripts/create_perbarcode_matrix.py"
click node_aggregatedformat "https://github.com/core-bioinformatics/magpie/blob/main/scripts/create_perbarcode_matrix.py"

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_inputcheck toneBlue
class node_shiny,node_landmarksfiles toneAmber
class node_snakemake,node_coordinatealign toneMint
class node_mockformat,node_spatialaggregate,node_aggregatedformat toneRose
class node_researcher,node_sampledata toneIndigo
```

## Components

### Inputs and validation

- [Input checks](https://github.com/core-bioinformatics/magpie/blob/main/scripts/check_inputs.py): `scripts/check_inputs.py`

### Landmark selection

- [Landmark app](https://github.com/core-bioinformatics/magpie/blob/main/magpie_shiny_app.py): `magpie_shiny_app.py`
- **Landmark files**

### Alignment and mapping

- [Snakemake pipeline](https://github.com/core-bioinformatics/magpie/blob/main/Snakefile): `Snakefile`
- [Coordinate alignment](https://github.com/core-bioinformatics/magpie/blob/main/scripts/alter_data.py): `scripts/alter_data.py`

### Spatial integration

- [MSI format conversion](https://github.com/core-bioinformatics/magpie/blob/main/scripts/create_mock_spaceranger.py): `scripts/create_mock_spaceranger.py`
- [Spot aggregation](https://github.com/core-bioinformatics/magpie/blob/main/scripts/create_perbarcode_matrix.py): `scripts/create_perbarcode_matrix.py`
- [Aggregated format](https://github.com/core-bioinformatics/magpie/blob/main/scripts/create_perbarcode_matrix.py): `scripts/create_perbarcode_matrix.py`

### Other components

- **Researcher**
- **Sample data**

## Connections

- Researcher → Sample data: provides (evidence: `README.md`)
- Researcher → Landmark app: selects landmarks (evidence: `README.md`)
- Landmark app → Landmark files: downloads landmarks (evidence: `README.md`)
- Sample data → Input checks: validates files
- Researcher → Snakemake pipeline: runs pipeline (evidence: `README.md`)
- Landmark files → Snakemake pipeline: supplies landmarks (evidence: `README.md`)
- Snakemake pipeline → Coordinate alignment: dispatches alignment
- Coordinate alignment → Spot aggregation: provides coordinates
- Spot aggregation → Aggregated format: creates format (evidence: `scripts/create_perbarcode_matrix.py`)
