The FiveCData class

A class for handling 5C read data.

class hifive.fivec_data.FiveCData(filename, mode='r', silent=False)

This class handles interaction count data for 5C experiments.

The FiveCData class contains all of the interaction information for a 5C experiment, including pairs of fragment indices and their associated counts.

Note

This class is also available as hifive.FiveCData

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:

FiveCData 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 outcomes.
load()

Load 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_data_from_bam(fragfilename, filelist)

Read interaction counts from pairs of BAM files and place in h5dict.

Parameters:
  • fragfilename (str.) – This specifies the file name of the Fragment object to associate with the dataset.
  • filelist (list) – A list containing lists of paired read end files.
Returns:

None

Attributes:
  • fragfilename (str.) - A string containing the relative path of the fragment file.
  • cis_data (ndarray) - A numpy array of type int32 and shape N x 3 where N is the number of valid non-zero intra-regional fragment pairings observed in the data. The first column contains the fragment index (from the ‘fragments’ array in the Fragment object) of the upstream fragment, the second column contains the idnex of the downstream fragment, and the third column contains the number of reads observed for that fragment pair.
  • cis_indices (ndarray) - A numpy array of type int64 and a length of the number of fragments + 1. Each position contains the first entry for the correspondingly-indexed fragment in the first column of ‘cis_data’. For example, all of the downstream cis interactions for the fragment at index 5 in the Fragment object ‘fragments’ array are in cis_data[cis_indices[5]:cis_indices[6], :].
  • trans_data (ndarray) - A numpy array of type int32 and shape N x 3 where N is the number of valid non-zero inter-regional fragment pairings observed in the data. The first column contains the fragment index (from the ‘fragments’ array in the Fragment object) of the upstream fragment (upstream also refers to the lower indexed chromosome in this context), the second column contains the idnex of the downstream fragment, and the third column contains the number of reads observed for that fragment pair.
  • trans_indices (ndarray) - A numpy array of type int64 and a length of the number of fragments + 1. Each position contains the first entry for the correspondingly-indexed fragment in the first column of ‘trans_data’. For example, all of the downstream trans interactions for the fragment at index 5 in the Fragment object ‘fragments’ array are in cis_data[cis_indices[5]:cis_indices[6], :].
  • frags (filestream) - A filestream to the hdf5 Fragment file such that all saved Fragment attributes can be accessed through this class attribute.

When data is loaded the ‘history’ attribute is updated to include the history of the Fragment file that becomes associated with it.

load_data_from_counts(fragfilename, filelist)

Read interaction counts from a text file(s) and place in h5dict.

Parameters:
  • fragfilename (str.) – This specifies the file name of the Fragment object to associate with the dataset.
  • filelist (list) – A list containing all of the file names of counts text files to be included in the dataset. If only one file is needed, this may be passed as a string.
Returns:

None

Attributes:
  • fragfilename (str.) - A string containing the relative path of the fragment file.
  • cis_data (ndarray) - A numpy array of type int32 and shape N x 3 where N is the number of valid non-zero intra-regional fragment pairings observed in the data. The first column contains the fragment index (from the ‘fragments’ array in the Fragment object) of the upstream fragment, the second column contains the idnex of the downstream fragment, and the third column contains the number of reads observed for that fragment pair.
  • cis_indices (ndarray) - A numpy array of type int64 and a length of the number of fragments + 1. Each position contains the first entry for the correspondingly-indexed fragment in the first column of ‘cis_data’. For example, all of the downstream cis interactions for the fragment at index 5 in the Fragment object ‘fragments’ array are in cis_data[cis_indices[5]:cis_indices[6], :].
  • trans_data (ndarray) - A numpy array of type int32 and shape N x 3 where N is the number of valid non-zero inter-regional fragment pairings observed in the data. The first column contains the fragment index (from the ‘fragments’ array in the Fragment object) of the upstream fragment (upstream also refers to the lower indexed chromosome in this context), the second column contains the index of the downstream fragment, and the third column contains the number of reads observed for that fragment pair.
  • trans_indices (ndarray) - A numpy array of type int64 and a length of the number of fragments + 1. Each position contains the first entry for the correspondingly-indexed fragment in the first column of ‘trans_data’. For example, all of the downstream trans interactions for the fragment at index 5 in the Fragment object ‘fragments’ array are in cis_data[cis_indices[5]:cis_indices[6], :].
  • frags (ndarray) - A filestream to the hdf5 Fragment file such that all saved Fragment attributes can be accessed through this class attribute.

When data is loaded the ‘history’ attribute is updated to include the history of the Fragment file that becomes associated with it.

save()

Save analysis parameters to h5dict.

Returns:None