lib5c.algorithms.trimming module

Module for trimming low or “dead” 5C fragments away from 5C datasets.

lib5c.algorithms.trimming.trim_counts(counts, indices)[source]

Removes specified rows and columns from the counts matrix.

Parameters:
  • counts (np.ndarray) – The square symmetric counts matrix to trim.
  • indices (Iterable[int]) – The indices to wipe
Returns:

The trimmed counts matrix.

Return type:

np.ndarray

lib5c.algorithms.trimming.trim_counts_superdict(counts_superdict, indices)[source]

Applies trim_counts() to each replicate in a counts_superdict.

Parameters:
  • counts_superdict (Dict[str, np.ndarray]) – The keys are replicate names, the values are the counts for that rep.
  • indices (Iterable[int]) – The indices to trim.
Returns:

The keys are replicate names, the values are the trimmed counts for that rep.

Return type:

Dict[str, np.ndarray]

lib5c.algorithms.trimming.trim_primers(primermap, counts_superdict, min_sum=100.0, min_frac=0.5)[source]

Trim a primermap using counts information from many replicates.

Parameters:
  • primermap (List[Dict[str, Any]]) – The primermap to trim. See lib5c.parsers.primers.get_primermap().
  • counts_superdict (Dict[str, np.ndarray]) – The keys are replicate names, the values are the counts for that rep.
  • min_sum (Optional[float]) – Primers with a total cis sum lower than this value will be trimmed.
  • min_frac (Optional[float]) – Primers with fewer than this fraction of nonzero interactions out of all their finite interactions will be trimmed.
Returns:

The first element is the trimmed primermap, the second is the set of indices of the original primermap which were removed.

Return type:

Tuple[List[Dict[str, Any]], Set[int]]

lib5c.algorithms.trimming.wipe_counts(counts, indices, wipe_value=nan)[source]

Wipes specified rows and columns of the counts matrix with a specified value.

Parameters:
  • counts (np.ndarray) – The square symmetric counts matrix to wipe.
  • indices (Iterable[int]) – The indices of the rows and columns to wipe.
  • wipe_value (Optional[float]) – The value to wipe the selected indices with.
Returns:

The wiped counts matrix.

Return type:

np.ndarray

lib5c.algorithms.trimming.wipe_counts_superdict(counts_superdict, indices, wipe_value=nan)[source]

Applies wipe_counts() to each replicate in a counts_superdict.

Parameters:
  • counts_superdict (Dict[str, np.ndarray]) – The keys are replicate names, the values are the counts for that rep.
  • indices (Iterable[int]) – The indices to wipe
  • wipe_value (Optional[float]) – The value to wipe the selected indices with.
Returns:

The keys are replicate names, the values are the wiped counts for that rep.

Return type:

Dict[str, np.ndarray]