Skip to content
BilkentCompGenPublic

About

RepeatNet: an ab initio centromeric sequence detection algorithm

Resources

Stars

1 star

Watchers

17 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

RepeatNet

RepeatNet: an ab initio centromeric satellite sequence detection algorithm from unassembled paired-end or long-read whole-genome shotgun (WGS) reads (Alkan et al., Genome Research 2011), supporting Sanger, Illumina, PacBio HiFi, Oxford Nanopore (ONT), and PacBio CLR datasets with sparse 64-bit $k$-mers ($1 \le k \le 31$).

External Downstream Tools

  • PHRAP, SPAdes, or hifiasm / Flye — assembling extracted reads/read pairs into contigs
  • Tandem Repeats Finder (TRF) — extracting candidate satellite monomer / HOR consensus sequences from assembled contigs
  • Graphviz (neato / dot) (optional) — visualizing $k$-mer co-occurrence graphs and connected components

Compilation

make            # optimized build (-O3 -Wall -Wextra) -> ./repeatnet
make debug      # AddressSanitizer + UBSan build for debugging
make clean      # remove ./repeatnet and build/

Run ./repeatnet --help or ./repeatnet <command> --help for full option summaries.


Command Overview (samtools-style CLI)

Usage: repeatnet <command> [options]

Pipeline commands:
  loadseq      index sanger/illumina/hifi/ont/pacbio-clr reads into .kindex
  makegraph    filter/merge .kindex and build the co-occurrence graph (.matrix/.viz)
  components   partition a .matrix graph into connected components
  fetchseq     extract reads or read pairs supporting a connected component
  assemble     assemble component reads + run TRF via YAML config [future work]

Utility commands:
  trim         remove k-mers in a component/file (and revcomps) from a .kindex
  encode       encode a k-mer sequence (1..31 bp) into its 64-bit integer vertex ID
  decode       decode 64-bit integer vertex IDs from a file back to k-mer sequences
  help         display help for any subcommand

Sequencing Modes (--mode) & Input Formats

Both compression (gzip / bgzip magic bytes 0x1f 0x8b vs. plain text, via zlib) and sequence format (FASTA > vs. FASTQ @) are auto-detected independently for every input file. Specify the sequencing platform via -m / --mode:

1. Illumina Paired-End (--mode illumina)

Forward (-f) and reverse (-r) mates are in matching order across two files (plain text or .gz). RepeatNet skips hash pairing, streams read pairs one-by-one in $O(1)$ sequence memory, and omits .h<H> from output filenames:

repeatnet loadseq --mode illumina -k 15 -f reads_1.fq.gz -r reads_2.fq.gz -o sample

2. Long Reads: PacBio HiFi, ONT, PacBio CLR (--mode hifi|ont|pacbio-clr)

Unpaired single-molecule long reads (-i). RepeatNet streams reads one-by-one without hash pairing (omitting .h<H> from output filenames) and records a read under a $k$-mer when that $k$-mer occurs $\ge 2$ non-overlapping times ($\ge k$ bp apart) within the same read:

repeatnet loadseq --mode hifi -k 21 -i reads.hifi.fq -o sample_hifi
repeatnet loadseq --mode ont -k 15 -i reads.ont.fq -o sample_ont
repeatnet loadseq --mode pacbio-clr -k 15 -i reads.clr.fa -o sample_clr

3. Sanger Paired-End (--mode sanger)

Supports either an unordered/interleaved single file (-i, paired via clone-name hash() and writing <prefix>.h<H>.*) or two ordered mate files (-f and -r, streamed without hashing and writing <prefix>.*):

repeatnet loadseq --mode sanger -i sanger_reads.fa -o sanger_run

Typical End-to-End Workflow

Step 1: Index Tandem-Repeat $k$-mers (loadseq)

# Illumina paired-end short reads:
repeatnet loadseq --mode illumina -f reads_1.fq -r reads_2.fq -o sample

# Or PacBio HiFi long reads (e.g., k = 21):
repeatnet loadseq --mode hifi -k 21 -i reads.hifi.fq -o sample

# Or interleaved Sanger reads (writes sample.h11.{kindex,names,kmers}):
repeatnet loadseq --mode sanger -i test.fa -o sample

Generates <prefix>.kindex, <prefix>.names, and <prefix>.kmers (or <prefix>.h<H>.* when single-file sanger hash pairing is used).

Step 2: Simplify .kindex & Build Repeat Graph (makegraph)

repeatnet makegraph -x sample.kindex -m -c 100 -a 100
  • -m (--merge, enabled by default; pass -M / --no-merge to disable) merges each $k$-mer with its reverse complement because WGS reads originate from both strands.
  • -c 100 discards $k$-mer vertices occurring in fewer than 100 read pairs / long reads.
  • -a 100 keeps edges between pairs of $k$-mers that co-occur in at least 100 read pairs / long reads (alternatively, omit -a and pass -e <float> to threshold by normalized Sørensen–Dice edge weight).

(Optional) Visualize the graph with Graphviz:

neato -Tps -o graph.eps sample.kindex.cut100.a100.merged.viz

Step 3: Extract Connected Components (components)

repeatnet components -g sample.kindex.cut100.a100.merged.matrix

Writes component-1.{matrix,viz,txt}, component-2.{matrix,viz,txt}, ..., plus <matrix>.degrees. Pick candidate satellite clusters (e.g., largest component-N.txt files).

Step 4: Fetch Read Sequences for a Component (fetchseq)

# Illumina paired-end (split R1/R2 for SPAdes, or -o component-1.fa -F for PHRAP):
repeatnet fetchseq --mode illumina -C component-1.txt -f reads_1.fq -r reads_2.fq -x sample.kindex -1 comp1_1.fq -2 comp1_2.fq

# Long reads (HiFi / ONT / PacBio CLR):
repeatnet fetchseq --mode hifi -C component-1.txt -i reads.hifi.fq -x sample.kindex -o component-1.fq

# Interleaved Sanger input:
repeatnet fetchseq --mode sanger -C component-1.txt -i test.fa -x sample.h11.kindex -o component-1.fa

(Tip: pass -F / --fasta to convert FASTQ reads to FASTA, or --clones-only to output only the unique supporting read/clone names.)

Finally, assemble the extracted reads (phrap, SPAdes, hifiasm, or Flye) and run TRF on the resulting contigs to obtain candidate satellite monomer/HOR consensus sequences.

Step 5: Downstream Assembler & TRF Configuration (assemble, YAML Config)

Downstream assembler binaries/flags (phrap, spades, hifiasm, flye, or custom profiles) and TRF parameters are configured in config.yaml:

# Generate a default config.yaml template:
repeatnet assemble --init-config my_config.yaml

# Inspect resolved assembler & TRF settings:
repeatnet assemble -y config.yaml --show-config
repeatnet assemble -y config.yaml --mode illumina -1 comp1_1.fq -2 comp1_2.fq

(Note: repeatnet assemble currently loads/validates the YAML configuration and resolves the target assembler + TRF commands; automated subprocess execution is stubbed as future work.)


What Is the .kindex File?

In paired-end libraries (sanger, illumina), both mates of a centromeric insert lie inside the same tandem repeat array on opposite strands, so a $k$-mer $w$ on the forward read appears as $\overline{w}$ on the reverse read (a "double-sided $k$-mer"). In single-molecule long reads (hifi, ont, pacbio-clr), a centromeric read spans multiple tandem monomers on the same strand, producing $\ge 2$ non-overlapping occurrences of $w$ within the read.

The .kindex file is RepeatNet's sparse 64-bit inverted index of tandem-repeat $k$-mers:

  1. Header (ASCII): Line 1 stores the $k$-mer length <WS>\n (1 <= WS <= 31, default 12).
  2. Body (Binary records): For every active $k$-mer with $\ge 1$ supporting read/pair, .kindex stores [uint64_t code][uint32_t count][uint32_t read_id_1]...[uint32_t read_id_count] in ascending code and ascending read_id order, where each read_id indexes into <prefix>[.h<H>].names.

Saving .kindex decouples raw sequence parsing from graph exploration: you run loadseq once, and can then run makegraph, fetchseq, and trim repeatedly with different -c / -a / -e thresholds in seconds without re-indexing the WGS library.


Generated Files Reference

(Note: .h<H> appears in <prefix>[.h<H>].* only when single-file --mode sanger hash pairing is used; it is omitted for illumina, hifi, ont, pacbio-clr, and two-file sanger.)

File / Pattern Command Format Description
<prefix>[.h<H>].kindex loadseq Mixed ASCII + Binary Sparse 64-bit $k$-mer inverted index: ASCII <WS>\n header followed by binary [uint64_t code][uint32_t count][uint32_t id_1 ... id_count] records.
<prefix>[.h<H>].names loadseq ASCII TSV Read / clone ID lookup table: line 1 is total slot count nseq, followed by <id>\t<read_or_clone_name>.
<prefix>[.h<H>].kmers loadseq ASCII TSV Pre-merge $k$-mer summary: <uint64_t code>\t<count> for all active $k$-mers.
<kindex>.histogram makegraph ASCII TSV Pre-merge count distribution: <read_count>\t<num_kmers> sorted by ascending read_count to guide -c selection.
<kindex>.cut<C>.<aA|eE>[.merged].matrix makegraph Binary 64-bit co-occurrence repeat graph: [uint64_t num_edges][int WS] header followed by num_edges triples [uint64_t v1][uint64_t v2][uint32_t shared_reads] ($v_1 &lt; v_2$).
<kindex>.cut<C>.<aA|eE>[.merged].viz makegraph Graphviz DOT Undirected graph (graph G { v1 -- v2; }) for visualization with neato or dot.
<kindex>.cut<C>.<aA|eE>[.merged].edges makegraph --edgehist ASCII text Shared-read co-occurrence weight (eboth) per emitted graph edge (one integer per line).
<matrix>.degrees components ASCII TSV Sparse vertex degree table (<uint64_t vertex_id>\t<degree>) sorted by vertex ID for every non-isolated vertex.
component-<N>.matrix components Binary Subgraph 64-bit .matrix file containing only the edges belonging to connected component N (-p customizes the component prefix).
component-<N>.viz components Graphviz DOT Subgraph visualization (subgraph clusterN { ... }) for connected component N labeled with decoded $k$-mer strings.
component-<N>.txt components ASCII text Lexicographically sorted list of unique decoded $k$-mer DNA strings in connected component N (passed to fetchseq -C).
<hub_file>.neighbors components --getn ASCII text Sorted, deduplicated 64-bit integer vertex IDs of the queried hub vertex(es) in <hub_file> and their immediate graph neighbors.
<out.fa> / <out_1.fq>, <out_2.fq> fetchseq FASTA / FASTQ / Text Extracted reads or read pairs (single file via -o/stdout, split mates via -1/-2, forced FASTA via -F, or names via --clones-only) supporting a component.
<prefix>-<kmerfile>.kindex trim / makegraph --trim Mixed ASCII + Binary Trimmed .kindex with all $k$-mers in <kmerfile> and their reverse complements removed for iterative satellite peeling.
<prefix>-<kmerfile>.kmers trim / makegraph --trim ASCII TSV Updated <uint64_t code>\t<count> summary corresponding to the trimmed .kindex.
<ids_file>.decoded decode FASTA Decoded $k$-mer sequences (><vertex_id>\n<k-mer>) for 64-bit vertex IDs listed in <ids_file> (-k sets $k$, default 12).

Citation

Alkan C, Cardone MF, Catacchio CR, Antonacci F, O'Brien SJ, Ryder OA, Purgato S, Zoli M, Della Valle G, Eichler EE, Ventura M. (2011). Genome-wide characterization of centromeric satellites from multiple mammalian genomes. Genome Research, 21(1):137–145. doi:10.1101/gr.111278.110

About

RepeatNet: an ab initio centromeric sequence detection algorithm

Resources

Stars

1 star

Watchers

17 watching

Forks

Releases

Packages

Contributors

Languages