to_pairwise: Enable pairwise analysis with customized function

Description Usage Arguments Value Author(s) Examples

View source: R/to_pairwise.R

Description

given a data frame, perform pairwise analysis with any function on all pairs of columns

Usage

1
to_pairwise(d, f, unique_pair = TRUE, same_comparison = FALSE, mc = 1)

Arguments

d

a data frame or tibble or data table

f

a function to perform some analysis. The inputs of the function should be two numeric vectors.

unique_pair

a binary indicator of whether only unique pairs should be kept. If TRUE, "B-A" pair will be removed if "A-B" pair is present.

same_comparison

a binary indicator of whether to keep self pairs (i.e., "A-A"). If TRUE, self pairs will be kept.

mc

number of cores to use for multi-thread parallel analysis. Pass to mclapply. Deafult: 1

Value

a data table contains analysis results of all pairs of columns. The first two columns ("id1" and "id2") contain the two column names in d that were included in each pairwise analysis.

Author(s)

Siyang Xia sxia@hsph.harvard.edu

Examples

1
2
3
4
data(peptide_z)
peptide_bi <- as.data.frame((peptide_z > 5) * 1)
output <- to_pairwise(d = peptide_bi, f = peptide_cooccurrence)
head(output)

siyangxia419/virlink documentation built on Jan. 2, 2022, 12:16 a.m.