calc_taxon_abund | R Documentation |
For a given table in a taxmap
object, sum the values in
each column for each taxon. This is useful to convert per-observation counts
(e.g. OTU counts) to per-taxon counts.
calc_taxon_abund(
obj,
data,
cols = NULL,
groups = NULL,
out_names = NULL,
dataset = NULL
)
obj |
A |
data |
The name of a table in |
cols |
The columns in
|
groups |
Group multiple columns per treatment/group. This should be a
vector of group IDs (e.g. character, integer) the same length as
|
out_names |
The names of count columns in the output. Must be the same
length and order as |
dataset |
DEPRECIATED. use "data" instead. |
A tibble
Other calculations:
calc_diff_abund_deseq2()
,
calc_group_mean()
,
calc_group_median()
,
calc_group_rsd()
,
calc_group_stat()
,
calc_n_samples()
,
calc_obs_props()
,
calc_prop_samples()
,
compare_groups()
,
counts_to_presence()
,
rarefy_obs()
,
zero_low_counts()
## Not run:
# Parse data for example
x = parse_tax_data(hmp_otus, class_cols = "lineage", class_sep = ";",
class_key = c(tax_rank = "taxon_rank", tax_name = "taxon_name"),
class_regex = "^(.+)__(.+)$")
# Calculate the taxon abundance for each numeric column (i.e. sample)
calc_taxon_abund(x, "tax_data")
# Calculate the taxon abundance for a subset of columns
calc_taxon_abund(x, "tax_data", cols = 4:5)
calc_taxon_abund(x, "tax_data", cols = c("700035949", "700097855"))
calc_taxon_abund(x, "tax_data", cols = startsWith(colnames(x$data$tax_data), "70001"))
# Calculate the taxon abundance for groups of columns (e.g. treatments)
# Note that we do not need to use the "cols" option for this since all
# numeric columns are samples in this data. If there were numeric columns
# that were not samples present in hmp_samples, the "cols" would be needed.
calc_taxon_abund(x, "tax_data", groups = hmp_samples$sex)
calc_taxon_abund(x, "tax_data", groups = hmp_samples$body_site)
# The above example using the "cols" option, even though not needed in this case
calc_taxon_abund(x, "tax_data", cols = hmp_samples$sample_id,
groups = hmp_samples$sex)
# Rename the output columns
calc_taxon_abund(x, "tax_data", cols = hmp_samples$sample_id[1:10],
out_names = letters[1:10])
calc_taxon_abund(x, "tax_data", groups = hmp_samples$sex,
out_names = c("Women", "Men"))
# Geting a total for all columns
calc_taxon_abund(x, "tax_data", cols = hmp_samples$sample_id,
groups = rep("total", nrow(hmp_samples)))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.