This function matches two sets of variables using a bipartite graph and returns a data frame of the matched pairs.

bipartite_variable_match(
  data,
  cog_col = "cog",
  voi_col = "voi",
  plot = FALSE,
  weight_type = "-log(p)",
  edge_width_multiplier = 11,
  directed = FALSE
)

Arguments

data

A data frame containing the required columns for matching.

cog_col

Character. The name of the first variable column. Default is "cog".

voi_col

Character. The name of the second variable column. Default is "voi".

plot

Logical. If TRUE, plots the resulting bipartite graph. Default is FALSE.

weight_type

Character. Defines the edge weight type for the bipartite graph. Options are "d" (distance), "-log(p)" (negative log p-value). Default is "-log(p)".

edge_width_multiplier

Numeric. Multiplier for the edge width in the plot. Default is 11.

directed

Logical. If TRUE, creates a directed graph. Default is FALSE.

Value

A data frame with matched pairs of variables and their associated data.

Examples

# Example usage:
df <- data.frame(cog = c("cog1", "cog2"), voi = c(1, 2), 
 d = c(0.1, 0.2), p = c(0.05, 0.01), multi = c(1, 2))
bipartite_variable_match(df, plot = TRUE)

#>    cog voi   d    p multi
#> 1 cog1   1 0.1 0.05     1
#> 2 cog2   2 0.2 0.01     2