Takes z-scores from differential expression analysis, computes one-sided p-values, applies FDR correction, and binarizes based on a cutoff. This is the core logic extracted from run_fastTopics().

compute_topic_pvalues(
  z_matrix,
  fdr_cutoff = 0.05,
  total_bins = ceiling(3e+09/500)
)

Arguments

z_matrix

A matrix of z-scores (peaks x topics) from DE analysis.

fdr_cutoff

FDR threshold for significance (default: 0.05).

total_bins

Total number of hypothetical bins for FDR correction (default: ceiling(3e9 / 500), i.e., genome-wide bins).

Value

A list with:

pvals

One-sided p-value matrix (peaks x topics)

qvals

FDR-adjusted p-value matrix

p_jk

Binary matrix (1 = significant peak-topic pair)

n_sig_per_topic

Named vector of significant peaks per topic