grelu.io.motifs#

Functions related to reading and writing MEME files

Functions#

read_meme_file(→ Dict[str, numpy.ndarray])

Read a motif database in MEME format

read_modisco_report(→ Dict[str, numpy.ndarray])

Reads motifs discovered by TF-MoDISco

Module Contents#

grelu.io.motifs.read_meme_file(file: str, names: List[str] | None = None, n_motifs: int | None = None) Dict[str, numpy.ndarray][source]#

Read a motif database in MEME format

Parameters:
  • file – The path to the MEME file

  • names – List of motif names to read

  • n_motifs – Number of motifs to read

Returns:

a dictionary in which the keys are motif names and the values are the motif position probability matrices (PPMs) as numpy arrays of shape (4, L).

grelu.io.motifs.read_modisco_report(h5_file: str, group: str | None = None, names: List[str] | None = None, trim_threshold: float = 0.3) Dict[str, numpy.ndarray][source]#

Reads motifs discovered by TF-MoDISco

Parameters:
  • h5_file – Path to an h5 file containing modisco output

  • group – One of “pos” for positive motifs, “neg” for negative motifs or None for all motifs.

  • names – A list containing names of motifs to read. Overrides ‘group’.

  • trim_threshold – A threshold value between 0 and 1 used for trimming the PPMs. Each PPM will be trimmed from both ends until the first position for which the probability for any base is greater than or equal to trim_threshold. trim_threshold = 0 will result in no trimming.

Returns:

A list of motifs as pymemesuite.common.Motif objects

Return type:

motifs