| register_immunarch_method | R Documentation |
register_immunarch_method(
core,
family,
name,
register_family = TRUE,
required_cols = NULL,
need_repertoires = TRUE
)
core |
A function with signature |
family |
String. Method family name used for dispatch (e.g., |
name |
String. Method name within the family (e.g., |
register_family |
Logical (default |
required_cols |
Character vector of column names that must be present in
|
need_repertoires |
Logical. Use this to declare the necessity of having aggregated repertoires. |
Wrap a core implementation into a user-facing function and (optionally) register it in the in-memory method registry. The wrapper adds common arguments and runs safety checks so your core stays minimal.
Signature: function(idata, ...)
Must not declare autojoin, format, or features - these are added by the wrapper.
Common args from im_common_args(): autojoin, format, features
(with autojoin default controlled by getOption("immunarch.autojoin", FALSE)).
Validates idata is an immundata::ImmunData object.
Ensures all columns in required_cols exist in idata$annotations.
If autojoin = TRUE and the result is a data frame containing the repertoire id
column (immundata::imd_schema("repertoire")), joins repertoire metadata from
idata$repertoires.
A function - the user-facing wrapper around core. Typical usage is to
assign it to the exported symbol of the method, e.g.:
airr_stats_lengths <- register_immunarch_method(...).
## Not run:
# Minimal core implementation (must accept `idata`)
airr_stats_lengths_impl <- function(idata, seq_col = "cdr3_aa") {
dplyr::as_tibble(idata$annotations) |>
dplyr::distinct(.data[[immundata::imd_schema("repertoire")]], .data[[seq_col]]) |>
dplyr::mutate(seq_len = nchar(.data[[seq_col]])) |>
dplyr::count(.data[[immundata::imd_schema("repertoire")]], seq_len, name = "n")
}
# Register and expose a user-facing function
airr_stats_lengths <- register_immunarch_method(
core = airr_stats_lengths_impl,
family = "airr_stats",
name = "lengths",
required_cols = c("cdr3_aa", immundata::imd_schema("repertoire"))
)
# Optional: call via dispatcher
# make_airr_dispatcher("airr_stats")(idata = immdata, method = "lengths")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.