lib5c.util.annotationmap module

Module containing utilities for constructing annotatiomaps.

Annotatiomaps record the number of BED features of a certain type present at a given linear bin as specified by a pixelmap.

lib5c.util.annotationmap.main()[source]
lib5c.util.annotationmap.make_annotationmaps(pixelmap, directory='./annotations', add_wildcard=True)[source]

Gets a dict of annotationmaps, one for every BED file in a specified directory.

Parameters:
  • pixelmap (pixelmap) – The pixelmap to use to generate the annotationmap. See lib5c.parsers.bed.get_pixelmap().
  • directory (str) – The directory to look in for BED files describing the annotations.
  • add_wildcard (bool) – Pass True to add a ‘wildcard’ annotation that has 100 hits in every bin. Useful for doing “unsided” enrichments later.
Returns:

The keys of the outer dict are annotation names as parsed from the names of the BED files in directory. The values are annotationmaps. See lib5c.util.annotationmap.get_single_annotatiomap().

Return type:

dict of dict of lists

lib5c.util.annotationmap.make_single_annotationmap(annotation, pixelmap)[source]

Generates an annotationmap given an annotation and a pixelmap.

Parameters:
  • annotation (dict of lists of dicts) –

    The keys are chromosome names. The values are lists of features for that chromosome. The features are represented as dicts with the following structure:

    {
        'chrom': str
        'start': int,
        'end'  : int,
    }
    

    See lib5c.parsers.bed.load_features().

  • pixelmap (pixelmap) – The pixelmap to use to generate the annotationmap. See lib5c.parsers.bed.get_pixelmap().
Returns:

The keys of the dictionary are region names. The values are lists, where the i th entry represents the number of intersections between the annotation and the i th bin of that region.

Return type:

dict of lists