foodingraph: foodingraph: a package for food network inference

Description CI bootstrap network inference Network visualization Utils functions


The foodingraph package provide two categories of functions :

  1. confidence-interval (CI) bootstrap inference of mutual information (MI) or maximal information coefficient (MIC) adjacency matrices.

  2. network visualization in a graph using igraph and ggraph

CI bootstrap network inference

The two functions are

  1. boot_cat_bin : a function to perform the CI bootstrap inference for pairwise associations between ordinal and binary variables. It uses thresholds defined by simulation of independent associations using boot_simulated_cat_bin, such that it simulates independent associations between ordinal-ordinal, binary-binary and ordinal-binary pairs of variables. It calculates the CI bootstraps for each pairwise association of the variables' dataset, then compares the 1st percentile of these CI to the corresponding thresholds of independent data.

  2. boot_simulated_cat_bin : a function to determine the threshold values of MI or MIC of independent pairs of variables (ordinal vs. ordinal, and binary vs binary and ordinal vs. binary). It calculates the CI bootstraps of MI or MIC for these pairs of variables, and return a defined percentile of these CI (e.g. 99th percentile).

Network visualization

The three main functions are

  1. graph_from_matrix : create a graph from an adjacency matrix. This function need at least two arguments : 1. the adjacency matrix, in which the column names and row names are the node names. 2. the legend, which is a data frame of at least two columns : name (the name of the nodes in the adjacency matrix, e.g. CRUDSAL_cat) and title (the titles for each name, e.g. raw vegetables)
    Optionally, you can add a column family to specify the nodes' families.

  2. graph_from_links_nodes : create a graph from a list of nodes and links. This function needs two arguments : 1. the list of nodes and links, which should be the result from links_nodes_from_mat (if not, make sure the structure corresponds). 2. the legend (described above).

  3. compare_graphs : a function to compare two graphs. It unifies the legends and attributes, so the graphs can be visually comparable.

  4. save_graph : a function to save the graph in a file at high resolution.

Utils functions

Other functions include

  1. family_palette : to create a color palette to be used in the graph. It is usually done automatically, but can prove useful if comparing multiple graphs, to ensure the family colors remain the same throughout the graphs.

  2. links_nodes_from_mat : to extract the links and nodes from an adjacency matrix

  3. mic_adj_matrix : using the cstats function from the minerva package, calculate the adjacency MIC matrix.

foodingraph documentation built on Oct. 6, 2019, 5:06 p.m.