Regions module

Module providing randomisation functions for :GenomicRegion objects.

genomic_regions.permute.randomize_regions(original_regions, chromosome_sizes=None, method='unconstrained', attribute='score', preserve_attributes=False, sort=False, _chromosome_regions=None)

Perform a single randomisation of a list of genomic regions.

Parameters
  • original_regionslist of GenomicRegion objects

  • chromosome_sizes – Either the path to a <genome>.chrom.sizes file (e.g. from UCSC) or a genome identifier (e.g. mm10, hg19, …). Only necessary when using ‘unconstrained’ randomisation.

  • method – Type of randomisation. ‘unconstrained’, which will randomly place regions on the same chromosome, ‘spacing’, which will first compile a list of distances between regions, shuffle the distances and regions independently, and then alternately place a region and a space on the chromosome. This changes the order and pairwise distances of region on each chromosome, but maintains the overall distance distribution. ‘attribute’: Keeps region locations, but shuffles a specific region attribute instead (specified by attribute parameter)

  • attribute – attribute to shuffle in ‘attribute’ mode. Default: score

  • preserve_attributes – Randomised region will preserve the attributes of the original regions

  • sort – Sort region list before randomising

Returns

list of randomised regions

genomic_regions.permute.iter_randomized_regions(original_regions, iterations=1, chromosome_sizes=None, method='unconstrained', attribute='score', preserve_attributes=False, sort=False, _chromosome_regions=None)

Perform a multiple randomisations of a list of genomic regions.

Parameters
  • original_regionslist of GenomicRegion objects

  • iterations – Number of randomisations to perform

  • chromosome_sizes – Either the path to a <genome>.chrom.sizes file (e.g. from UCSC) or a genome identifier (e.g. mm10, hg19, …). Only necessary when using ‘unconstrained’ randomisation.

  • method – Type of randomisation. ‘unconstrained’, which will randomly place regions on the same chromosome, ‘spacing’, which will first compile a list of distances between regions, shuffle the distances and regions independently, and then alternately place a region and a space on the chromosome. This changes the order and pairwise distances of region on each chromosome, but maintains the overall distance distribution. ‘attribute’: Keeps region locations, but shuffles a specific region attribute instead (specified by attribute parameter)

  • attribute – attribute to shuffle in ‘attribute’ mode. Default: score

  • preserve_attributes – Randomised region will preserve the attributes of the original regions

  • sort – Sort region list before randomising

Returns

iterator over lists of randomised regions