cobamp.analysis package

Submodules

cobamp.analysis.frequency module

cobamp.analysis.frequency.get_frequency_dataframe(pathway_dict, k_min=1, k_max=1)[source]

cobamp.analysis.graph module

cobamp.analysis.graph.apply_fx_to_all_node_values(tree, fx)[source]

Applies a function to all nodes below the tree, modifying their value to its result. Parameters ———- tree: A Tree instance fx: A function to apply ——-

cobamp.analysis.graph.compress_linear_paths(tree)[source]

Collapses sequences of nodes contained in a Tree with only one children as a single node containing all values of those nodes. Parameters ———- tree: A Tree instance. ——-

cobamp.analysis.graph.find_all_tree_nodes(tree)[source]

tree: A Tree instance.

cobamp.analysis.graph.ignore_compressed_nodes_by_size(tree, size)[source]

Modifies the values of a tree’s children that have been previously compressed with the <compress_linear_paths> function if they contain more than a certain number of elements. The node’s value is changed to “REMAINING”. Parameters ———- tree: A Tree instance size: An integer with the size threshold ——-

cobamp.analysis.graph.merge_duplicate_nodes(tree)[source]

Merges all nodes with similar values, replacing every instance reference of all nodes with the same object if its value is identical

cobamp.analysis.graph.populate_nx_graph(tree, G, previous=None, name_separator='\n', unique_nodes=True, node_dict=None)[source]
cobamp.analysis.graph.pretty_print_tree(tree, write_path=None)[source]

tree: A Tree instance write_path: Path to store a text file. Use None if the string is not to be stored in a file.

cobamp.analysis.graph.probabilistic_tree_compression(tree, data=None, total_count=None, name_separator=' and ')[source]

Compresses a node and subsequent children by removing them and modifying the value to a dictionary with the relative frequency of each element in the subsequent nodes. Requires values on the extra_info field.

tree: A Tree instance data: Local count if not available in extra_info total_count: Total amount of sets if not available in extra_info name_separator: Separator to use when representing multiple elements ——-

cobamp.analysis.graph.probabilistic_tree_prune(tree, target_level, current_level=0, cut_leaves=False, name_separator=' and ')[source]

Cuts a tree’s nodes under a certain height (target_level) and converts ensuing nodes into a single one whose value represents the relative frequency of an element in the nodes below. Requires values on the extra_info field. Parameters ———- tree: A Tree instance target_level: An int representing the level at which the tree will be cut current_level: The current level of the tree (int). Default is 0 for root nodes. cut_leaves: A boolean indicating whether the node at the target level is excluded or displays probabilities. name_separator: Separator to use when representing multiple elements ——-

cobamp.analysis.plotting module

cobamp.analysis.plotting.annotate_heatmap(im, data=None, valfmt='{x:.2f}', textcolors=['black', 'white'], threshold=None, **textkw)[source]

A function to annotate a heatmap.

Arguments:
im : The AxesImage to be labeled.
Optional arguments:

data : Data used to annotate. If None, the image’s data is used. valfmt : The format of the annotations inside the heatmap.

This should either use the string format method, e.g. “$ {x:.2f}”, or be a matplotlib.ticker.Formatter.
textcolors : A list or array of two color specifications. The first is
used for values below a threshold, the second for those above.
threshold : Value in data units according to which the colors from
textcolors are applied. If None (the default) uses the middle of the colormap as separation.

Further arguments are passed on to the created text labels.

cobamp.analysis.plotting.display_heatmap(df)[source]
cobamp.analysis.plotting.heatmap(data, row_labels, col_labels, ax=None, cbar_kw={}, cbarlabel='', **kwargs)[source]

Create a heatmap from a numpy array and two lists of labels.

Arguments:

data : A 2D numpy array of shape (N,M) row_labels : A list or array of length N with the labels

for the rows
col_labels : A list or array of length M with the labels
for the columns
Optional arguments:
ax : A matplotlib.axes.Axes instance to which the heatmap
is plotted. If not provided, use current axes or create a new one.
cbar_kw : A dictionary with arguments to
matplotlib.Figure.colorbar().

cbarlabel : The label for the colorbar

All other arguments are directly passed on to the imshow call.

Module contents