do_calc_on_num_cols: Run some function to produce new columns.

View source: R/calculations--internal.R

do_calc_on_num_colsR Documentation

Run some function to produce new columns.

Description

For a given table in a taxmap object, run some function to produce new columns. This function handles all of the option parsing and formatting of the result.

Usage

do_calc_on_num_cols(
  obj,
  data,
  func,
  cols = NULL,
  groups = NULL,
  other_cols = FALSE,
  out_names = NULL
)

Arguments

obj

A taxmap object

data

The name of a table in obj$data.

func

The function to apply. Should have the following form: function(count_table, cols = cols, groups = groups) and return a table.

cols

The columns in data to use. By default, all numeric columns are used. Takes one of the following inputs:

TRUE/FALSE:

All/No columns will used.

Character vector:

The names of columns to use

Numeric vector:

The indexes of columns to use

Vector of TRUE/FALSE of length equal to the number of columns:

Use the columns corresponding to TRUE values.

groups

Group multiple columns per treatment/group. This should be a vector of group IDs (e.g. character, integer) the same length as cols that defines which samples go in which group. When used, there will be one column in the output for each unique value in groups.

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:

NULL:

No columns will be added back, not even the taxon id column.

TRUE/FALSE:

All/None of the non-target columns will be preserved.

Character vector:

The names of columns to preserve

Numeric vector:

The indexes of columns to preserve

Vector of TRUE/FALSE of length equal to the number of columns:

Preserve the columns corresponding to TRUE values.

out_names

The names of count columns in the output. Must be the same length and order as cols (or unique(groups), if groups is used).

Value

A tibble


metacoder documentation built on April 4, 2023, 9:08 a.m.