flotilla.compute.network module

Compute networks (the kind with nodes and edges) on data. Visualize with :py:mod:flotilla.visualize.network

class flotilla.compute.network.Networker[source]

Bases: object

Networks (the kind with nodes and edges), aka a graph

Calculate the edges based on similarity between rows of PCA-reduced data

Construct a Networker object with default node colors (dark teal) and sizes (all nodes at 300)

adjacency(*args, **kwargs)[source]

Calculate the adjacency graph, i.e. connectedness between nodes

Parameters:

data : pandas.DataFrame

A (n_nodes, n_pcs) sized dataframe of reduced data

use_pc1 : bool, optional

If True, use the first principal component of reduced data (default True)

use_pc2 : bool, optional

If True, use the second principal component of reduced data (default True)

use_pc3 : bool, optional

If True, use the third principal component of reduced data (default True)

use_pc4 : bool, optional

If True, use the fourth principal component of reduced data (default True)

n_pcs : int, optional

Total number of principal components to use (default 5)

Returns:

adjacency : pandas.DataFrame

A lower triangular matrix of the edge weights between the rows of the data

get_weight_fun(fun_name='no_weight')[source]

Given a string, return the function

Used to obtain functions that perform common transforms on distance

Parameters:

fun_name : ‘no_weight’ | ‘sq’ | ‘arctan’ | ‘arctan_sq’, optional

Name of the function to obtain (default ‘no_weight’)

Returns:

func : function

A function which transforms a number in the indicated way

Raises:

ValueError

If fun_name is not one of the ones indicated above

graph(*args, **kwargs)[source]

Create a graph based on the adjacency matrix and other inputs

Parameters:

adjacency : pandas.DataFrame

A (n_nodes, n_nodes) square dataframe of edge weights between all nodes in the graph

cov_cut : float, optional

Minimum covariance between two nodes for their edge to be plotted. (default 0)

node_color_mapper : function, optional

Function to recolor the nodes for plotting, based on the node name. If None, defaults to a dark teal. (default None)

node_size_mapper : function, optional

Function to resize the nodes for plotting, based on the node name. If None, defaults to the same size for all nodes. (default None)

degree_cut : int

Minimum number of edges a node must have for it to be drawn on the graph

weight_function : ‘no_weight’ | ‘sq’ | ‘arctan’ | ‘arctan_sq’, optional

Weight function of the edges. The lower the weight, the farther away two nodes are drawn from each other.

name : str, optional (default=None)

For memoization purposes, not used in the function.

Returns:

graph : networkx.Graph

The graph created with all these parameters

positions : dict

A {node_name : [x, y]} mapping of all nodes and their x, y positions

weight_funs = ['no_weight', 'sq', 'arctan', 'arctan_sq']
Olga B. Botvinnik is funded by the NDSEG fellowship and is a NumFOCUS John Hunter Technology Fellow.
Michael T. Lovci was partially funded by a fellowship from Genentech.
Partially funded by NIH grants NS075449 and HG004659 and CIRM grants RB4-06045 and TR3-05676 to Gene Yeo.