lib5c.writers.counts module

Module for writing .counts files.

lib5c.writers.counts.main()[source]
lib5c.writers.counts.write_cis_trans_counts(counts, outfile, primermap, omit_zeros=True)[source]

Writes a counts file including both the cis and trans counts.

Parameters
  • counts (2d numpy array) – The square, symmetric array of counts to be written. This must be a single matrix that contains the cis contacts for all regions as well as the trans contacts between them. The rows of the matrix must correspond to genomic loci in order of increasing genomic coordinate.

  • outfile (str) – String reference to the file to write counts to.

  • primermap (dict of lists of dicts) –

    The keys of the outer dict are region names. The values are lists, where the i th entry represents the i th primer or bin in that region. Primers or bins are represented as dicts with the following structure:

    {
        'chrom' : str,
        'start' : int,
        'end'   : int,
        'name'  : str,
        'orientation': "3'" or "5'"
    }
    

    The strand key is optional and only makes sense when writing primer-primer interaction counts. If present, impossible primer-primer combinations will be omitted from the output. See lib5c.parsers.primers.get_primermap() or lib5c.parsers.primers.get_pixelmap().

  • omit_zeros (bool) – If True, lines will not be written to the outfile if the counts for that line are zero.

lib5c.writers.counts.write_counts(counts, outfile, primermap, skip_zeros=False)[source]

Writes a standard counts file.

Parameters
  • counts (dict of 2d arrays) – The counts to be written. The keys are the region names. The values are the arrays of counts values for that region. These arrays should be square and symmetric.

  • outfile (str) – String reference to the file to write counts to.

  • primermap (dict of lists of dicts) –

    The keys of the outer dict are region names. The values are lists, where the i th entry represents the i th primer or bin in that region. Primers or bins are represented as dicts with the following structure:

    {
        'chrom' : str,
        'start' : int,
        'end'   : int,
        'name'  : str,
        'orientation': "3'" or "5'"
    }
    

    The strand key is optional and only makes sense when writing primer-primer interaction counts. If present, impossible primer-primer combinations will be omitted from the output. See lib5c.parsers.primers.get_primermap() or lib5c.parsers.primers.get_pixelmap().

  • skip_zeros (bool) – Pass True to omit writing output lines for bin-bin pairs with zero, nan, or empty string value.