counts_to_presence {metacoder} | R Documentation |
Apply a function to groups of columns
Description
For a given table in a taxmap
object, apply a function to
rows in groups of columns. The result of the function is used to create new
columns. This is equivalent to splitting columns of a table by a factor and
using apply
on each group.
Usage
counts_to_presence(
obj,
data,
threshold = 0,
groups = NULL,
cols = NULL,
other_cols = FALSE,
out_names = NULL,
dataset = NULL
)
Arguments
obj |
A |
data |
The name of a table in |
threshold |
The value a number must be greater than to count as present. By, default, anything above 0 is considered present. |
groups |
Group multiple columns per treatment/group. This should be a
vector of group IDs (e.g. character, integer) the same length as
|
cols |
The columns in
|
other_cols |
Preserve in the output non-target columns present in the input data. New columns will always be on the end. The "taxon_id" column will be preserved in the front. Takes one of the following inputs:
|
out_names |
The names of count columns in the output. Must be the same
length and order as |
dataset |
DEPRECIATED. use "data" instead. |
Value
A tibble
See Also
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()
,
calc_taxon_abund()
,
compare_groups()
,
rarefy_obs()
,
zero_low_counts()
Examples
## Not run:
# Parse data for examples
x = parse_tax_data(hmp_otus, class_cols = "lineage", class_sep = ";",
class_key = c(tax_rank = "taxon_rank", tax_name = "taxon_name"),
class_regex = "^(.+)__(.+)$")
# Convert count to presence/absence
counts_to_presence(x, "tax_data")
# Check if there are any reads in each group of samples
counts_to_presence(x, "tax_data", groups = hmp_samples$body_site)
## End(Not run)