Module epiclass.utils.metadata_utils

Metadata analysis basic utility functions. Also defines some constants.

Functions

def count_combinations(my_metadata: Metadata, categories: Iterable[str], use_uuid: bool = False) ‑> Counter[Tuple[str, ...]]

Return label combinations counter from the given metadata categories.

Args

my_metadata : Metadata
Experiment metadata to analyze.
categories : List[str]
A list of categories to count.
use_uuid : bool
If True, count combinations by uuid; otherwise, by md5sum.

Returns

Counter (Tuple[str, …], int): A counter object that counts label combinations.

def count_labels_from_dset(dset: KnownData, label_category: str, from_uuid)

Returns a Counter object containing the counts of all examples of a given label category in a dataset.

This function processes the dataset and organizes the samples by the specified label category, counting the number of occurrences for each unique label.

Args

dset : KnownData
The dataset object containing the samples and metadata.
label_category : str
The specific label category to count (e.g., "assay", "cell_type").
from_uuid : bool
A flag to determine whether to use "uuid" or "md5sum" as the identifying label.

Returns

collections.Counter
A Counter object with the unique labels as keys and the counts as values.
def count_pairs(my_metadata: Metadata, cat1: str, cat2: str, use_uuid: bool = False) ‑> Counter[Tuple[str, str]]

Return label pairs (label_cat1, label_cat2) counter from the given metadata categories.

Args

my_metadata : Metadata
experiment metadata to analyze.
cat1 : str
The first category to count.
cat2 : str
The second category to count.
use_uuid : bool
If True, count pairs by uuid; otherwise, by md5sum.

Returns

Counter (Tuple[str, str], int): A counter object that counts label pairs.

def make_table(my_metadata: Metadata, cat1: str, cat2: str, filepath: str)

Write metadata content tsv table for given metadata categories

def print_pairs(my_metadata: Metadata, cat1: str, cat2: str)

Print label pairs from the given metadata categories.