The Fend class

A class for handling HiC fend information.

class hifive.fend.Fend(filename, mode='r', silent=False)

This class handles restriction enzyme digest-generated fragment data for HiC experiments.

This class stores a list of chromosomes, a dictionary for converting from chromosome label to integer and back, fragment starts, stops, and chromosome number in an h5dict.

Note

This class is also available as hifive.Fend

When initialized, this class creates an h5dict in which to store all data associated with this object.

Parameters:
  • filename (str.) – The file name of the h5dict. This should end with the suffix ‘.hdf5’
  • mode (str.) – The mode to open the h5dict with. This should be ‘w’ for creating or overwriting an h5dict with name given in filename.
  • silent (bool.) – Indicates whether to print information about function execution for this object.
Returns:

Fend class object

Attributes:
  • file (str.) - A string containing the name of the file passed during object creation for saving the object to.
  • silent (bool.) - A boolean indicating whether to suppress all of the output messages.
  • history (str.) - A string containing all of the commands executed on this object and their outcome.
load()

Load fend data from h5dict specified at object creation.

Any call of this function will overwrite current object data with values from the last save() call.

Returns:None
load_fends(filename, genome_name=None, re_name=None, format=None)

Parse and store fend data in h5dict.

Parameters:
  • filename (str.) – A file name to read restriction fragment data from. The file may be a ‘mat’ file compatible with HiCPipe, or a BED file containing RE fragment boundaries or cutsites.
  • genome_name (str.) – The name of the species and build. Optional.
  • re_name (str.) – The name of the restriction enzyme used to produce the fragment set. Optional.
  • format (str.) – Format of the input file. If not specified, it will be inferred from the file extension. Optional.
Returns:

None

Attributes:
  • chromosomes (ndarray) - A numpy array containing chromosome names as strings. The position of the chromosome name in this array is referred to as the chromosome index.
  • fends (ndarray) - A numpy array of length N where N is the number of fends and containing the fields ‘chr’, ‘start’, ‘stop’, and ‘mid’. All of these are of type int32. The ‘chr’ field contains the index of the chromosome. If the bed file or fend file used to create the Fend object contains additional columns, these features are also included as fields with names corresponding to the header names. These additional fields are of type float32. If produced from a bed file, fends are sorted by chromosome (the order in the ‘chromosomes’ array) and then by coordinates.
  • chr_indices (ndarray) - A numpy array with a length of the number of chromosomes in ‘chromosomes’ + 1. This array contains the first position in ‘fragments’ for the chromosome in the corresponding position in the ‘chromosomes’ array. The last position in the array contains the total number of fragments.
  • genome_name (str.) - A string (or None if not passed as argument) of the genome from which the fends originated.
  • re_name (str.) - A string (or None if not passed as argument) of the restriction enzyme used to produce the fends.
save()

Save fend data to h5dict.

Returns:None