# biodataanalysisgroup/umic architecture

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

- Interactive diagram: https://gitdiagram.com/biodataanalysisgroup/umic
- Repository: https://github.com/biodataanalysisgroup/umic

## Overview

##### Project Type and Purpose
- UMIc is a bioinformatics framework written in R that processes sequencing data (fastq files) to perform UMI deduplication and error correction.
- The primary purpose is to clean and correct sequencing reads based on a nucleotide-level evaluation using quality and frequency data.
- It is not a full web-based application but essentially a command-line driven pipeline with clearly separated input (data) and output (results) components.

##### File Structure Analysis
- There are three main folders:
- The “R” directory, containing the core scripts:
- UMIsProject.R (the main script that initializes parameters and starts the pipeline),
- casesWorkflows.R (probably handling per-case logic or workflows),
- functions.R (common routines used across the framework).
- The “data” directory, which holds input datasets, organized by case (case1, case2, case3), each with one or multiple fastq.gz files.
- The “outputs” directory, where processed and corrected sequencing files are written along with summary CSV files.
- Additional files (LICENSE, README.md, UMIc.yml) provide documentation, license information, and potential configuration settings.

##### Extracting Insights from the README
- The README explains the input parameters needed in UMIsProject.R such as pairedData, UMIlocation, UMIlength, etc.
- It also describes the output format, which includes both corrected fastq files and summary CSV tables.
- Dependency management (i.e., package installation from CRAN and Bioconductor) plays a key role in the overall project architecture.

a. Main Components:
- Input Module: Represents the “data” folder which contains the raw fastq files.
- Configuration & Initialization: The main script (UMIsProject.R) that assimilates user-defined parameters.
- Core Processing Unit: Composed of:
- Workflow Control (casesWorkflows.R) handling per-case workflows.
- Supporting Functions (functions.R) that implement deduplication and error correction logic.
- External Dependencies: List of required R packages (tidyverse, data.table, stringdist, pryr, Biostrings, ShortRead). These are essential libraries controlled by CRAN/Bioconductor.
- Output Module: Corresponds to the “outputs” folder where results (corrected fastq files and summary CSVs) are written.
- (Optionally) Configuration File (UMIc.yml) if it's used for additional setup or parameters.

b. Relationships and Data Flow:
- Loading the input data from the “data” folder.
- Passing control to the workflow script (casesWorkflows.R).
- Utilizing utility functions (from functions.R) to perform UMI-based correction.
- From “data” (raw input) → Processing Unit (R scripts) → “outputs” (corrected data).
- Internal calls among the R scripts to perform the deduplication and merging logic.
- Reagent-like dependencies where external packages are loaded and utilized within the processing modules.

c. Architectural Patterns and Design Principles:
- Modular Structure: Separation of concerns is clear between input handling, workflow control, and processing functions.
- Pipeline Architecture: The design is linear with clear stages from raw data ingestion to output generation.
- Reusability: The use of supporting functions (functions.R) emphasizes code reuse and encapsulation of core deduplication logic.
- Configuration Driven: Key parameters are defined by the user in the main script, making the tool flexible for different datasets.

d. Technologies and Libraries:
- Programming Language and Runtime: R, along with its ecosystem of packages.
- Libraries: tidyverse (data manipulation), data.table (fast data operations), stringdist (for similarity metrics), pryr (for introspection), Biostrings and ShortRead (for sequence processing).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Data Input (data)"]:::data
    C["Configuration File (UMIc.yml)"]:::config
    B["User Configuration (UMIsProject.R)"]:::script
    D["Workflow Controller (casesWorkflows.R)"]:::script
    E["Utility Functions (functions.R)"]:::script
    F["External Libraries (tidyverse, data.table, stringdist, pryr, Biostrings, ShortRead)"]:::external
    G["Output Manager (outputs)"]:::data

    A -->|"reads_input"| B
    C -->|"configures"| B
    B -->|"initiates_workflow"| D
    B -->|"loads_libraries"| F
    D -->|"calls_utilities"| E
    D -->|"executes_pipeline"| F
    D -->|"writes_output"| G
    E -->|"processes_data"| G

    click A "https://github.com/biodataanalysisgroup/umic/tree/master/data"
    click B "https://github.com/biodataanalysisgroup/umic/blob/master/R/UMIsProject.R"
    click C "https://github.com/biodataanalysisgroup/umic/blob/master/UMIc.yml"
    click D "https://github.com/biodataanalysisgroup/umic/blob/master/R/casesWorkflows.R"
    click E "https://github.com/biodataanalysisgroup/umic/blob/master/R/functions.R"
    click G "https://github.com/biodataanalysisgroup/umic/tree/master/outputs"

    classDef script fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef data fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef config fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
