tfmindi.load_motif_collection#
- tfmindi.load_motif_collection(motif_dir=None, motif_file=None, motif_names=None, motif_file_format='cbust', motif_file_extension='.cb')#
Load motif collection from directory of .cb files.
Converts motif PWM matrices to PPM (position probability matrix) format.
- Parameters:
motif_dir (
str|None(default:None)) – Directory path containing motif files (either motif_dir or motif_file has to be provided).motif_file (
str|TextIOWrapper|None(default:None)) – File containing motifs (either motif_dir or motif_file has to be provided).motif_names (
list[str] |None(default:None)) – Optional list of specific motif names to load. If None, loads all motifs.motif_file_format (
Literal['cbust','meme'] (default:'cbust')) – Motif file format, supported formats are cbust and meme.motif_file_extension (
str|None(default:'.cb')) – File extenstion used to glob all motifs in case motif_dir is used.
- Return type:
- 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']