tfmindi.load_motif_collection

tfmindi.load_motif_collection#

tfmindi.load_motif_collection(motif_dir, motif_names=None)#

Load motif collection from directory of .cb files.

Converts motif PWM matrices to PPM (position probability matrix) format.

Parameters:
  • motif_dir (str) – Directory path containing .cb motif files

  • motif_names (list[str] | None (default: None)) – Optional list of specific motif names to load. If None, loads all motifs.

Return type:

dict[tuple[str, str], ndarray]

Returns:

dict[tuple[str, str], np.ndarray] Dictionary mapping motif names to PWM matrices (4 x length)

Examples

>>> motifs = load_motif_collection("./motif_collection/")
>>> print(list(motifs.keys()))
[("filename_1", "motif_1"), ("filename_1", "motif_2"), ("filename_1", "motif_4")]
>>> print(motifs[("filename_1", "motif_1")].shape)
(4, 12)
>>> # Load only specific motifs
>>> selected_motifs = load_motif_collection("./motif_collection/", ["motif1", "motif2"])
>>> print(list(selected_motifs.keys()))
['motif1', 'motif2']