# chrisjason0505/genomic-hpc-pipeline-using-jl-projections architecture

> Architecture diagram of the GitHub repository chrisjason0505/genomic-hpc-pipeline-using-jl-projections, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections
- Repository: https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections

## Overview

#### Purpose and execution

This repository is a notebook-driven HPC genomics experiment for reconstructing high-dimensional HapMap SNP dosage data after dimensionality reduction. The primary entry point is `JL_MLP_SNP_Pipeline.ipynb`; it expects an untracked input file at `data/data_geno_hmp.csv`. Native encoding must be built first through `scripts/setup.py`.

#### Input and native encoding boundary

Raw SNP genotype strings are loaded from the HapMap CSV and converted to additive numeric dosages. The performance-critical genotype encoder is implemented in C at `scripts/encode_utils.c` and compiled as a Python extension by `scripts/setup.py`. The notebook invokes the compiled code through Python/ctypes, separating data parsing/experiment orchestration from native per-genotype encoding.

#### Dimensionality-reduction stage

The encoded sample-by-SNP matrix (documented as 150 × 16,735) is reduced to a fixed 128-dimensional representation using Johnson-Lindenstrauss random projection. This replaces PCA as the main reduction mechanism and creates the model input boundary: high-dimensional SNP dosage data becomes a compact projected matrix. The projection, comparison baselines, and timing analysis are orchestrated in `JL_MLP_SNP_Pipeline.ipynb`.

#### GPU autoencoder stage

A PyTorch MLP autoencoder consumes 128-dimensional JL vectors and reconstructs the original SNP feature space. Its encoder produces learned latent embeddings; its decoder expands back to 16,735 SNP dimensions. Training uses CUDA where available and automatic mixed precision, with BatchNorm, GELU, dropout, AdamW, cosine learning-rate scheduling, and early stopping managed by `JL_MLP_SNP_Pipeline.ipynb`.

#### Validation and evaluation flow

The notebook performs 5-fold cross-validation to estimate reconstruction RMSE, then runs a final held-out evaluation. A JL-only reconstruction baseline is compared against JL plus the trained MLP to isolate the neural reconstruction contribution. Persisted aggregate outputs are `data/kfold_summary.csv` and `data/final_results.csv`; the raw source dataset is intentionally excluded.

#### Runtime and infrastructure

The runtime is Python/Jupyter with dependencies declared in `requirements.txt`, a local C compiler for the extension build, and PyTorch CUDA/AMP support. The intended execution hardware is an NVIDIA GPU, specifically documented against an RTX 3060 Laptop GPU with 6 GB VRAM. There are no service, API, database, or deployment boundaries; computation and result generation are local.

#### Artifact generation

`JL_MLP_SNP_Pipeline.ipynb` is also the reporting layer: it produces exploratory, projection-quality, CPU/GPU profiling, fold-training, reconstruction, latent-space, and tradeoff visualizations. The README describes generated images under `outputs/images/`, although that directory is not present in the supplied tree and is therefore a runtime-generated artifact location.

Main entry points: [`JL_MLP_SNP_Pipeline.ipynb`](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb) (Pipeline notebook), [`scripts/setup.py`](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/scripts/setup.py) (Extension build), [`scripts/encode_utils.c`](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/scripts/encode_utils.c) (Genotype encoder), [`requirements.txt`](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/requirements.txt) (Python dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_native["Native encoding"]
  node_extension_build["Extension build<br/>Python build script<br/>[setup.py]"]
  node_c_encoder["Genotype encoder<br/>C extension source<br/>[encode_utils.c]"]
  node_compiled_encoder{{"Compiled encoder<br/>native Python extension"}}
end

subgraph group_notebook["Notebook experiment"]
  node_notebook_entry["Pipeline notebook<br/>Jupyter entry point"]
  node_dosage_matrix["SNP dosage matrix<br/>encoded matrix"]
  node_jl_projection["JL projection<br/>dimensional reduction"]
  node_jl_vectors["128-D JL vectors<br/>model input matrix"]
  node_mlp_encoder["MLP encoder<br/>PyTorch model layer"]
  node_mlp_decoder["MLP decoder<br/>PyTorch model layer"]
  node_training["CUDA/AMP training<br/>training loop"]
  node_cross_validation["5-fold validation<br/>evaluation stage"]
  node_heldout_eval["Final held-out evaluation<br/>evaluation stage"]
end

subgraph group_artifacts["Generated artifacts"]
  node_kfold_summary["CV summary<br/>results CSV<br/>[kfold_summary.csv]"]
  node_final_results["Final results<br/>results CSV<br/>[final_results.csv]"]
  node_visualizations["Experiment visualizations<br/>runtime image artifacts"]
end

node_hapmap_csv["HapMap genotype CSV<br/>raw input"]
node_requirements["Python dependencies<br/>dependency manifest<br/>[requirements.txt]"]

node_c_encoder -->|"compiled by"| node_extension_build
node_extension_build -->|"produces"| node_compiled_encoder
node_requirements -.->|"defines runtime"| node_notebook_entry
node_hapmap_csv -->|"loaded by"| node_notebook_entry
node_compiled_encoder -->|"invoked via ctypes"| node_notebook_entry
node_notebook_entry -->|"encodes"| node_dosage_matrix
node_dosage_matrix -->|"reduces"| node_jl_projection
node_jl_projection -->|"outputs"| node_jl_vectors
node_jl_vectors -->|"feeds"| node_mlp_encoder
node_mlp_encoder -->|"latent embeddings"| node_mlp_decoder
node_mlp_decoder -->|"optimized by"| node_training
node_training -->|"evaluated across folds"| node_cross_validation
node_cross_validation -->|"writes"| node_kfold_summary
node_training -->|"final model"| node_heldout_eval
node_jl_vectors -.->|"JL-only baseline"| node_heldout_eval
node_heldout_eval -->|"writes"| node_final_results
node_notebook_entry -->|"generates"| node_visualizations

click node_extension_build "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/scripts/setup.py"
click node_c_encoder "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/scripts/encode_utils.c"
click node_notebook_entry "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb"
click node_jl_projection "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb"
click node_mlp_encoder "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb"
click node_mlp_decoder "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb"
click node_training "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb"
click node_cross_validation "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb"
click node_heldout_eval "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb"
click node_kfold_summary "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/data/kfold_summary.csv"
click node_final_results "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/data/final_results.csv"
click node_requirements "https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/requirements.txt"

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_extension_build,node_c_encoder,node_compiled_encoder toneBlue
class node_notebook_entry,node_dosage_matrix,node_jl_projection,node_jl_vectors,node_mlp_encoder,node_mlp_decoder,node_training,node_cross_validation,node_heldout_eval toneAmber
class node_kfold_summary,node_final_results,node_visualizations toneMint
class node_hapmap_csv,node_requirements toneNeutral
```

## Components

### Native encoding

- [Extension build](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/scripts/setup.py): Python build script · Compiles the native genotype encoder. · `scripts/setup.py`
- [Genotype encoder](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/scripts/encode_utils.c): C extension source · Converts genotype strings to additive dosages. · `scripts/encode_utils.c`
- **Compiled encoder**: native Python extension · Called from Python through ctypes.

### Notebook experiment

- [Pipeline notebook](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb): Jupyter entry point · Orchestrates preprocessing, training, evaluation, and reporting. · `JL_MLP_SNP_Pipeline.ipynb`
- **SNP dosage matrix**: encoded matrix · 150 samples by 16,735 SNP features.
- [JL projection](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb): dimensional reduction · Projects dosage vectors to 128 dimensions. · `JL_MLP_SNP_Pipeline.ipynb`
- **128-D JL vectors**: model input matrix
- [MLP encoder](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb): PyTorch model layer · Produces learned latent embeddings. · `JL_MLP_SNP_Pipeline.ipynb`
- [MLP decoder](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb): PyTorch model layer · Reconstructs 16,735 SNP dimensions. · `JL_MLP_SNP_Pipeline.ipynb`
- [CUDA/AMP training](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb): training loop · Uses AdamW, cosine scheduling, and early stopping. · `JL_MLP_SNP_Pipeline.ipynb`
- [5-fold validation](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb): evaluation stage · Estimates reconstruction RMSE. · `JL_MLP_SNP_Pipeline.ipynb`
- [Final held-out evaluation](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/JL_MLP_SNP_Pipeline.ipynb): evaluation stage · Compares JL-only and JL-plus-MLP reconstruction. · `JL_MLP_SNP_Pipeline.ipynb`

### Generated artifacts

- [CV summary](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/data/kfold_summary.csv): results CSV · Aggregate fold metrics. · `data/kfold_summary.csv`
- [Final results](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/data/final_results.csv): results CSV · Held-out reconstruction metrics. · `data/final_results.csv`
- **Experiment visualizations**: runtime image artifacts · Projection, profiling, reconstruction, latent-space, and tradeoff plots.

### Other components

- **HapMap genotype CSV**: raw input · Untracked SNP genotype strings.
- [Python dependencies](https://github.com/chrisjason0505/genomic-hpc-pipeline-using-jl-projections/blob/main/requirements.txt): dependency manifest · Provides Jupyter and PyTorch runtime dependencies. · `requirements.txt`

## Connections

- Genotype encoder → Extension build: compiled by
- Extension build → Compiled encoder: produces
- Python dependencies → Pipeline notebook: defines runtime
- HapMap genotype CSV → Pipeline notebook: loaded by
- Compiled encoder → Pipeline notebook: invoked via ctypes
- Pipeline notebook → SNP dosage matrix: encodes
- SNP dosage matrix → JL projection: reduces
- JL projection → 128-D JL vectors: outputs
- 128-D JL vectors → MLP encoder: feeds
- MLP encoder → MLP decoder: latent embeddings
- MLP decoder → CUDA/AMP training: optimized by
- CUDA/AMP training → 5-fold validation: evaluated across folds
- 5-fold validation → CV summary: writes
- CUDA/AMP training → Final held-out evaluation: final model
- 128-D JL vectors → Final held-out evaluation: JL-only baseline
- Final held-out evaluation → Final results: writes
- Pipeline notebook → Experiment visualizations: generates
