API: segmentation

class blockify.segmentation.SegmentationRecord[source]

A class to store a single Bayesian block genomic segmentation.

finalize()[source]

Store post hoc summary statistics of the segmentation.

blockify.segmentation.blocksToDF(chrom, ranges)[source]

Convert a set of contiguous Bayesian blocks to pandas DataFrame format.

Parameters
  • chrom (str) – String specifying the chromsome

  • ranges (array) – Array whose entries specify the coordinates of block boundaries

Returns

output

Return type

pandas DataFrame

blockify.segmentation.segment(input_file, method, p0=None, prior=None)[source]

Core segmentation method.

Parameters
  • input_file (BedTool object) – BedTool object (instantiated from pybedtools) for input data

  • method (str) – String specifying whether to use OP or PELT for the segmentation

  • p0 (float, optional) – Float used to parameterize the prior on the total number of blocks; must be in the interval [0, 1]. Default: 0.05

  • prior (float, optional) – Explicit value for the total number of priors (specifying this is not recommended)

Returns

segmentation – A SegmentationRecord from segmenting the provided data

Return type

SegmentationRecord

blockify.segmentation.segment_from_command_line(args)[source]

Wrapper function for the command line function blockify segment

Parameters

args (argparse.Namespace object) – Input from command line

Returns

segmentation – A SegmentationRecord from segmenting the command line data

Return type

SegmentationRecord

blockify.segmentation.validateSegmentationArguments(input_file, p0, prior)[source]

Validates parameters passed via the command line.

Parameters
  • input_file (BedTool object) – BedTool object (instantiated from pybedtools) for input data

  • p0 (float) –

  • prior (float) –

Returns

None

Return type

None