hic3defdr.analysis.core module¶
-
class
hic3defdr.analysis.core.
CoreHiC3DeFDR
[source]¶ Bases:
object
Mixin class providing core saving and loading functionality for HiC3DeFDR.
-
get_matrix
(name, chrom, row_slice, col_slice, rep=None, cond=None)[source]¶ Loads data with
name
as a dense matrix specified bychrom, row_slice, col_slice
.Parameters: - name (str) – The name (stage) of the data to load. Add a special suffix ‘_mean’ to average per-rep stages within condtiions.
- chrom (str) – The chromosome to select data from.
- col_slice (row_slice,) – Row and column slice to use, respectively.
- cond (rep,) – Pass the rep name or condition name if the data specified by
name
has multiple columns.
Returns: The selected dense matrix.
Return type: np.ndarray
-
classmethod
load
(outdir)[source]¶ Loads a HiC3DeFDR analysis object from disk.
It is safe to have multiple instances of the same analysis open at once.
Parameters: outdir (str) – Folder path to where the HiC3DeFDR was saved. Returns: The loaded object. Return type: HiC3DeFDR
-
load_bias
(chrom)[source]¶ Loads the bias matrix for one chromosome.
The rows of the bias matrix correspond to bin indices along the chromosome. The columns correspond to the replicates.
The bias factors for bins that fail
bias_thresh
are set to zero. This is designed so that all pixels in these bins get dropped during union pixel set computation.Parameters: chrom (str) – The name of the chromosome to load the bias matrix for. Returns: The bias matrix. Return type: np.ndarray
-
load_data
(name, chrom=None, idx=None, rep=None, cond=None, coo=False)[source]¶ Loads arbitrary data for one chromosome or all chromosomes.
Parameters: - name (str) – The name of the data to load.
- chrom (str, optional) – The name of the chromosome to load data for. Pass None if this data is not organized by chromosome. Pass ‘all’ to load data for all chromosomes.
- idx (np.ndarray or tuple of np.ndarray, optional) – Pass a boolean array to load only a subset of the data. Pass a tuple of exactly two boolean arrays to chain the indices.
- rep (str, optional) – If the data is a (pixels, reps) rectangular array, pass the name of a rep to get a (pixels,) vector of data for just that rep.
- cond (str, optional) – If the data is a (pixels, conds) rectangular array, pass the name of a condition to get a (pixels,) vector of data for just that condition.
- coo (bool) – Pass True to return a COO-format
(row, col, data)
tuple ofnp.ndarray
.chrom
cannot be ‘all’, andidx
must be None (this function will handle filtering automatically).
Returns: data or (concatenated_data, offsets) or (row, col, data) – The loaded data for one chromosome, or a tuple of the concatenated data and an array of offsets per chromosome.
offsets
satisfies the following properties:offsets[0] == 0
,offsets[-1] == concatenated_data.shape[0]
, andconcatenated_data[offsets[i]:offsets[i+1], :]
contains the data for thei``th chromosome. If called with ``coo=True
, this function returns a COO-format(row, col, data)
tuple ofnp.ndarray
.Return type: np.ndarray
-
load_disp_fn
(cond)[source]¶ Loads the fitted dispersion function for a specific condition from disk.
Parameters: cond (str) – The condition to load the dispersion function for. Returns: Vectorized. Takes in the value of the covariate the dispersion was fitted against and returns the appropriate dispersion. Return type: function
-
picklefile
¶
-
save_data
(data, name, chrom=None)[source]¶ Saves arbitrary data for one chromosome to disk.
Parameters: - data (np.ndarray) – The data to save.
- name (str) – The name of the data to save.
- chrom (str or np.ndarray, optional) – The name of the chromosome to save data for, or None if this data is not organized by chromosome. Pass an np.ndarray of offsets to save data for all chromosomes.
-