Compocyte.core.toolsΒΆ

Utility functions for Compocyte.

This module implements helper functions used across the package such as data transformations, dictionary helpers and small utilities that keep the core code focused on algorithmic logic.

class Compocyte.core.tools.Hierarchical_Metric(true_labels, predicted_labels, hierarchy_structure, root_node='Blood')[source]ΒΆ

Bases: object

augmented_set_of_node_n(node)[source]ΒΆ

Assuming a tree hierarchy structure, ancestors of node n, including node, excluding root

calculate_intersects(t_label, p_label, t_label_augmented, p_label_augmented)[source]ΒΆ
hF(beta)[source]ΒΆ
hP()[source]ΒΆ
hR()[source]ΒΆ
list_micro_metrics(beta)[source]ΒΆ
macro_hF(beta)[source]ΒΆ

Macro averaged hF-Score (average of micro hF1’s for each label)

Compocyte.core.tools.delete_dict_entries(dictionary, del_key='classifier', first_run=True, deleted_key=False)[source]ΒΆ
Compocyte.core.tools.dict_depth(dictionary, running_count=0)[source]ΒΆ
Compocyte.core.tools.flatten_dict(dictionary, running_list_of_values=[])[source]ΒΆ
Compocyte.core.tools.flatten_labels(pred_h_labels, graph, root_node, verbose=False)[source]ΒΆ
Compocyte.core.tools.get_last_annotation(obs_names, adata, barcodes=None, true_only=False)[source]ΒΆ
Compocyte.core.tools.get_leaf_nodes(hierarchy)[source]ΒΆ
Compocyte.core.tools.hierarchy_names_unique(hierarchy_dict)[source]ΒΆ
Compocyte.core.tools.is_counts(matrix, n_rows_to_try=100)[source]ΒΆ

Determines whether or not a matrix (such as adata.X, adata.raw.X or an adata layer) contains count data by manually checking a subsample of the supplied matrix.

Compocyte.core.tools.make_graph_from_edges(d, g, parent_key='')[source]ΒΆ

Add explanation

Compocyte.core.tools.set_node_to_depth(dictionary, depth=0, node_to_depth={})[source]ΒΆ
Compocyte.core.tools.z_transform_properties(data_arr, discretization=False)[source]ΒΆ

Calculates a z transformation to center properties across cells in data_arr around mean zero