Welcome to anuran’s documentation! For tutorials, please check out the README: https://github.com/ramellose/anuran

Indices and tables

anuran main

anuran: Null models for replicate networks. The script takes a network as input and uses this to generate null models. The output of the null models is presented as a csv of set sizes and a t-test is used to assess whether set sizes are different than expected from the null model. Detailed explanations are available in the headers of each file.

anuran uses the file extension to import networks. Generation of null models is done on the adjacency matrix for speed; the NetworkX representation is unfortunately slower.

The demo data for anuran was downloaded from the following publication: Meyer, K. M., Memiaghe, H., Korte, L., Kenfack, D., Alonso, A., & Bohannan, B. J. (2018). Why do microbes exhibit weak biogeographic patterns?. The ISME journal, 12(6), 1404.

anuran.main.model_calcs(networks, args)

Function for generating null models and carrying out calculations. :param networks: Dictionary with folder name as key and values as tuples (name, network object). :param args: Settings for running anuran :return:

anuran.main.set_anuran()

This parser gets input settings for running anuran. It requires an input format that can be read by NetworkX. Make sure to include the extension in the input filename as this is used to infer the file type.

anuran centrality

The functions in this module calculate intersections or differences of networks. The first function is a wrapper that subsamples networks from a list of null models to output a dataframe of set sizes.

anuran.centrality.generate_ci_frame(networks, random, degree, fractions, prev, perm, core)

This function estimates centralities from all networks provided in the network, random and degree lists. The random and degree lists are structured as follows: —List corresponding to each original network (length networks)

—List of permutations per original network (length n in generate_null)

The core list is structured as follows: —List of all shared fractions (length fractions)

—List corresponding to core prevalence(length core)
—List of permutations per original network (length networks)

The function returns a pandas dataframe with the size of the intersection, the type of model and the shared fraction as a separate column. The length of the dataset is equal to the number of original networks, the number of permuted sets for the random models and the number of permuted sets for the degree-preserving model.

‘None’ values reflect that the species in question was not found in a network.

Parameters:
  • networks – List of input networks
  • random – Dictionary with permuted input networks without preserved degree distribution
  • degree – Dictionary with permuted input networks with preserved degree distribution
  • fractions – List with fractions of shared interactions
  • prev – List with prevalence of shared interactions
  • perm – Number of sets to take from null models
  • core – Number of processor cores
Returns:

List of lists with set sizes

anuran.centrality.generate_confidence_interval(ranking)

Given a list with centrality rankings calculated from multiple networks, this function calculates the confidence interval.

Parameters:ranking – List of centrality rankings for each network
Returns:Dictionary with nodes as keys and tuples of confidence intervals as values

anuran draw

The functions in this module visualize set sizes and other anuran outputs. Draw_sets visualizes the set sizes of the null models and original networks. Draw_samples shows the distribution of set sizes as the number of networks increases, for both null models and the input networks. Draw_centralities plots the upper limit of the confidence interval against the lower limit. Draw_graphs shows the graph properties for each of the networks used by anuran.

anuran.draw.draw_centralities(data, fp)

This function accepts a pandas dataframe with 5 columns: Node, Network, Network type, Conserved fraction, Centrality, Upper limit, Lower limit For every centrality a scatter plot is generated with the upper- and lower limits on the x and y axes respectively.

Parameters:
  • data – Pandas data frame
  • fp – Filepath with prefix for name
Returns:

anuran.draw.draw_graphs(data, fp)

This function accepts a pandas dataframe with 5 columns: Network, Name, Group, Network type, Conserved fraction, Property, Value

Parameters:
  • data – Pandas data frame
  • fp – Filepath with prefix for name
Returns:

anuran.draw.draw_samples(data, fp)

This function accepts a pandas dataframe with 6 columns: Network, Network type, Conserved fraction, Set type, Set size For every combination of set type a faceted box and whiskers plot is generated that visualizes the distribution of set sizes per network type.

Parameters:
  • data – Pandas data frame
  • fp – Filepath with prefix for name
Returns:

anuran.draw.draw_set_differences(data, fp)

This function accepts a pandas dataframe with 4 columns: Interval, Set size, Group, Network. The interval is the difference of the intersections.

The interval is the median for the null model networks.

The function writes a bar plot of the intervals to path.

Parameters:
  • data
  • fp
Returns:

anuran.draw.draw_sets(data, fp)

This function accepts a pandas dataframe with 5 columns: Network, Network type, Conserved fraction, Set type, Set size For every combination of set type a faceted box and whiskers plot is generated that visualizes the distribution of set sizes per network type.

Parameters:
  • data – Pandas data frame
  • fp – Filepath with prefix for name
Returns:

anuran graphvals

The functions in this module calculate different graph-level properties.

The first function is a wrapper that subsamples networks from a list of null models to output a dataframe of set sizes.

anuran.graphvals.generate_graph_frame(networks, random, degree, fractions, core, perm)

This function estimates graph-level properties of all networks provided in the network, random and degree lists. The random and degree lists are structured as follows: —List corresponding to each original network (length networks)

—List of permutations per original network (length n in generate_null)

The core list is structured as follows: —List of all shared fractions (length fractions)

—List corresponding to core prevalence(length core)
—List of permutations per original network (length networks)

The function returns a pandas dataframe with the size of the intersection, the type of model and the shared fraction as a separate column. The length of the dataset is equal to the number of original networks, the number of permuted sets for the random models and the number of permuted sets for the degree-preserving model. :param networks: List of input networks :param random: Dictionary with permuted input networks without preserved degree distribution :param degree: Dictionary with permuted input networks with preserved degree distribution :param fractions: List with fractions of shared interactions :param core: List with prevalence of shared interactions :param perm: Number of sets to take from null models :return: List of lists with set sizes

anuran.graphvals.generate_graph_properties(networks)

This function constructs lists with centrality rankings of nodes in multiple networks. Instead of using the absolute degree or betweenness centrality, this takes metric bias into account.

If the graph is not connected, the values are calculated for the largest connected component.

Parameters:networks – List of input networks
Returns:Pandas dataframe with rankings

anuran nulls

The null models module contains functions for constructing permutations of input networks. Generation of null models is done on the adjacency matrix for speed; the NetworkX representation is unfortunately slower. The functions can either change (random model) or preserve (degree model) the degree distribution.

The functions in this module also calculate intersections or differences of networks. The first function is a wrapper that subsamples networks from a list of null models to output a dataframe of set sizes.

These functions run operations in parallel. utils.py contains the operations they carry out.

anuran.nulls.generate_null(networks, n, npos, core, fraction=False, prev=False)

This function takes a list of networks. For each network, a list with length n is generated, with each item in the list being a permutation of the original network. This is returned as a list of lists with this structure: —List corresponding to each original network (length networks)

—List of permutations per original network (length n)

For the positive controls, this list is inverted: —List of permutations across networks (length n)

—List corresponding to a single permuted group of networks

To generate the list through multiprocessing, a dictionary with arguments is generated and provided to a utility function.

Parameters:
  • networks – List of input NetworkX objects
  • n – Number of randomized networks per input network
  • npos – Number of positive control randomized networks per group
  • core – Number of processor cores
  • fraction – Fraction of conserved interactions
  • prev – Prevalence of core. If provided, null models have conserved interactions.
Returns:

List of lists with randomized networks