Package bedshift Documentation

Class Bedshift

The bedshift object with methods to perturb regions

def __init__(self, bedfile_path, delimiter='\t')

Read in a .bed file to pandas DataFrame format

Parameters:

  • bedfile_path (str): the path to the bedfile
def add(self, addrate, addmean, addstdev)

Add regions

Parameters:

  • addrate (float): the rate to add regions
  • addmean (float): the mean length of added regions
  • addstdev (float): the standard deviation of the length of added regions

Returns:

  • int: the number of regions added
def add_from_file(self, fp, addrate, delimiter='\t')

Add regions from another bedfile to this perturbed bedfile

Parameters:

  • addrate (float): the rate to add regions
  • fp (str): the filepath to the other bedfile

Returns:

  • int: the number of regions added
def all_perturbations(self, addrate=0.0, addmean=320.0, addstdev=30.0, addfile=None, shiftrate=0.0, shiftmean=0.0, shiftstdev=150.0, cutrate=0.0, mergerate=0.0, droprate=0.0)

Perform all five perturbations in the order of shift, add, cut, merge, drop.

Parameters:

  • addrate (float): the rate (as a proportion of the total number of regions) to add regions
  • addmean (float): the mean length of added regions
  • addstdev (float): the standard deviation of the length of added regions
  • shiftrate (float): the rate to shift regions (both the start and end are shifted by the same amount)
  • shiftmean (float): the mean shift distance
  • shiftstdev (float): the standard deviation of the shift distance
  • cutrate (float): the rate to cut regions into two separate regions
  • mergerate (float): the rate to merge two regions into one
  • droprate (float): the rate to drop/remove regions

Returns:

  • int: the number of total regions perturbed
def cut(self, cutrate)

Cut regions to create two new regions

Parameters:

  • cutrate (float): the rate to cut regions into two separate regions

Returns:

  • int: the number of regions cut
def drop(self, droprate)

Drop regions

Parameters:

  • droprate (float): the rate to drop/remove regions

Returns:

  • int: the number of rows dropped
def merge(self, mergerate)

Merge two regions into one new region

Parameters:

  • mergerate (float): the rate to merge two regions into one

Returns:

  • int: number of regions merged
def pick_random_chrom(self)

Utility function to pick a random chromosome

Returns:

  • str, float chrom_str, chrom_len: chromosome number and length
def read_bed(self, bedfile_path, delimiter='\t')

Read a BED file into pandas dataframe

Parameters:

  • bedfile_path (str): The path to the BED file
def reset_bed(self)

Reset the stored bedfile to the state before perturbations

def shift(self, shiftrate, shiftmean, shiftstdev)

Shift regions

Parameters:

  • shiftrate (float): the rate to shift regions (both the start and end are shifted by the same amount)
  • shiftmean (float): the mean shift distance
  • shiftstdev (float): the standard deviation of the shift distance

Returns:

  • int: the number of regions shifted
def to_bed(self, outfile_name)

Write a pandas dataframe back into BED file format

Parameters:

  • outfile_name (str): The name of the output BED file

Version Information: bedshift v1.0.0, generated by lucidoc v0.4.2