# mjlab-columbia/spade-ptm architecture

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

- Interactive diagram: https://gitdiagram.com/mjlab-columbia/spade-ptm
- Repository: https://github.com/mjlab-columbia/spade-ptm

## Overview

##### Project Type & Purpose
- This is a Python command-line tool built specifically to analyze SEC-MS data and evaluate protein assembly dynamics through the lens of post-translational modifications (PTMs).
- Its core functionality is implemented as a sequential pipeline with four main operations: data preprocessing, peak picking, peak matching/alignment, and post alignment editing/calculations.
- The project targets the analysis of TMT intensity tables from Spectromine, performing operations like smoothing, peak detection, alignment, and additional analytical computations (e.g., fold changes, molecular weight estimation).

##### File Structure Analysis
- The repository contains the following key Python scripts:
- dataPreprocessing.py: Handles initial data reshaping, normalization, averaging, and exports the results into an SQL database.
- peakPicking.py: Processes the SQL database output by smoothing the data (using SciPy’s digital filter), performing peak picking (via scipy.signal.find_peaks), and plotting peak multiplicity.
- PeakMatching.py: Aligns the peaks between samples—including matching PTM peptides to global peaks—based on a provided threshold.
- postMatchingEditing.py: Conducts post-alignment calculations such as computing mean elution fractions, fold change calculations, molecular weight estimations, and categorization of peak regions.
- Supporting files include configuration descriptors (environment.yaml, requirements.txt) and a LICENSE and README.

- Branch out from the SQL database to the “Peak Picking” module (annotate with “smoothing” and “find_peaks” operations).
- Resulting data to the “Peak Matching/Alignment” module, emphasizing configuration (e.g., threshold value).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Main Pipeline
    subgraph "SPADE-PTM Pipeline"
        inp["Input Data (TMT Intensity Tables)"]:::input
        preprocess["Data Preprocessing (Reshape, Normalize, SQL Export)"]:::processing
        db(("SQL Database")):::database
        peakPick["Peak Picking (Smoothing, find_peaks, Plotting)"]:::processing
        peakMatch["Peak Matching/Alignment (Threshold Matching)"]:::processing
        postEdit["Post Alignment Editing (Fold Change, MW Estimation)"]:::processing
        output["Output Results"]:::input

        inp -->|"ingest"| preprocess
        preprocess -->|"store"| db
        db -->|"fetch"| peakPick
        peakPick -->|"update"| db
        db -->|"retrieve"| peakMatch
        peakMatch -->|"match"| postEdit
        postEdit -->|"finalize"| output
    end

    %% Auxiliary Files
    subgraph "Auxiliary Files"
        config1["environment.yaml"]:::auxiliary
        config2["requirements.txt"]:::auxiliary
        docs1["README.md"]:::auxiliary
        docs2["LICENSE"]:::auxiliary
    end

    %% Click Events for Modules
    click preprocess "https://github.com/mjlab-columbia/spade-ptm/blob/main/dataPreprocessing.py"
    click peakPick "https://github.com/mjlab-columbia/spade-ptm/blob/main/peakPicking.py"
    click peakMatch "https://github.com/mjlab-columbia/spade-ptm/blob/main/PeakMatching.py"
    click postEdit "https://github.com/mjlab-columbia/spade-ptm/blob/main/postMatchingEditing.py"
    
    %% Click Events for Auxiliary Files
    click config1 "https://github.com/mjlab-columbia/spade-ptm/blob/main/environment.yaml"
    click config2 "https://github.com/mjlab-columbia/spade-ptm/blob/main/requirements.txt"
    click docs1 "https://github.com/mjlab-columbia/spade-ptm/blob/main/README.md"
    click docs2 "https://github.com/mjlab-columbia/spade-ptm/tree/main/LICENSE"
    
    %% Styles
    classDef input fill:#fde68a,stroke:#f59e0b,stroke-width:2px;
    classDef processing fill:#bfdbfe,stroke:#3b82f6,stroke-width:2px;
    classDef database fill:#d1fae5,stroke:#10b981,stroke-width:2px;
    classDef auxiliary fill:#fff1f2,stroke:#f43f5e,stroke-width:2px;
```
