# collaborativebioinformatics/cnvision architecture

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

- Interactive diagram: https://gitdiagram.com/collaborativebioinformatics/cnvision
- Repository: https://github.com/collaborativebioinformatics/cnvision

## Overview

##### Project type and purpose
- CNVision is a multi‐module, data‐driven machine learning pipeline for copy number variant (CNV) calling and filtering.
- It combines:
- Data preprocessing (VCF/CRAM → BAM → ground truth VCF)
- Sequence‐based classification (DNABERT-2 fine-tuning)
- Image‐based classification (CNN/ViT on CIGAR-encoded RGB images)
- Filtering & evaluation against truth sets (Truvari, benchmarking metrics)
- It is organized as standalone modules, each handling one stage of the pipeline, and designed for batch/cloud execution (e.g., on DNANexus, AWS S3).

##### File structure
- Top-level modules (~parallel functional stages):
- Data_Module – raw data download, genome indexing, SV/CNV calling, visualization
- LLM_Module – sequence tokenization, embedding, DNABERT-2 fine-tuning
- Image_Encoding_Module – CIGAR → 4-channel tensors → 3-channel RGB images
- Image_Embedding_Module – DINOv3 metadata prep, LoRA fine-tuning for ViTs
- Filtering_and_Evaluation_Module – Truvari benchmarking, VCF merging/refinement
- DNANexus_Module – pipeline glue & cloud orchestration scripts
- Helpers/config: LICENSE, root README.md, per-module README.md, build scripts (conda, pip requirements).

##### README for additional insights
- The root README contains flowcharts for each module, technology stack (Python 3.8, Conda, samtools, bcftools, R), and external data sources (AWS S3, NCBI FTP).
- It explicitly describes two parallel ML branches (sequence vs. image) that converge in the filtering stage.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Data Sources
    subgraph "External Data Sources"
        AWS_S3["AWS S3"]:::external
        NCBI_FTP["NCBI FTP"]:::external
    end

    %% Data Layer
    subgraph "Data Layer"
        DM["Data Ingestion & Preprocessing\n(Data_Module)"]:::process
        DM --> DM_README["README.md"]:::script
        DM --> DM_GT["groundtruth/"]:::dataStore
        DM --> DM_PLOT["plot-svlen.R"]:::script
    end

    AWS_S3 --> DM
    NCBI_FTP --> DM

    %% Sequence Pipeline
    subgraph "Sequence Pipeline"
        SP["LLM_Module"]:::process
        SP --> SP_README["README.md"]:::script
        SP --> SP_ENC["encoding_embedding.py"]:::script
        SP --> SP_FT["finetune.py"]:::script
        SP --> SP_REQ["requirements.txt"]:::script
    end

    DM --> SP

    %% Image Pipeline
    subgraph "Image Pipeline"
        subgraph "Encoding"
            IE["Image_Encoding_Module"]:::process
            IE --> IE_README["README.md"]:::script
            IE --> IE_GEN["gen_RGB_images.py"]:::script
            IE --> IE_FIG["figures/"]:::dataStore
        end
        subgraph "Embedding"
            IM["Image_Embedding_Module"]:::process
            IM --> IM_README["README.md"]:::script
            IM --> IM_META["make_meta.py"]:::script
            IM --> IM_META_INF["make_meta_infer.py"]:::script
            IM --> IM_FTLORA["finetune_lora_vit.py"]:::script
        end
    end

    DM --> IE
    IE --> IM

    %% Evaluation Layer
    subgraph "Evaluation Layer"
        FE["Filtering & Evaluation\n(Filtering_and_Evaluation_Module)"]:::process
        FE --> FE_README["README.md"]:::script
    end

    SP --> FE
    IM --> FE

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        OR["DNANexus_Module"]:::process
        OR --> OR_README["README.md"]:::script
    end

    OR --> DM
    OR --> SP
    OR --> IE
    OR --> IM
    OR --> FE

    %% Click Events
    click DM "https://github.com/collaborativebioinformatics/cnvision/tree/main/Data_Module/"
    click DM_README "https://github.com/collaborativebioinformatics/cnvision/blob/main/Data_Module/README.md"
    click DM_GT "https://github.com/collaborativebioinformatics/cnvision/tree/main/Data_Module/groundtruth/"
    click DM_PLOT "https://github.com/collaborativebioinformatics/cnvision/blob/main/Data_Module/plot-svlen.R"

    click SP "https://github.com/collaborativebioinformatics/cnvision/tree/main/LLM_Module/"
    click SP_README "https://github.com/collaborativebioinformatics/cnvision/blob/main/LLM_Module/README.md"
    click SP_ENC "https://github.com/collaborativebioinformatics/cnvision/blob/main/LLM_Module/encoding_embedding.py"
    click SP_FT "https://github.com/collaborativebioinformatics/cnvision/blob/main/LLM_Module/finetune.py"
    click SP_REQ "https://github.com/collaborativebioinformatics/cnvision/blob/main/LLM_Module/requirements.txt"

    click IE "https://github.com/collaborativebioinformatics/cnvision/tree/main/Image_Encoding_Module/"
    click IE_README "https://github.com/collaborativebioinformatics/cnvision/blob/main/Image_Encoding_Module/README.md"
    click IE_GEN "https://github.com/collaborativebioinformatics/cnvision/blob/main/Image_Encoding_Module/scripts/gen_RGB_images.py"
    click IE_FIG "https://github.com/collaborativebioinformatics/cnvision/tree/main/Image_Encoding_Module/figures/"

    click IM "https://github.com/collaborativebioinformatics/cnvision/tree/main/Image_Embedding_Module/"
    click IM_README "https://github.com/collaborativebioinformatics/cnvision/blob/main/Image_Embedding_Module/README.md"
    click IM_META "https://github.com/collaborativebioinformatics/cnvision/blob/main/Image_Embedding_Module/make_meta.py"
    click IM_META_INF "https://github.com/collaborativebioinformatics/cnvision/blob/main/Image_Embedding_Module/make_meta_infer.py"
    click IM_FTLORA "https://github.com/collaborativebioinformatics/cnvision/blob/main/Image_Embedding_Module/finetune_lora_vit.py"

    click FE "https://github.com/collaborativebioinformatics/cnvision/tree/main/Filtering_and_Evaluation_Module/"
    click FE_README "https://github.com/collaborativebioinformatics/cnvision/blob/main/Filtering_and_Evaluation_Module/README.md"

    click OR "https://github.com/collaborativebioinformatics/cnvision/tree/main/DNANexus_Module/"
    click OR_README "https://github.com/collaborativebioinformatics/cnvision/blob/main/DNANexus_Module/README.md"

    %% Styles
    classDef external fill:#CCDDFF,stroke:#333,stroke-width:1px
    classDef process fill:#CCFFCC,stroke:#333,stroke-width:1px
    classDef script fill:#FFFFCC,stroke:#333,stroke-width:1px
    classDef dataStore fill:#FFCCFF,stroke:#333,stroke-width:1px
```
