Skip to content

About

Dependency-light Julia tools for protist amplicon workflows: parse PR2/SILVA lineage ladders, aggregate reads and evidence, ingest classification and placement formats, and export annotated Newick and iTOL datasets.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

141 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Protoctist.jl

Code licence: MPL-2.0 Docs licence: CC-BY-SA-4.0 Quantum-Safe Provenance

Rhodium Standard Repository OpenSSF Scorecard SonarQube Quality Gate Archived in Software Heritage

Types, file formats and exports for protist community analyses built on PR2 or SILVA: ranked lineages, evidence rolled up a taxonomy, jplace placements, and iTOL-ready trees.

What it does

A protist amplicon analysis produces a table of lineage strings with counts, often a set of phylogenetic placements, and eventually a figure. Protoctist covers that stretch in Julia:

  • reads the tables your classifier wrote (CSV, TSV, ECSV) and the placements your placer wrote (jplace);

  • parses lineages against the rank ladder they were assigned under — PR2 v5 (9 ranks) or SILVA (7 ranks) — and refuses to mix the two;

  • builds the taxonomy those lineages span and rolls counts and evidence status up it in one linear pass, without dropping a read;

  • writes annotated Newick and the iTOL dataset files for the result;

  • records the conditions a run was judged under and decides whether two runs may be pooled, giving every reason when they may not.

using Protoctist

run = load_protist_run("merged.csv")    # ProtistRun(3 rows, 14 taxa, ladder=:pr2)

clade_cumulus(run)[1:3]                  # cumulative reads per clade, largest first
# "root" => 57, "Eukaryota" => 57, "Excavata" => 40

export_iqtree_annotated(run, "out/")
# out/tree.newick  out/itol_counts.txt  out/itol_status.txt  out/itol_contamination.txt

Upload tree.newick to iTOL and drop the three dataset files onto it. The dataset files are keyed by taxon name, so they also apply to an IQ-TREE or EPA-ng tree whose labels use the same names.

Installation

using Pkg
Pkg.add(url = "https://github.com/hyperpolymath/Protoctist.jl")

Julia 1.9 or later. Protoctist has no package dependencies; adding it to an existing environment cannot change the version of anything already there.

Lineages and rank ladders

p = TaxPath("Eukaryota;TSAR;Alveolata;Ciliophora")    # PR2 ladder by default
at_rank(p, :subdivision)      # "Ciliophora"
at_rank(p, :genus)            # nothing — the lineage does not reach genus

s = TaxPath("Bacteria;Proteobacteria;"; ladder = :silva)
at_rank(s, :phylum)           # "Proteobacteria"
s == TaxPath("Bacteria;Proteobacteria"; ladder = :pr2)    # false: different ladders

A TaxPath carries its ladder, and paths on different ladders are never equal. An interior blank (a;;c) is an unfilled rank: the lineage continues, and the next label is placed at its own rank rather than shifted up. A trailing ; is not a rank at all, so SILVA- and QIIME 2-style strings parse as written.

Evidence status and residuals

load_protist_run rolls up counts. To carry evidence, give rollup_counts rows with a status and, where classification left candidates open, a residual:

tree = build_taxonomy_tree(["Eukaryota;TSAR;Rhizaria;Cercozoa",
                            "Eukaryota;TSAR;Alveolata"])
rows = [
    (path = TaxPath("Eukaryota;TSAR;Rhizaria;Cercozoa"), count = 10, status = FACTIVE),
    (path = TaxPath("Eukaryota;TSAR;Alveolata;Dinoflagellata"), count = 3,
     status = BELIEF, residual = LineageResidual(2, false, false)),
]
annot = rollup_counts(tree, rows)
annotate_newick(tree, annot)
# ... Alveolata[&&NHX:rank=division:count=3:cum=3:f=0:b=3:res=3:novel=0:contam=0] ...

FACTIVE marks an assignment the evidence entails; BELIEF one it supports without entailing. LineageResidual records how many named candidates remained, whether a novel taxon is admissible, and whether contamination is suspected.

The second row names Dinoflagellata, which the tree does not contain. It is counted at Alveolata, the deepest ancestor the tree does contain, and appears there as a non-zero own count on an interior node — coarser, but present and visible.

Placements

b = Protoctist.Formats.read_jplace("epa_result.jplace")
b.placements                           # every candidate edge for every query
Protoctist.Formats.best_placements(b)       # one per query, highest like_weight_ratio
Protoctist.Formats.write_jplace(b, "filtered.jplace")

Every candidate edge is kept, including those for multiplicity names (nm). Selection is by like_weight_ratio, never by the order the placer listed them in. A null field is read as NaN and written back as null.

Pooling runs

a = build_manifest((reference = "PR2", version = "5.0.0", ladder = :pr2),
                   (min_identity = 0.97,), hashes_a)
b = build_manifest((reference = "PR2", version = "4.14.0", ladder = :pr2),
                   (min_identity = 0.99,), hashes_b)
validate_merge(a, b)
# MergeVerdict(refused: policy.min_identity differs: 0.97 vs 0.99;
#              run.version differs: "5.0.0" vs "4.14.0")

Inputs are expected to differ between runs — that is what pooling is for — so only the judgement surface is compared: the policy, and the reference, ladder and version. Hashes are recorded as your pipeline computed them and are never recomputed.

Where it sits in a pipeline

Upstream / downstream Exchange Notes

DADA2 assignTaxonomy

TSV/CSV, one lineage column

Join the per-rank columns into one ; string first. DADA2’s NA is read as an unfilled rank. Pass sep = '\t' for TSV.

QIIME 2 taxonomy.tsv

TSV, Taxon column

Detected automatically. Rank prefixes (d, p) are kept as part of the label. Counts come from the feature table; without a count column each row counts once.

Astropy / ECSV

ECSV

The # header is preserved verbatim on write. Astropy’s default delimiter is a space: pass sep = ' '.

EPA-ng, pplacer, APPLES

jplace v3

Read and written; all candidates kept.

iTOL

Newick + dataset files

SIMPLEBAR (cumulative reads), MULTIBAR (factive / belief / residual), COLORSTRIP (contamination).

ETE, treeio / ggtree (read.nhx)

Newick with NHX comments

NHX-aware readers get rank, counts and status per node. The annotations sit in […​] comments, so a reader that skips comments sees plain Newick.

DataFrames.jl, any Tables.jl sink

NamedTuple of columns

DataFrame(Protoctist.Formats.columntable(Protoctist.Formats.read_ecsv(path))).

Protoctist does not reach back into any of these tools. It reads what they wrote. It does not re-sort, re-classify or re-hash anything. What it writes are standard formats that the next tool reads without a plugin.

Formal basis

The evidence vocabulary follows two formal developments, both checked in Agda with --safe --without-K:

  • epistemic-types separates a factive modality, which has a reflection principle, from a belief modality, which deliberately lacks one. FACTIVE and BELIEF follow that split. A warrant there has no Evidence → A constructor. In the same way, Protoctist carries `EvidenceReceipt`s it is given and never mints one.

  • residual-evidence-types quantifies identification over all admissible candidates. LineageResidual is the count-level summary of that judgement.

The Julia types follow these designs; they are not extracted from the proofs.

Protoctist 0.1 defines its own copies of the few shapes it needs from these, which is why it has no dependencies. Binding to them through package extensions is planned.

Guides

Cookbook (DADA2, QIIME 2, EPA-ng, pooling runs, all runnable under examples/) · Lineage formats · Troubleshooting · Glossary

Design and limits

EXPLAINME gives the reasoning behind each design decision, the cost of each choice, and the current limits. Those limits are: a jplace reader that keeps only the five standard fields, no branch lengths on the taxonomy tree, and row matching that is linear in rows × depth × siblings.

Testing

julia --project=. -e 'using Pkg; Pkg.test()'

100 behaviour tests across types, trees, file formats and manifests. They run after Aqua.test_all (11 checks), which covers method ambiguities, unbound type parameters, undefined exports, stale dependencies, compat bounds, type piracy and persistent tasks.

Licence

Code, configuration and scripts are Mozilla Public License 2.0 (MPL-2.0); prose documentation is CC-BY-SA-4.0. Both texts live in LICENSES/, and per-file SPDX-License-Identifier headers are authoritative. The GitHub-detected licence is MPL-2.0 (the root LICENSE). Long-term attribution uses Quantum-Safe Provenance — see the Quantum-Safe Provenance exhibit.

About

Dependency-light Julia tools for protist amplicon workflows: parse PR2/SILVA lineage ladders, aggregate reads and evidence, ingest classification and placement formats, and export annotated Newick and iTOL datasets.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages