trviz.visualizer
Module Contents
Classes
- class trviz.visualizer.TandemRepeatVisualizer
- static encode_tr_sequence(labeled_motifs)
- static _get_unique_labels(aligned_repeats)
- static plot_motif_color_map(symbol_to_motif, motif_counter, symbol_to_color, file_name, figure_size=None, box_size=1, box_margin=0.1, label_size=None, dpi=300)
Generate a plot for motif color map
- trplot(aligned_labeled_repeats: List[str], sample_ids: List[str], figure_size: Tuple[int, int] = None, output_name: str = None, dpi: int = 300, alpha: float = 0.6, box_line_width: float = 0, hide_xticks: bool = False, hide_yticks: bool = False, symbol_to_motif: Dict[str, str] = None, sort_by_clustering: bool = True, hide_dendrogram: bool = True, population_data: str = None, motif_marks: Dict[str, str] = None, allele_as_row: bool = True, xlabel_size: int = 8, ylabel_size: int = 8, xlabel_rotation: int = 0, ylabel_rotation: int = 0, private_motif_color: str = 'black', frame_on: Dict[str, bool] = None, debug: bool = False)
Generate a plot showing the variations in tandem repeat sequences. A distinct color is assigned to each motif. For private motifs (with low frequency), the same color (in black by default) may be assigned.
- Parameters
aligned_labeled_repeats – aligned and encoded tandem repeat sequences.
sample_ids – sample IDs
figure_size – figure size
output_name – output file name
dpi – DPI for the plot
alpha – alpha value for the plot
box_line_width – line width for box edges
hide_xticks – if true, hide xticks
hide_yticks – if true, hide yticks
symbol_to_motif – a dictionary mapping symbols to motifs
sort_by_clustering – if true, sort the samples by clustering
motif_marks – a dictionary mapping sample to motif marks
hide_dendrogram – if true, hide the dendrogram
population_data – population data file name
motif_marks – a dictionary mapping sample to motif marks
allele_as_row – if true, plot allele as row (default is true)
xlabel_size – x label size (default is 8)
ylabel_size – y label size (default is 8)
xlabel_rotation – x label rotation (default is 0)
ylabel_rotation – y label rotation (default is 0)
private_motif_color – the color for private motifs. Default is black
frame_on – a dictionary mapping sample to frame on. Default is {‘top’: False, ‘bottom’: True, ‘right’: False, ‘left’: True}
debug – if true, print verbose information.
- add_dendrogram(fig, aligned_labeled_repeats, sample_ids, symbol_to_motif, hide_clustering)
Add dendrogram to the figure.
- figmatplotlib.figure.Figure
Figure to add dendrogram to.
- aligned_labeled_repeatslist of list of str
List of aligned labeled repeats.
- sample_idslist of str
List of sample ids.
- symbol_to_motifdict of str to str
Dictionary mapping symbols to motifs.
- hide_clusteringbool
Whether to hide clustering.
- sorted_sample_idslist of str
List of sorted sample ids.
- sorted_aligned_labeled_repeatslist of list of str
List of sorted aligned labeled repeats.
- static get_symbol_to_color_map(alpha, unique_symbol_count, unique_symbols)
- set_symbol_to_color_map(symbol_to_color)
- get_population_colormap(population_data)
Allowed super populations: {AMR, AFR, EAS, SAS, EUR}