crested.tl.modisco.process_patterns

crested.tl.modisco.process_patterns#

crested.tl.modisco.process_patterns(matched_files, sim_threshold=6.0, trim_ic_threshold=0.025, discard_ic_threshold=0.1, clustering=None, linkage_method='average', sort_by='n_seqlets', representative='n_seqlets', verbose=False)#

Process genomic patterns from matched HDF5 files, trim based on information content, and match to known patterns.

Parameters:
  • matched_files (dict[str, str | list[str] | None]) – dictionary with class names as keys and paths to HDF5 files as values.

  • sim_threshold (float (default: 6.0)) – Similarity threshold (-log10(pval) from TOMTOM, memesuite-lite) for grouping patterns into a cluster.

  • trim_ic_threshold (float (default: 0.025)) – Information content threshold for trimming patterns.

  • discard_ic_threshold (float (default: 0.1)) – Information content threshold for discarding patterns.

  • clustering (str | None (default: None)) – How to group patterns across cell types into clusters. "agglomerative" (the default) computes the full pairwise similarity once and runs deterministic, order-independent hierarchical clustering (see linkage_method) with a single cut at sim_threshold — same output structure, reproducible regardless of input order. "greedy" is the original order-dependent leader clustering (assign each pattern to the best existing cluster above sim_threshold, else start a new one) followed by a post-hoc all-vs-all merge; use it to reproduce analyses run before the default changed. If left unset (None), defaults to "agglomerative" and emits a warning noting the changed default.

  • linkage_method (str (default: 'average')) – Linkage for clustering="agglomerative" (any scipy.cluster.hierarchy.linkage method, e.g. "average", "complete", "single"). Ignored for greedy. "average" (default) controls chaining better than single linkage.

  • sort_by (str | None (default: 'n_seqlets')) – How to order the returned clusters (and their string keys, "0", "1", …). "n_seqlets" (default) sorts by descending total seqlet count summed over a cluster’s classes, so "0" is the most-supported cluster. "ic" sorts by descending cluster information content. None keeps the internal insertion/merge order. Applied to both clustering methods.

  • representative (str (default: 'n_seqlets')) – Which member instance to use as a cluster’s representative motif (the logo shown and the PPM matched against the motif database for TF assignment). "n_seqlets" (default) picks the most-supported instance (most seqlets) — robust, since it can’t be dragged to a single noisy long outlier. "ic_total" picks the most complete motif by summed per-position IC (= mean IC x length); fuller motif, more TOMTOM columns, but noisier on ragged/over-merged clusters. "ic_mean" is the legacy mean per-position IC (favours short, tight motifs); use it only to reproduce pre-change runs. Agglomerative clustering only (greedy derives its representative during matching).

  • verbose (bool (default: False)) – Flag to enable verbose output.

Return type:

dict[str, dict[str, str | list[float]]]

Returns:

All processed patterns with metadata.