pairwise_ratios: Pairwise ratios of vector elements and matrix rows or columns

Description Usage Arguments Examples

View source: R/ratios.R

Description

For a matrix, computes the ratios of the supplied margin (1 = rows, 2 = cols). Otherwise, computes the ratios of the elements.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
pairwise_ratios(x, ..., f = `/`, filter = TRUE, set_names = TRUE, sep = ":")

## Default S3 method:
pairwise_ratios(x, f = `/`, filter = TRUE, set_names = TRUE, sep = ":")

## S3 method for class 'matrix'
pairwise_ratios(x, margin, f = `/`, filter = TRUE, set_names = TRUE, sep = ":")

## S3 method for class 'otu_table'
pairwise_ratios(x, margin = "taxa", f = `/`, filter = TRUE, sep = ":")

## S3 method for class 'phyloseq'
pairwise_ratios(x, margin = "taxa", f = `/`, filter = TRUE, sep = ":")

Arguments

x

A vector or matrix

f

Vectorized binary function applied to numerator and denominator

filter

Whether to filter out redundant pairs

set_names

Whether to set names for the pairs

sep

Seperator for pair names

margin

Margin (1 = rows, 2 = cols) of matrix x to compute ratios of

Examples

1
2
3
4
5
6
7
  mat <- seq(10) |>
    matrix(nrow = 2)
  rownames(mat) <- paste0('r', seq(2))
  colnames(mat) <- paste0('c', seq(5))
  
  pairwise_ratios(mat, 2)
  pairwise_ratios(mat[1,])

mikemc/metacal documentation built on Feb. 20, 2022, 1:46 a.m.