hic3defdr.util.evaluation module

hic3defdr.util.evaluation.compute_fdr(y_true, y_pred)[source]

Computes the observed false discovery rate from boolean vectors of true and predicted labels.

Parameters:y_pred (y_true,) – Boolean vectors of the true and predicted labels, respectively.
Returns:The false discovery rate.
Return type:float
hic3defdr.util.evaluation.evaluate(y_true, qvalues, n_fdr_points=100)[source]

Evaluates how good a vector of q-values (or p-values) is at predicting the vector of true labels.

Parameters:
  • y_true (np.ndarray) – The boolean vector of true labels.
  • qvalues (np.ndarray) – Vector of q-values or p-values which are supposed to predict the boolean label in y_true.
  • n_fdr_points (int) – The maximum number of points at which to compute FDR. The FDR computation is not parallelized so increasing this number will slow down the evaluation. The default value of 100 should be sufficient to visualize the FDR control curve.
Returns:

fdr, fpr, tpr, thresh – Parallel arrays of the FDR, FPR, TPR, and thresholds (in 1 - qvalue) space which specify the FDR, FPR, and and TPR at each threshold. The thresholds are selected to represent the convex edge of the ROC curve. The FDR will only be evaluated at about 100 selected thresholds and will be set to np.nan at the un-evaluated thresholds.

Return type:

np.ndarray

hic3defdr.util.evaluation.make_y_true(row, col, clusters, labels)[source]

Makes a boolean vector of the true labels for each pixel, given a list of clusters and the true label for each cluster.

Parameters:
  • col (row,) – The row and column indices of pixels to be labeled.
  • clusters (list of list of tuple) – The outer list is a list of clusters. Each cluster is a list of (i, j) tuples marking the position of significant points which belong to that cluster.
  • labels (list of str) – List of labels for each cluster, parallel to clusters.
Returns:

Boolean vector with the same length as row/col. It’s i`th element is False when the pixel at `(row[i], col[i]) is in a cluster with label ‘constit’ and is True otherwise.

Return type:

np.ndarray