@anndata-omics-bridge/apb-catalog
v0.2.0
Published
apb-catalog's API in TypeScript: look up APB result fields by meaning in the browser
Readme
@anndata-omics-bridge/apb-catalog
apb-catalog's API in TypeScript: look up the fields of an APB result by meaning, such as a PEP or an unnormalized intensity, in the browser, without naming vendor columns.
Documentation: anndata-omics-bridge.github.io/apb-catalog-ts, with Get started and the API.
Catalog viewer: fgcz-ms.uzh.ch/public/apb-catalog, every set with its entries, requirements and coverage, in the browser, built on this package.
Contributing: the sets can be extended to suit your application, and you are welcome to create your own; see Contributing.
New API. This package is new, and its API may still change between releases. Feedback is very welcome: open an issue with what you need, what surprised you, or what broke.
APB
The AnnData Proteomics Bridge, apb2, converts the reports of proteomics quantification software into one result layout. Declarative parse rules describe each vendor table, so one parser reads them all.
- Software: AlphaDIA, DIA-NN, FragPipe, MaxQuant, PEAKS, Sage, Spectronaut and more
- Levels: peptidoform ion, peptidoform, peptide, protein, peptidoform fragment
- Per level: one AnnData, runs as
obs, features asvar, measurements as layers - Formats: h5ad, h5mu, Parquet, DuckDB
Columns keep the vendor's names: the posterior error probability is PEP in MaxQuant and DIA-NN, EG_PEP in Spectronaut.
apb-catalog
apb-catalog records what those columns mean, in reviewed sets. A consumer asks a set for a kind, such as pep or intensity, and gets the column.
| Set | Fields |
| --- | --- |
| abundance_alpha | Intensities, and whether the software normalizes them across runs |
| confidence_alpha | PEP and q-values per run and per feature |
| proteobench_entrapment_alpha | Precursor q-values for ProteoBench's entrapment scoring |
| apb_alpha | Fields apb2 convert writes for every vendor: ProForma identifiers, decoy and contaminant flags |
| obs_annotation_alpha | Each run's group and subject, from an SDRF or a prolfquapp table |
| fasta_peptides_alpha | apb-fasta's peptide verification, once apb-fasta verify-peptides has run |
| fasta_proteins_alpha | apb-fasta's protein annotation, once apb-fasta merge-annotations has run |
| chromatography_alpha | Retention times, peak bounds and widths, with their unit |
A lookup answers one of three ways:
- One field: the column, or its data
- Software does not report it:
null - Several fields: an
UnresolvedFielderror, never a silent choice
This package
This is apb-catalog's Python API in TypeScript, with the same classes and methods as Python's apb-catalog and R's apbCatalogR. It is built for web apps that plot from APB results in the browser. Snapshots are not ported, as in apbCatalogR.
| Call | Answers |
| --- | --- |
| Bundle.load(url) | The catalog bundle, from the URL of its manifest.json |
| new Catalog(bundle, software, software_version, set_name) | From the rules alone, without data: levels, each slot holding names |
| await read_parsed_levels(url) | One result, as R's read_parsed_levels(): levels with AnnData's slots by the vendor's own names, such as the whole var() |
| new DataCatalog(bundle, result, sets) | On that result, the named sets alone: levels with AnnData's slots looked up by key, returning the data |
| sets(bundle), rule_coverage(bundle, set_name), catalog_table(bundle) | The sets, how each rule covers a set, every entry as a table |
Two things differ from Python and R, because a browser fetches everything over HTTP:
- The bundle is not shipped with the package: the app serves it next to the data, and
Bundle.loadfetches it once read_parsed_levelsreads a result's provenance JSON, the Parquet result'smanifest.json, alone. Lookups read only that JSON; a data call fetches only the Parquet file it needs, by HTTP range request, once.
It does not convert vendor files. Convert with apb2, as Parquet:
apb2 convert DATA --params PARAMETER_FILE --format parquet --output result # writes result.parquetInstall
npm install @anndata-omics-bridge/apb-catalogUse
Ask the rules which column a software version reports:
import { Bundle, Catalog, DataCatalog } from '@anndata-omics-bridge/apb-catalog'
const bundle = await Bundle.load('catalog/apb-catalog-bundle/manifest.json')
const ion = new Catalog(bundle, 'DIA-NN', '2.2.0', 'abundance_alpha').levels.get('peptidoform_ion')
ion?.layers.keys()
// ['intensity', 'intensity_ms1', 'intensity_norm_settings', 'intensity_ms1_norm_settings']
ion?.layers.get('intensity')
// 'Precursor_Quantity'
ion?.layers.get('maxlfq')
// null: DIA-NN 2.2.0 reports no MaxLFQ for precursorsGet the data of a result:
const result = await read_parsed_levels('results/result.parquet/manifest.json')
const catalog = new DataCatalog(bundle, result, ['confidence_alpha'])
const level = catalog.levels.get('peptidoform_ion')
const pep = await level?.layers.get('pep')
// { runs: string[], features: string[], values: Float64Array[] }, one array per run; null when absent
level?.layers.name('pep')
// 'PEP', the field get reads; throws where get gives nullEach slot, layers, var and obs, answers as Python's does, with get in place of [...]:
- A name is a key first, then the level's own field of that name;
getgives null when it is neither - A prefix makes the lookup exact:
'c:q_value'asks the confidence set alone,'v:q_value'the level's own field alone;sets(bundle)lists each set'sprefix get(key, { unit: 'minute' })narrows a key by a qualifier it leaves openkeys()andhas(key)know keys onlyvar.select(keys)andobs.select(keys)read every column the keys name, asvar[[...]]doesvaralso reads varm tables; such a field is namedtable/column- A
varorobscolumn is one array: aFloat64Arrayfor numbers, otherwise strings or booleans X()is the primary layer, andobs_names()andvar_names()the run and feature names- A lookup throws
UnresolvedFieldat once when the catalog cannot decide; data arrives as a promise
The bundle
apb-catalog builds two bundles at each release:
- Bundle: the reviewed sets and the levels apb2 converts for each software version; lookups read only this
- Test bundle: synthetic results, with apb-catalog's answers on them; the tests check that TypeScript gives the same answers
How an app gets the latest bundle:
- Download
apb-catalog-bundle.tar.gzfrom the latest apb-catalog release and serve its folder with the data; a browser cannot download it from GitHub itself - A newer catalog needs only new files on the server, no new package version
- A bundle of a newer format than the package reads is refused with "update @anndata-omics-bridge/apb-catalog"
The file server must answer HTTP range requests.
Development
npm ci
make check # type check and every testThe tests read both bundles from APB_CATALOG_BUILD, by default ../apb-catalog/build (make bundle in apb-catalog).
