Attributes provide information about nodes of in the classification tree,
which is displayed in the top-right area of the chart once a node is clicked.
If generating Krona charts from a matrix/data frame/phyloseq object, both
name and data are required.
If a pre-computed nested tree is provided as classification, only name
is required to indicate the name of the list entry containing the data.
Also, some other options don't apply: dataset_summary_fn, allow_extra_data,
missing_fill, only_ranks.
Numeric data can be used for custom coloring (see color in make_krona).
External links can be displayed by setting hrefBase and href.
Text data may contain HTML code (automatically escaped).
Usage
ChartAttribute(
name,
data = NULL,
displayName = name,
text = NULL,
missing_value = NA,
hrefBase = NULL,
href = NULL,
max_digits = NULL,
dataset_summary_fn = NULL,
summary_fn = NULL,
allow_extra_data = FALSE,
missing_fill = NA,
only_ranks = NULL
)Arguments
- name
A name or label. In case of generating charts from a tree structure (nested lists),
nameidentifies the attribute.- data
The attribute data, which can be a vector or matrix/data frame (see details)
- displayName
Optional longer label displayed next to the attribute value instead of the
name- text
Text displayed for a node, or a function used to generate the text, in the form
text(node_name, attribute_value)- missing_value
Behavior in case of missing attribute values: By default (
missing_value = NA), the attribute is hidden from the list of attributes in the top-right corner if the underlying data isNAfor the currently selected node. To explicitly always include the attribute in the list, e.g. setmissing_value = 'N/A'. Note: If using this attribute for coloring,missing_valueshould also be set to some character string, otherwise the color for the value 0 is assumed.make_krona(color = ...)does this automatically.- hrefBase
Optional base URL is prepended to each value (or
hrefpath). The text is turned into a link ifhrefBaseis defined.- href
URL or URL component following the common
hrefBaseprefix, or a function for generating it in the formhref(node_name, attribute_value)- max_digits
The number of digits to use when formatting numeric data. The default is
max_digitsfrom ChartOpts.- summary_fn
Summary function for aggregating
datafor higher ranks. The function should look as follows:summary_fn(attribute_data, magnitudes)whereattribute_datais a vector of values. The default function for numeric data calculates a weighted mean:weighted.mean(attribute_data, magnitudes, na.rm=TRUE). In case of a character vector/matrix, the default function assigns an item to a lower/inner rank if all nested items are equal, otherwise it assignsNA.- allow_extra_data
Suppress warnings regarding extra entries in
datanot found in the classification.- missing_fill
Numeric or character value to use for missing entries that are present in the
classificationbut not in the attributedata. Default:NA(another good choice for numeric values could be missing_fill = 0). Not to be mistaken withmissing_value, which just controls how attributes are displayed.- only_ranks
Optional vector of names or indices of
classificationrank columns for which the attribute should be displayed- dataset_summary_fn:
Function for a rowwise summary of
datacolumns across datasets (seegroupsin make_krona). The function must accept a vector vector of values and return a single value. The default issumfor numeric values. Character items from a group are only retained if are all equal, otherwiseNAis returned.
Details
Attributes reflect the structure of the Krona XML format. Even the abundance
information (magnitude) is stored as an XML attribute (make_krona.matrix uses
the name n for that).
How does data look like?
It may be provided as:
A vector with entries corresponding to the different classes in the hierarchy; values cannot vary across different datasets, if there are any
A matrix or data frame with (optionally named) columns corresponding to data sets (see
dataset_groupin make_krona). If the number of columns corresponds to the columns of themagnitudesupplied to make_krona, values are aggregated bydataset_groupwithdataset_summary_fn.
If if vector names or matrix row names are set both in the make_krona
classification and the attribute data, they will be used for matching the two.
There may be missing values in data (see also missing_fill).
If there are no row names, classification and attribute data entries
must align.
Numeric data is aggregated with summary_fn (default: average).
Text data is usually only available in the lowest rank (outermost level
of the hierarchy) unless it is identical across all children of a node,
in which case it gets propagated upwards. The behavior can be changed with
summary_fn.