A machine-readable description of what each argument of an rbiom
function accepts: its kind, its fixed choices, numeric limits, whether
NULL is allowed and what it means, and where dataset-dependent
choices come from. Another program (such as a web interface) can use it
to draw input controls and to check a request without calling the
function. The same description is what the functions use to check their
own arguments, so the two cannot disagree.
Value
With fn, one entry (a list). Without, a named list of entries,
one per covered function, so names(fn_schema()) lists the
covered functions. With json = TRUE, the same as a JSON string.
Entries
Each entry has:
fnThe function's name.
returnsWhat the function returns:
typeis one of"plot","table","factor","matrix","dist","biom", or"file";haslists the$fields the result carries (e.g."data","code","stats").counts(Optional) The counts the function should be given, where it makes a difference:
"rarefied"(diversity and abundance compared at one sequencing depth), or"unrarefied"(rarefaction curves,rarefy()itself, and differential abundance, which models sequencing depth itself).needs(Optional) An optional package the function requires.
rules(Optional) Constraints between arguments, each one of:
one_of(exactly one of these arguments must be non-NULL);any_of(at least one must be); orwhen(conditions, as for an argument'swhen) withrequires(these arguments must then be non-NULL) orforbids(they must then beNULL).paramsOne entry per argument, in the order of
formals().
Arguments
Every argument has name, type, and desc (the first sentence of
its help text). The other fields are present only when they apply.
typeOne of:
"logical","integer","number","string";"choice"(one or more ofchoices);"layers"(plot layers:choiceslists eachletterandname; letters may be run together, as in"xd");"field"(metadata field names: seeclass);"rank"(taxonomic ranks of the dataset, by name or by position:1is the highest rank,-1the lowest,0the OTUs);"taxa"(seeforms);"metric"(divis"alpha"or"beta";choiceslists each metric'sid,name, whether it isphylogenetic, needing a tree, and whether it needs integer counts,int_only);"aesthetic"(colors, shapes, or patterns:aes, andby, the argument whose values they are mapped to);"palette";"tracks";"biom","tree","dist","vector","file","dots"(R objects, a file path, and...: seer_only).requiredTRUEwhen the argument has no default.defaultThe default value, from
formals().default_expr,default_noteFor a default that is an expression, such as
stat.by = x: the expression (not evaluated) and what it means.defaultis thenNULL.nullPresent when
NULLis accepted: what it means.choicesThe fixed options. Matching ignores case and accepts unambiguous abbreviations.
choices_needsThe choices that need an optional package, as choice = package (layer name = package for layers), e.g.
tSNE = "Rtsne". Choices not listed need nothing extra.choices_whenOptions that depend on other arguments: a list of
whenconditions (as below) with thechoicesthat apply while they hold. The first that holds applies; otherwisechoices.min,maxNumeric limits.
"integer"values must be whole.max_nHow many values may be given. Absent: any number.
per_sideOne value for both rows and columns of a heat map, or two: for rows, then columns.
classFor fields:
"categorical","numeric", or"any".coerceFor categorical fields: numeric fields are accepted too, and treated as categories.
opsFor fields: field names may be prefixed with
"=="(compare within groups) or"!="(between groups).extraFor fields: values accepted besides the dataset's fields, such as
".taxa".formsThe forms accepted, when there are several:
"logical"(TRUEorFALSE);"true"(TRUEonly);"integer";"string";"choice"(one ofchoices);"palette"(a palette name fromlist_palettes(), optionally prefixed with"-"to reverse it);"values"(a vector of colors, shapes, or patterns);"named_values"(a vector named by the values ofby);"count"(the n most abundant taxa);"fraction"(a number below 1: taxa with at least that mean relative abundance);"names"(taxa names at the chosen rank);"fields"(metadata field names);"spec"(a list of options; see the function's help).palettesThe palette kinds suited to the argument.
needsAn optional package the argument requires.
whenConditions under which the argument has any effect; all must hold. Each names a
paramand one of:is(its value is one of these),is_not,has_any(it includes one of these),is_null,not_null. Values are canonical: layer names, not letters, and metric ids. Absent: the argument may always matter.deprecatedThe version that deprecated the argument.
r_onlyOnly an R caller can set it: an R object, a file path, a host setting such as
cpus, or....fn_check()refuses it.noteAnything else a caller needs to know.
In JSON, NULL is null, numbers are written in full, Inf is the
string "Inf", and the list fields (choices, forms, ops,
palettes, has, and the values in when) are always arrays.
choices_needs is an object.
The metric choices come from the installed version of the ecodive
package.
See also
fn_check() to check arguments against a dataset;
list_palettes() and list_metrics().
Examples
library(rbiom)
head(names(fn_schema()))
#> [1] "adiv_boxplot" "adiv_corrplot" "adiv_stats" "adiv_matrix"
#> [5] "adiv_table" "bdiv_boxplot"
x <- fn_schema("adiv_boxplot")
x$returns
#> $type
#> [1] "plot"
#>
#> $has
#> [1] "data" "code" "stats"
#>
str(x$params[[10]])
#> List of 6
#> $ name : chr "test"
#> $ type : chr "choice"
#> $ choices: chr [1:5] "auto" "none" "wilcox" "emmeans" ...
#> $ max_n : num 1
#> $ default: chr "auto"
#> $ desc : chr "Method for computing p-values."
fn_schema("rarefy", json = TRUE)
#> {"fn":"rarefy","returns":{"type":"biom","has":["code"]},"counts":"unrarefied","params":[{"name":"biom","type":"biom","required":true,"r_only":true,"desc":"An rbiom object, or any value accepted by `as_rbiom()`."},{"name":"depth","type":"integer","min":1,"max_n":1,"null":"Chosen automatically, as by suggest_rarefy_depth().","default":null,"desc":"The number of observations to keep per sample."},{"name":"seed","type":"integer","min":0,"max_n":1,"default":0,"desc":"Random seed for selecting which observations to keep."},{"name":"inflate","type":"logical","max_n":1,"default":false,"desc":"Logical. Handling for non-integer data (e.g. relative abundances)."},{"name":"clone","type":"logical","r_only":true,"max_n":1,"default":true,"desc":"Create a copy of `biom` before modifying."},{"name":"cpus","type":"integer","r_only":true,"min":1,"max":256,"max_n":1,"null":"All available cores.","default":null,"default_expr":"n_cpus()","default_note":"All available cores.","desc":"The number of CPUs to use."}]}