BlobToolKit Viewer Taxonomy Display#
Overview#
The BlobToolKit viewer colors assembly scaffolds/contigs by a single active category axis β typically a taxonomic rank field such as bestsumorder_phylum. This axis is stored in Redux state as plot.cat and drives both the scatter plot coloring and the summary table category column.
plot.cat: The Single Active Category Axis#
plot.cat is a string field ID stored in the Redux plot slice (e.g., "bestsumorder_phylum"). It is initialized from the dataset's metadata at import time and synced to/from the URL query string via catField.
Redux state: The plot reducer holds an axes object (x, y, z, cat). getCatAxis and getMainPlot are the canonical reselect selectors for reading it.
URL β store sync: In querySync.jsx, catField maps to the axes.cat slot . When catField appears in the query string, it is dispatched as an EDIT_PLOT action , which also triggers an EDIT_FIELD action to mark that field as active. The viewer reads window.plot.cat as a fallback default .
Default value set at parse time: In hits.py, after applying the taxrule, the parse() function sets meta.plot["cat"] to "{prefix}_phylum" (e.g., "bestsumorder_phylum") unless plot.cat is already set . This is the mechanism by which a phylum-level view is the out-of-the-box default.
BLAST/Diamond Hits β Rank-Specific Category Fields#
The Python-side pipeline (hits.py) converts raw BLAST/Diamond tabular output into per-rank Category fields:
- Parse hits β
parse_blast()reads tabular BLAST output, extractingsubject,score,start,end, andtaxidper hit. - Bin hits β
bin_hits()partitions hits along each sequence into windows (chunks). - Apply taxrule β
apply_taxrule()iterates over all taxonomic ranks returned bytaxdump.list_ranks(). For each bin,apply_taxrule_to_bin()looks up each hit's taxid against the taxonomy dump to resolve a rank-specific name (e.g., phylum name), accumulating scores per category. The category with the highest aggregated score in each bin wins. - Across-bin consensus β
apply_taxrule_across_bins()selects the most-frequent (then highest-scored) category across all bins for that sequence. - Sequences with no hits receive the label
"no-hit". - Unresolvable ranks produce
"undef"or"{parent}-undef"labels .
Field naming convention: One Category field is created per rank per taxrule prefix, following the pattern {prefix}_{rank} (e.g., bestsumorder_phylum, bestsumorder_genus). . Companion sub-fields {prefix}_{rank}_score and {prefix}_{rank}_cindex are also created .
Viewer: Binding plot.cat to Visualization#
Selectors#
| Selector | Location | Role |
|---|---|---|
getCatAxis | Returns state.plot.axes.cat | |
getRawDataForCat | Fetches raw category values for the active cat field | |
getBinsForCat | Computes display bins (sorted, grouped, "other" bucket) for the active cat field | |
getSummary | Aggregates span/count/N50 per category bin, keyed by catAxis | |
getLineage | Extracts the target rank from plot.axes.cat by stripping the prefix (e.g., "phylum" from "bestsumorder_phylum") and matches against dataset taxon metadata |
Table#
TablePlot.jsx passes plot.cat.meta.id as plotCategory to generateColumns() . The column for the active category axis renders color-coded CategoryLabel cells , while other category columns render plain text labels.
Color assignment#
getBinnedColors maps each category index (from bins) to a palette color, so every downstream consumer (scatter plot, table, legend) uses a consistent color for the same taxon name.
Key Files#
| File | Purpose |
|---|---|
src/blobtools/lib/hits.py | BLAST/Diamond β rank Category field conversion |
src/viewer/src/client/views/reducers/plot.js | Redux plot slice; getCatAxis, getMainPlot |
src/viewer/src/client/views/querySync.jsx | URL β Redux sync for catField β plot.cat |
src/viewer/src/client/views/reducers/plotData.js | getRawDataForCat, getBinsForCat |
src/viewer/src/client/views/reducers/field.js | Category field binning logic |
src/viewer/src/client/views/reducers/summary.js | getSummary, getLineage, getBinnedColors |
src/viewer/src/client/views/components/TablePlot.jsx | Table view; highlights active category column |