read-tag-table
A lightweight Rust crate for storing, serializing, and exchanging single-cell read tag information.
read-tag-table provides a common representation for read-level cell barcode and UMI assignments and was extracted from the bam_tide ecosystem to serve as a reusable interchange format between tools.
The crate supports:
- Binary serialization for fast loading and storage
- TSV and TSV.GZ import
- TSV export
- Read-level lookup by read identifier
- Cell/UMI pair statistics
- Integration with single-cell sequencing workflows
Installation
From crates.io
or manually:
[]
= "0.1"
From GitHub
[]
= { = "https://github.com/stela2502/read-tag-table.git" }
Concepts
ReadTagRecord
A ReadTagRecord stores the barcode and UMI assignment for a single sequencing read.
Each record contains:
- read identifier
- optional original read identifier
- cell barcode sequence
- cell barcode quality values
- UMI sequence
- UMI quality values
Example:
use ReadTagRecord;
let record = new;
ReadTagTable
A ReadTagTable stores many ReadTagRecord objects and provides lookup and summary functionality.
use ;
let mut table = new;
table.insert;
Command Line Integration
The crate includes a ready-to-use Clap integration.
use Parser;
use ReadTagTableCli;
Load a table directly:
let table = cli.read_tag_table.load?;
For workflows using multiple read-tag tables:
let table = cli.read_tag_table.load_for_id?;
Supported inputs:
- Binary
.bintables - TSV files
- TSV.GZ files
The appropriate reader is selected automatically.
Binary Storage
The preferred storage format is the native binary format.
Save
table.save_binary?;
or:
table.save?;
Load
let table = load_binary?;
The binary format is considerably faster to load than TSV and is recommended for large datasets.
Loading TSV Files
Read-tag tables can be loaded from TSV files.
Required columns:
| Column |
|---|
| read_id |
| raw_cb |
| raw_umi |
Optional columns:
| Column |
|---|
| original_read_id |
| quality_cb |
| quality_umi |
Example:
read_id raw_cb raw_umi
read1 CELL1 UMI1
read2 CELL2 UMI2
Load using a configuration:
use ;
let config = ReadTagTableConfig ;
let table = from_config?;
Both plain TSV and TSV.GZ files are supported.
Lookup by Read ID
Retrieve the barcode and UMI associated with a read:
if let Some = table.cell_umi_for_read
Or access the full record:
if let Some = table.get
Merging Tables
Multiple tables can be combined:
table_a.merge;
Records from the second table overwrite records with identical read identifiers.
Exporting TSV
Write a table as TSV:
let mut file = create?;
table.write_tsv?;
The output format is compatible with the TSV reader.
Cell / UMI Statistics
The crate can summarize cell-barcode / UMI observations.
let stats = table.summarize_pairs;
Reported statistics include:
- number of valid cells
- number of unique cell/UMI combinations
- total observations
- UMIs per cell
- observations per cell/UMI pair
This functionality is useful for quality control and library complexity analysis.
Typical Workflow
FASTQ/BAM processing
↓
ReadTagRecord generation
↓
ReadTagTable
↓
save_binary()
↓
read_tags.bin
↓
load_binary()
↓
downstream analysis
Intended Use
read-tag-table is designed as a lightweight exchange format between tools that generate or consume single-cell barcode assignments.
Examples include:
- FASTQ normalizers
- Primer stripping workflows
- Primer restoration workflows
- Single-cell barcode translation
- Cell/UMI quality control
- VDJ and targeted sequencing pipelines
License
See the repository LICENSE file.