aggregateTaxa: Aggregate taxa according to a measure.

View source: R/aggregateTaxa.R

aggregateTaxaR Documentation

Aggregate taxa according to a measure.

Description

This function aggregates taxa according to their rank from a measure passed in weights: if a taxa has a lower rank than its coarser level, type = 'coarse', it is aggregated into the coarser; if their is a unique thinner level with a better rank than the coarser one, then the coarser is aggregated into the thiner Comparison is done only for the family, genus and specie levels.

Usage

aggregateTaxa(
  taxa,
  features = NULL,
  weights = NULL,
  thr = NULL,
  type = "coarse"
)

Arguments

taxa

taxa should be a data.frame with the feature name and all its other coarser/thinner levels (columns: 'Feature', 'f', 'g', 's')

features

if taxa is a vector or a data.frame that lacks all levels, a vector of the features to be checked.

weights

a data.frame with a column Feature and a column weight; for type = 'both' or 'coarse' only.

thr

numeric, value after which the algorithm should stop looking for better ranks in a taxonomic branch; for type = 'both' or 'coarse' only. If NULL, the median of weights is used.

type

character. If 'coarse', finer levels are aggregated into their coarser one if it has a better rank. If 'fine' then coarser levels are aggregated into a thinner level if it has a better rank and is unique, i.e. there is a unique finer level for that coarser level. If 'both', both aggregation steps are seuqentially performed.

Value

A dataframe with aggregated features in the "Feature" column, and the 'recipient' taxa in the "newFeature" column.


aruaud/endoR documentation built on Jan. 25, 2025, 2:20 a.m.