Visualization Module
This module provides visualization tools for genomic analysis, including genome-wide symbol frequency plots, skew diagrams for replication origin estimation, and motif logos to represent conservation across aligned DNA motifs.
Symbol array
- GenomeVisualizer.visualization.plot_symbol_array(symbol_array: dict[int, int], symbol: str, genome_label: str = 'genome') None[source]
Plots the symbol frequency array across the genome.
This function visualizes the number of occurrences of a specified nucleotide in a sliding window (typically of size genome_length/2), showing variation in composition across the genome.
- Parameters:
symbol_array (dict[int, int]) – Dictionary mapping genome positions to the count of a symbol in the sliding window.
symbol (str) – The nucleotide symbol (‘A’, ‘C’, ‘G’, or ‘T’) used for counting.
genome_label (str, optional) – Label for the genome, used in the figure title. Default is “genome”.
- Returns:
The function displays the plot using matplotlib.
- Return type:
None
Example
>>> arr = FasterSymbolArray(genome, 'C') >>> plot_symbol_array(arr, 'C', genome_label="E. coli")
Skew array
- GenomeVisualizer.visualization.plot_skew_array_with_ori(skew: list[int], ori_positions: list[int], genome_label: str = 'genome') None[source]
Plots the skew array and highlights the estimated origin(s) of replication.
- Parameters:
skew (list[int]) – Skew values computed across the genome.
ori_positions (list[int]) – Positions where the skew reaches its minimum (possible ori sites).
genome_label (str, optional) – Name of the genome to show in the title. Default is “genome”.
- Returns:
The function displays the plot using matplotlib.
- Return type:
None
Example
>>> skew = SkewArray(genome) >>> ori_pos = MinimumSkew(genome) >>> plot_skew_array_with_ori(skew, ori_pos, genome_label="E. coli")
Motif Logo
- GenomeVisualizer.visualization.plot_motiflogo(motifs: list[str]) None[source]
Plots a motif logo based on information content using Shannon entropy.
This function generates a sequence logo from a list of motifs, where each letter’s height is proportional to its information content in bits. Highly conserved positions produce taller symbols.
- Parameters:
motifs (list[str]) – A list of DNA strings (motifs) of equal length.
- Returns:
Displays a motif logo plot using matplotlib.
- Return type:
None
Example
>>> plot_motiflogo(["ATG", "ACG", "AAG", "AGG", "ATG"])