| Title: | Look Up APB Result Fields by Meaning |
|---|---|
| Description: | Looks up the fields of AnnData Proteomics Bridge (APB) results by meaning, such as a PEP or an unnormalized intensity, without naming vendor columns. Reimplements the apb-catalog API on the bundle apb-catalog releases: reviewed sets, apb2's rule levels and expected answers. Reads APB results, as h5ad, Parquet or DuckDB, into anndataR objects. |
| Authors: | Witold E. Wolski [aut] (ORCID: <https://orcid.org/0000-0002-6468-120X>), Witek Wolski [cre] (ORCID: <https://orcid.org/0000-0002-6468-120X>), Functional Genomics Center Zurich [fnd] |
| Maintainer: | Witek Wolski <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.4 |
| Built: | 2026-11-12 21:59:04 UTC |
| Source: | https://github.com/bioc/apbCatalogR |
Read a var or obs slot by several keys
## S3 method for class 'Columns' x[i, ...]## S3 method for class 'Columns' x[i, ...]
x |
A var or obs slot of a level. |
i |
Keys, or the level's own names. |
... |
Ignored. |
A data frame of every column the names name; the names without data.
Read a slot by key
## S3 method for class 'Slot' x[[i, ...]]## S3 method for class 'Slot' x[[i, ...]]
x |
A Slot. |
i |
A key, or the level's own name. |
... |
Ignored. |
A matrix for layers, a vector for var and obs; a name without data.
Answers from the catalog alone, without data. The rule levels whose version
pattern admits the version give the levels; the set's entries for that
pattern give each level's fields. levels have the slots of a
DataCatalog's levels, holding names: a slot answers one of the set's keys,
such as "intensity_norm_settings", with the field's name, and its $get()
takes further qualifiers, such as unit. Lookups that several fields answer,
or that an unreviewed level cannot, signal UnresolvedField. enforce
checks the set's requirements against the rule's levels once, when the
catalog opens.
The class generator; Catalog$new() returns a Catalog.
levelsOne LevelNames per rule level, with a DataCatalog's slots holding names.
descriptionWhat this set holds and who uses it.
Catalog$new()Bind a set to the rule levels of one software version.
Catalog$new(software, software_version, set_name, enforce = NULL)
softwareThe quantification software, such as "DIA-NN".
software_versionThe software's version, such as "2.2.0".
set_nameThe set, such as "abundance_alpha" or
"confidence_alpha"; see sets().
enforceNULL, "required" or "recommended": signal one
MissingRequiredField listing every field the set requires at
that strength and the rule lacks; under "required", missing
recommended fields give one warning. An error when the set has no
requirements.
Catalog$fields()Every cataloged field the rule declares, one row per
field, as catalog_table() shows them.
Catalog$fields()
A data frame, with present true for each row.
Catalog$print()Print the set and the levels.
Catalog$print(...)
...Ignored.
Catalog$clone()The objects of this class are cloneable with this method.
Catalog$clone(deep = FALSE)
deepWhether to make a deep clone.
catalog <- Catalog$new("DIA-NN", "2.2.0", "abundance_alpha") catalog$levels$peptidoform_ion$layers[["intensity"]] catalog$levels$peptidoform_ion$layers$keys()catalog <- Catalog$new("DIA-NN", "2.2.0", "abundance_alpha") catalog$levels$peptidoform_ion$layers[["intensity"]] catalog$levels$peptidoform_ion$layers$keys()
The whole catalog, every set of the bundle, or one set: one row per entry
and software version it applies to, as apb-catalog table prints it.
catalog_table(set_name = NULL)catalog_table(set_name = NULL)
set_name |
One set's name; |
A data frame with columns set, source (who writes the field: the
quantification software, an app or annotation:<convention>), version
(the version label; * for an app's or an annotation's entry, which
applies to every version), software_version_pattern (NA for an entry
of every software version), level, slot (layers, var, obs or
varm), table (the varm table, else NA), name (the field's name;
prefix:<prefix> for a field found by column-name prefix), key, kind,
one qualifier.<name> column per other qualifier, requirement and
entry_id.
head(catalog_table("confidence_alpha"))head(catalog_table("confidence_alpha"))
Reports the bundle lookups answer from: its version, whether it was shipped
with the package or installed by update_catalog(), and the apb2 version
its rule levels come from.
catalog_version()catalog_version()
A list with version, origin ("shipped" or "cache"), path
and apb2_version.
catalog_version()catalog_version()
obs[c("group")] holds every column the key names, each under its own name,
where obs[["group"]] signals UnresolvedField because there are several.
The class generator, not exported: a Level's var and obs are
its objects.
Slot -> Columns
Columns$new()Bind one var or obs slot of a level.
Columns$new(level, location, lookup, read, named, combine)
levelThe level's name.
location"var" or "obs".
lookupHow the catalog answers keys: find, find_all,
offered, known and sets, one lookup per set prefix.
readThe value of a field the slot holds.
namedThe level's own names in this slot.
combineThe fields read, a named list, as one value.
Columns$get_all()Every field the names name, in order; an error for a name that is neither a key nor the level's own.
Columns$get_all(names)
namesKeys, or the level's own names.
A data frame; names without data.
Columns$clone()The objects of this class are cloneable with this method.
Columns$clone(deep = FALSE)
deepWhether to make a deep clone.
Answers on a result read with read_parsed_levels() and hands the data back
directly: levels give each level's slots, looked up by one of the set's
keys, such as "q_value" or Sage's "quantification_q_value". Ambiguous or
unreviewed answers signal UnresolvedField.
Composes the named sets alone: apb_alpha, the fields apb2 convert writes,
answers only when named. A key routes to the sets that define it; two sets
naming different fields for one key on one level is an error. With no set
named, every name is the level's own. A named set that can answer nothing on
the result, because its app has not run or the result records no sample
annotation, is an error saying what to run. enforce checks the
requirements once, here.
DataCatalog$answering_sets(result) returns the sets
DataCatalog$new(result, name) opens, as a character vector: every set but
one whose app has not run on the result or whose annotation it does not
record. It signals no error for such a set, so a consumer can leave it out.
The class generator; DataCatalog$new() returns a DataCatalog.
levelsOne Level per level of the result, with anndataR's slots looked up by key.
descriptionWhat the first set named holds and who uses it; an error when no set was named.
DataCatalog$new()Bind the named sets, and no others, to the levels of one result.
DataCatalog$new(result, ..., enforce = NULL)
resultA ParsedLevels object.
...The sets, such as "abundance_alpha" and
"confidence_alpha"; see sets().
enforceNULL, "required" or "recommended": signal one
MissingRequiredField listing every field the named sets require
at that strength and the result lacks; under "required", missing
recommended fields give one warning. An error when no named set
has requirements.
DataCatalog$fields()Every cataloged field of the result in every composed
set, one row per field, as catalog_table() shows them.
DataCatalog$fields()
A data frame with present and, for a field apb2 left out
because it held one value, that constant.
DataCatalog$print()Print the set and the levels.
DataCatalog$print(...)
...Ignored.
DataCatalog$clone()The objects of this class are cloneable with this method.
DataCatalog$clone(deep = FALSE)
deepWhether to make a deep clone.
results <- tempfile() archive <- system.file( "extdata", "test-bundle", "results.tar.gz", package = "apbCatalogR" ) utils::untar(archive, exdir = results) result <- read_parsed_levels( file.path(results, "maxquant_wide-peptidoform_ion.parquet") ) catalog <- DataCatalog$new(result, "confidence_alpha") dim(catalog$levels$peptidoform_ion$layers[["pep"]]) catalog$levels$peptidoform_ion$layers$name("pep")results <- tempfile() archive <- system.file( "extdata", "test-bundle", "results.tar.gz", package = "apbCatalogR" ) utils::untar(archive, exdir = results) result <- read_parsed_levels( file.path(results, "maxquant_wide-peptidoform_ion.parquet") ) catalog <- DataCatalog$new(result, "confidence_alpha") dim(catalog$levels$peptidoform_ion$layers[["pep"]]) catalog$levels$peptidoform_ion$layers$name("pep")
anndataR's slots of one level: X, layers, var, obs, obs_names and
var_names. X is the level's primary layer and layers its other layers,
observations by variables; a key may name the primary layer, and then answers
X. cat$levels$protein$layers[["intensity"]] looks the name up as one of
the catalog's keys first, then as the level's own name in that slot, and
signals an error when it is neither; a prefix makes the lookup exact,
"c:q_value" the confidence set alone, "v:q_value" the level's own name
alone.
obs[c("group", "Run")] reads every column the names name as a data frame.
The class generator, not exported: a DataCatalog's levels hold
its objects, which the catalog creates.
nameThe level's name.
layersThe level's layers, read with [[ or $get(); $name() names
the field, $keys() lists the keys it offers.
varThe level's per-feature columns, from var or a varm table,
read with [[, [ or $get().
obsThe level's per-sample columns, read with [[ or [.
XThe primary layer, observations by variables.
obs_namesOne name per observation: its key columns, joined by
|.
var_namesOne name per variable: its key columns, joined by
|.
Level$new()Bind one level to the catalog's lookups.
Level$new(name, level, lookup)
nameThe level's name.
levelThe level, an anndataR AnnData.
lookupHow the catalog answers keys: find, find_all,
offered, known and sets, one lookup per set prefix.
Level$clone()The objects of this class are cloneable with this method.
Level$clone(deep = FALSE)
deepWhether to make a deep clone.
The slots of a Level without data: layers, var and obs answer a key
with the field's name, a varm column as table/column. There is no X,
obs_names, var_names or own name: a name that is no key the level answers
signals an error.
The class generator, not exported: a Catalog's levels hold its
objects, which the catalog creates.
nameThe level's name.
layersThe level's layer names, read with [[; $keys() lists the
keys it offers.
varThe level's per-feature column names, read with [[ or [.
obsThe level's per-sample column names, read with [[ or [.
LevelNames$new()Bind one rule level to the catalog's lookups.
LevelNames$new(name, lookup)
nameThe level's name.
lookupHow the catalog answers keys: find, find_all,
offered, known and sets, one lookup per set prefix.
LevelNames$clone()The objects of this class are cloneable with this method.
LevelNames$clone(deep = FALSE)
deepWhether to make a deep clone.
The R counterpart of apb2's ParsedLevels, as read_parsed_levels() returns
it.
Each level is an anndataR AnnData laid out as apb2's .h5ad writer lays it
out: the primary layer in X, the other layers in layers, obs and var
frames named by their key columns, and the level's APB part in uns$apb:
parse (with provenance$rule_json), roles, storage and post-parse
records.
The class generator; ParsedLevels$new() returns a ParsedLevels
object.
levelsA named list of anndataR AnnData, one per level.
unsThe root parse record.
metadataThe root post-parse records, such as sdrf or fasta.
hierarchyHow the levels nest, or NULL.
annotation_tablesA named list of data frames; each carries its
metadata as the attribute apb.
feature_relationsA named list of data frames of source, row,
target, column and value; each carries its metadata as the attribute
apb.
ParsedLevels$new()Collect the levels and records of one result.
ParsedLevels$new( levels, uns = list(), metadata = list(), hierarchy = NULL, annotation_tables = list(), feature_relations = list() )
levelsA named list of anndataR AnnData.
unsThe root parse record.
metadataThe root post-parse records.
hierarchyHow the levels nest, or NULL.
annotation_tablesA named list of data frames.
feature_relationsA named list of data frames.
ParsedLevels$print()Print the levels and their shapes.
ParsedLevels$print(...)
...Ignored.
ParsedLevels$clone()The objects of this class are cloneable with this method.
ParsedLevels$clone(deep = FALSE)
deepWhether to make a deep clone.
results <- tempfile() archive <- system.file( "extdata", "test-bundle", "results.tar.gz", package = "apbCatalogR" ) utils::untar(archive, exdir = results) result <- read_parsed_levels(file.path(results, "edge-two-levels.parquet")) names(result$levels) result$levels$proteinresults <- tempfile() archive <- system.file( "extdata", "test-bundle", "results.tar.gz", package = "apbCatalogR" ) utils::untar(archive, exdir = results) result <- read_parsed_levels(file.path(results, "edge-two-levels.parquet")) names(result$levels) result$levels$protein
Reads a result apb2 wrote into a ParsedLevels object, one anndataR
AnnData per level, the same for every format: a .h5ad file, a .duckdb
file, or the directory apb2 writes for a .parquet result. Reading Parquet
needs the arrow package, DuckDB the duckdb and DBI packages, .h5ad
the rhdf5 package, with which anndataR reads it.
read_parsed_levels(path)read_parsed_levels(path)
path |
The result, such as |
A ParsedLevels object.
apb2's convert command writes the result; each format records its format
name and version, and a result of another format or version is refused:
Parquet: a directory ending in .parquet whose manifest.json
(format apb2-parsed-levels-parquet, version 9) names every level and
table. Each level is a folder under levels/ with obs.parquet,
var.parquet, one file per layer in layers/ (features by observations)
and the tables of obsm/, varm/, obsp/ and varp/. The result's own
tables are in annotation_tables/ and feature_relations/.
DuckDB: one .duckdb file (format apb2-parsed-levels-duckdb,
version 8) holding the same manifest in the table apb2_result_metadata;
each table the manifest names is a database table.
h5ad: one .h5ad file of a one-level result in anndata's layout
(format apb2-parsed-levels, version 8), with apb2's storage descriptor in
uns$apb. An .h5ad file other software wrote has none and is refused.
results <- tempfile() archive <- system.file( "extdata", "test-bundle", "results.tar.gz", package = "apbCatalogR" ) utils::untar(archive, exdir = results) read_parsed_levels(file.path(results, "edge-two-levels.parquet"))results <- tempfile() archive <- system.file( "extdata", "test-bundle", "results.tar.gz", package = "apbCatalogR" ) utils::untar(archive, exdir = results) read_parsed_levels(file.path(results, "edge-two-levels.parquet"))
One row per cataloged or required field of each rule level the set reviews;
a set without vendor entries is checked against every level the bundle's
entries name for each version of versions.csv. A set with requirements
judges each level: fail when a required field is unsupported, warn when
a recommended one is, pass otherwise; an unsupported optional field is
listed but passes.
rule_coverage(set_name)rule_coverage(set_name)
set_name |
The set's name. |
A data frame with columns software (the quantification software of
the rule), version (the label), software_version_pattern, level,
slot, table (the varm table, else NA), name (the field's name,
NA when unsupported), key, kind, one qualifier.<name> column per
other qualifier of the set, as in catalog_table(), producer (the app,
NA for the quantification software's fields), requirement, needs
(what to run before the field exists) and verdict (NA for a set
without requirements).
head(rule_coverage("abundance_alpha"))head(rule_coverage("abundance_alpha"))
Every set of the bundle with its prefix, its purpose, its users and its
number of entries. The prefix asks the set alone, as "c:q_value".
sets()sets()
A data frame with columns set, prefix, purpose, used_by (a
list column), has_requirements and entries.
sets()sets()
[[ reads a key, else the level's own name; $keys() lists the catalog's
keys only. $get() returns NULL where [[ signals an error, $name() the
field's name; both take the qualifiers a key leaves open. A set's prefix,
"c:q_value", asks that set alone and never the level's own name;
"v:q_value" asks the level's own name alone. The design follows the Python
package cf_xarray, whose accessor finds a
variable by its CF-convention standard name before its own name.
The class generator, not exported: a Level's layers is its
object.
Slot$new()Bind one slot of a level.
Slot$new(level, location, lookup, read, named)
levelThe level's name.
location"layers", "var" or "obs".
lookupHow the catalog answers keys: find, find_all,
offered, known and sets, one lookup per set prefix.
readThe value of a field the slot holds.
namedThe level's own names in this slot.
Slot$get()The field a key names, narrowed by further qualifiers, else the level's own field of that name.
Slot$get(key, ...)
keyA key, or the level's own name.
...Further qualifiers by name, such as unit = "minute".
A matrix for layers, a vector for var and obs, a name without
data; NULL when it is neither.
Slot$name()The name of the field get reads; an error when the
name is neither a key the level answers nor one of its own names.
Slot$name(key, ...)
keyA key, or the level's own name.
...Further qualifiers by name, such as unit = "minute".
The field's name, such as "PEP"; table/column for a
column of a varm table.
Slot$keys()The keys the level offers in this slot.
Slot$keys()
A character vector.
Slot$clone()The objects of this class are cloneable with this method.
Slot$clone(deep = FALSE)
deepWhether to make a deep clone.
Installs a bundle archive into the user cache, so lookups use it without a
package update. apb-catalog's make bundle writes the archive, as
build/apb-catalog-bundle.tar.gz. Later sessions keep using the newest
bundle, shipped or installed. Nothing is downloaded.
update_catalog(path)update_catalog(path)
path |
Path to the bundle archive, a |
The catalog_version() now in use, invisibly.
if (interactive()) { update_catalog("apb-catalog/build/apb-catalog-bundle.tar.gz") }if (interactive()) { update_catalog("apb-catalog/build/apb-catalog-bundle.tar.gz") }