agentsclimarketplace

Spectra variable core population

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v1/skills/spectra-variable-core-population

Use when when implementing a custom MsBackend and the spectraData() method needs to return all core spectra variables (e.g., centroided, polarity, collisionEnergy) regardless of which variables were explicitly stored during backend initialization.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill spectra-variable-core-population

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.9 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it

spectra-variable-core-population

Summary

Populate missing core spectra variables with NA values in a backend's spectraData() output to ensure complete metadata structure. This ensures all required MS spectra variables are present in DataFrame results even when user-supplied data contains only a subset.

When to use

When implementing a custom MsBackend and the spectraData() method needs to return all core spectra variables (e.g., centroided, polarity, collisionEnergy) regardless of which variables were explicitly stored during backend initialization. This is essential when a backend stores only user-supplied variables like msLevel and rtime but must advertise and return the full set of core variables required by the Spectra API.

When NOT to use

  • Your backend stores and manages all core spectra variables explicitly; fillCoreSpectraVariables() is unnecessary overhead in that case.
  • You are implementing a read-only backend that intentionally exposes only a non-standard subset of variables and do not want to claim API compliance with MsBackend.
  • You are working with an existing backend (e.g., MsBackendMzR, MsBackendMemory) that already implements this pattern; focus on your application logic instead.

Inputs

  • DataFrame containing user-supplied spectra variables (e.g., msLevel, rtime)
  • MsBackend instance with populated user-supplied data slots

Outputs

  • DataFrame with all core spectra variables present, missing ones filled with NA
  • Spectra object backed by the completed backend

How to apply

Within the spectraData() method of your MsBackend subclass, invoke fillCoreSpectraVariables() on the DataFrame containing user-supplied spectra variables before returning. This helper function examines which core variables are missing from the current DataFrame and appends them as columns filled with NA values. The rationale is that the MsBackend API contract requires all backends to report the same set of core variables through spectraVariables(), so spectraData() must honor that contract by including those variables in its output, even if the backend does not actively manage all of them. Ensure spectraVariables() returns the union of both user-supplied and core variable names so that consumers know all variables will be present in the DataFrame.

Related tools

  • Spectra (R package providing the MsBackend virtual class, fillCoreSpectraVariables() helper, and DataFrame schema for core spectra variables) — https://github.com/RforMassSpectrometry/Spectra
  • S4Vectors (Provides DataFrame class used to store and return spectra variables with consistent schema)
  • MsBackendMemory (Reference implementation of MsBackend showing how spectraData() and fillCoreSpectraVariables() are used together) — https://github.com/RforMassSpectrometry/Spectra

Examples

# In MsBackendTest@spectraData() implementation:
setMethod("spectraData", "MsBackendTest", function(object, columns = NULL) {
  res <- DataFrame(msLevel = object@msLevel, rtime = object@rtime)
  res <- Spectra:::.fillCoreSpectraVariables(res)
  res
})

Evaluation signals

  • spectraData() return value contains all core variable names listed in spectraVariables() output
  • Missing core variables appear in the returned DataFrame as columns with all NA values
  • User-supplied variables retain their original data; no values are lost or overwritten
  • Calling spectraData() on two backends with different sets of user-supplied variables produces DataFrames with identical column sets (all core variables present) but different row values
  • The returned DataFrame passes as.data.frame() and retains proper column classes for NA-filled columns (logical for boolean cores, numeric for numeric cores, etc.)

Limitations

  • fillCoreSpectraVariables() only handles the predefined set of core variables recognized by the Spectra package; custom or domain-specific variables must be managed separately by the backend.
  • NA-filling occurs at the DataFrame level; if your backend needs to support lazy-loading of missing variables on-demand, you must override this behavior.
  • The function does not validate or impute sensible defaults; all missing cores become NA, which may not be appropriate for backends wrapping external data sources that have implicit defaults (e.g., polarity = 1 by convention).

Evidence

  • [other] The spectraData() implementation for MsBackendTest uses fillCoreSpectraVariables() to ensure that all core spectra variables are returned, filling missing ones with NA values even when only user-supplied variables like msLevel and rtime are stored.: "The spectraData() implementation for MsBackendTest uses fillCoreSpectraVariables() to ensure that all core spectra variables are returned, filling missing ones with NA values"
  • [intro] The spectraData() method should return the full spectra data within a backend as a DataFrame object (defined in the r Biocpkg("S4Vectors"): "The spectraData() method should return the full spectra data within a backend as a DataFrame object"
  • [intro] The spectraVariables() method should return a character vector with the names of all available spectra variables of the backend.: "The spectraVariables() method should return a character vector with the names of all available spectra variables"
  • [intro] Core spectra variables must be provided by each backend with dataStorage and dataOrigin as special required variables: "dataStorage and dataOrigin are two special spectra variables that define for each spectrum where the data is stored and from where the data derived"
  • [intro] The Spectra package separates the code for the analysis of MS data from the code needed to import, represent and provide the data.: "The Spectra package separates the code for the analysis of MS data from the code needed to import, represent and provide the data"

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.