netmap.downstream.gene_clustering.compute_regression

netmap.downstream.gene_clustering.compute_regression(df, cophenet_threshold, dist_linkage, correlation_threshold=0.6, quantile=0.1)[source]

Fit a quantile regression to determine an automatic dendrogram cut distance.

Filters the cophenetic/correlation scatter to rows below cophenet_threshold, fits a quantile regression line at quantile, and solves for the cophenet value at which the fitted line crosses correlation_threshold. Calls plot_regression_and_dendrogram() for visual validation.

Parameters:
  • df (pd.DataFrame) – DataFrame with columns 'cophenet' and 'corr' as returned by get_hierarchical_clustering().

  • cophenet_threshold (float) – Upper bound on cophenet distance used to restrict the regression fit to a linear region of the scatter.

  • dist_linkage – Linkage matrix passed through to plot_regression_and_dendrogram() for dendrogram rendering.

  • correlation_threshold (float) – Pearson correlation value at which the automatic cut distance is resolved. Defaults to 0.6.

  • quantile (float) – Quantile for the regression fit (0–1). Defaults to 0.1 (10th percentile).

Returns:

The computed cutoff distance, or None if the regression slope is zero (degenerate fit).

Return type:

float or None