buscoplotpy.graphics package
Submodules
buscoplotpy.graphics.chromoplot module
buscoplotpy.graphics.chromosome module
- class buscoplotpy.graphics.chromosome.Chromosome(name: str, x_start: float, x_end: float, y_start: float, y_end: float, size: float, horizontal: bool = True, round_edges: bool = False, color: str = '', genes_dataframe: DataFrame = None)
Bases:
object- add_gene_density(genes_dataframe: DataFrame) None
Adds gene density to the Chromosome.
- Parameters:
genes_dataframe (pd.DataFrame): The dataframe containing the gene density information.
- add_label(x: float, y: float, text: str, rotation: float = 0, ha: str = 'left', va: str = 'baseline')
Add a label to the plot at the specified coordinates.
- Parameters:
x (float): The x-coordinate of the label.
y (float): The y-coordinate of the label.
text (str): The text of the label.
ha (str, optional): The horizontal alignment of the label. Defaults to ‘left’.
va (str, optional): The vertical alignment of the label. Defaults to ‘baseline’.
- add_region(anchor_point: (<class 'float'>, <class 'float'>), width: float, height: float, color: str = 'black', linewidth: int = 1)
Adds a region to the list of regions.
- Parameters:
anchor_point (Tuple[float, float]): The anchor point of the region.
width (float): The width of the region.
height (float): The height of the region.
color (str, optional): The color of the region. Defaults to ‘black’.
linewidth (int, optional): The linewidth of the region. Defaults to 1.
- get_relative_position(position: int) -> (<class 'float'>, <class 'float'>)
Returns the position relative to the start and end of the chromosome.
- Parameters:
position (int): The position to convert.
- Returns:
float: The position relative to the start and end of the chromosome.
- plot(fig, ax)
Plot the chromosome on the given axes.
- Parameters:
ax: The axes to plot on.
round_edges: A boolean indicating whether to round the edges of the chromosome.
- Returns:
None
buscoplotpy.graphics.karyoplot module
- buscoplotpy.graphics.karyoplot.karyoplot(karyotype: DataFrame, output_file: str = '', title: str = 'Karyoplot', fulltable: DataFrame = None, selected_sequences: list = [], dpi: int = 300, chrs_limit: int = 30, plt_show: bool = False, palette: False = 'green', bbox_inches: str = 'tight', dim: int = 2) None
Plot a karyotype based on the karyotype file and the BUSCO fulltable.
- Parameters:
karyotype (pd.DataFrame): The karyotype DataFrame.
output_file (str, optional): The path to save the output plot.
title (str, optional): The title of the plot.
fulltable (pd.DataFrame): The BUSCO’s full table DataFrame.
dpi (int, optional): The DPI (dots per inch) of the output plot. Default is 300.
chrs_limit (int, optional): The maximum number of chromosomes to plot. Default is 30.
plt_show (bool, optional): Whether to show the plot. Default is False.
palette (str, optional): The color palette to use. Default is ‘green’.
bbox_inches (str, optional): The bbox_inches parameter of the plt.savefig() function. Default is ‘tight’.
dim (int, optional): The dimension of the chromosomes. Defaults to 2.
- Output:
The karyotype plot in png format.
- Returns:
None
buscoplotpy.graphics.label module
buscoplotpy.graphics.link module
- class buscoplotpy.graphics.link.Link(C1: Chromosome, C2: Chromosome, p_1: int, p_2: int, color: str = '#d1d1d1', straight_line: bool = False, horizontal: bool = False)
Bases:
object- bezier_curve(t, p0, p1, p2, p3)
Calculate the Bezier curve at time t.
- Parameters:
t (float): The time parameter between 0 and 1.
p0 (float): The starting point of the curve.
p1 (float): The first control point.
p2 (float): The second control point.
p3 (float): The ending point of the curve.
- Returns:
float: The position on the Bezier curve at time t.
- plot(ax)
Plot the link on the given axes.
- Parameters:
ax (matplotlib.axes.Axes): The axes on which to plot the link.
buscoplotpy.graphics.organism_busco_barplot module
- buscoplotpy.graphics.organism_busco_barplot.organism_busco_barplot(df: DataFrame, group_name: str = '', organism_name: str = '', out_path: str = './', filename: str = 'busco_barplot', dpi: int = 300, plt_show: bool = False) None
Generate a barplot to visualize the completeness of assembly for different organisms on the same BUSCO dataset.
- Parameters:
df (pd.DataFrame): The input dataframe containing the data to be plotted.
group_name (str): The name of the group to be plotted.
organism_name (str): The name of the organism to be plotted.
out_path (str): The path where the plot image will be saved.
filename (str): The name of the plot image file.
- Output:
A barplot image with the completeness of assembly for different organisms on the same BUSCO dataset in .png format.
- Returns:
None
buscoplotpy.graphics.synteny module
- buscoplotpy.graphics.synteny.generate_bottom_karyotype(karyotype: DataFrame, dim: int, round_edges: bool) dict
Generate a bottom karyotype plot.
- Parameters:
karyotype (pd.DataFrame): DataFrame containing karyotype information.
dim (int): Dimension of the karyotype plot.
round_edges (bool): Whether to round the edges of the chromosomes.
- Returns:
dict: Dictionary containing the generated chromosomes.
- buscoplotpy.graphics.synteny.generate_left_karyotype(karyotype: DataFrame, dim: int, round_edges: bool) dict
Plot the left karyotype chromosomes.
- Parameters:
karyotype: pandas DataFrame containing information about the chromosomes
dim: dimension of the chromosomes
round_edges: flag indicating whether to round the edges of the chromosomes
- Returns:
C: A dictionary mapping chromosome names to their corresponding Chromosome objects.
- buscoplotpy.graphics.synteny.generate_links(ft_1: DataFrame, ft_2: DataFrame, right_chromosomes: dict, left_chromosomes: dict, link_colors: str, straight_line: bool, horizontal: bool) list
Generates and plots links between two data frames.
- Parameters:
ft_1 (pd.DataFrame): First full table data frame.
ft_2 (pd.DataFrame): Second full table data frame.
right_chromosomes (dict): Dictionary mapping sequence names to right chromosomes.
left_chromosomes (dict): Dictionary mapping sequence names to left chromosomes.
link_colors (str): Dictionary mapping sequence names to link colors.
straight_line (bool): Flag indicating whether to plot links as straight lines.
- Returns:
None
- buscoplotpy.graphics.synteny.generate_right_karyotype(karyotype: DataFrame, dim: int, round_edges: bool) dict
Plot the left karyotype chromosomes.
- Parameters:
karyotype: pandas DataFrame containing information about the chromosomes
dim: dimension of the chromosomes
round_edges: flag indicating whether to round the edges of the chromosomes
- Returns:
C: A dictionary mapping chromosome names to their corresponding Chromosome objects.
- buscoplotpy.graphics.synteny.generate_up_karyotype(karyotype: DataFrame, dim: int, round_edges: bool) dict
Generate an upward karyotype plot based on the given karyotype data.
- Parameters:
karyotype (pd.DataFrame): DataFrame containing karyotype information.
dim (int): Dimension of the karyotype plot.
round_edges (bool): Flag indicating whether to use rounded edges for the chromosomes.
- Returns:
dict: Dictionary containing the generated karyotype plot.
- buscoplotpy.graphics.synteny.horizontal_synteny_plot(ft_1: ~pandas.core.frame.DataFrame, ft_2: ~pandas.core.frame.DataFrame, karyotype_1: ~pandas.core.frame.DataFrame, karyotype_2: ~pandas.core.frame.DataFrame, title: str = 'Synteny plot', dim: int = 2, figsize: (<class 'int'>, <class 'int'>) = (30, 10), dpi: int = 300, round_edges: bool = False, link_colors: dict = {}, straight_line: bool = False, output_path: str = None, bbox_inches: str = 'tight', plt_show: bool = False)
Generate a horizontal synteny plot.
- Parameters:
ft_1 (pd.DataFrame): Full table for the left karyotype.
ft_2 (pd.DataFrame): Full table for the right karyotype.
karyotype_1 (pd.DataFrame): Karyotype dataframe for the left karyotype.
karyotype_2 (pd.DataFrame): Karyotype dataframe for the right karyotype.
title (str, optional): The title of the plot. Defaults to ‘Synteny plot’.
dim (int, optional): The dimension of the chromosomes. Defaults to 2.
figsize (tuple, optional): The size of the plot figure. Defaults to (18, 10).
dpi (int, optional): The resolution of the plot figure. Defaults to 300.
round_edges (bool, optional): Whether to round the edges of the karyotype blocks. Defaults to False.
link_colors (dict, optional): A dictionary mapping link colors to chromosome pairs. Defaults to {}.
straight_line (bool, optional): Whether to use straight lines for links. Defaults to False.
output_path (str, optional): The path to save the output plot. Defaults to None.
plt_show (bool, optional): Whether to show the plot. Defaults to False.
- Returns:
None
- buscoplotpy.graphics.synteny.plot_chromosomes(chromosomes: dict, fig: Figure, ax: Axes) None
Plots the chromosomes on the given axes.
- Parameters:
chromosomes (dict): Dictionary mapping sequence names to Chromosome objects.
ax (plt.Axes): Matplotlib axes object to plot the chromosomes on.
- Returns:
None
- buscoplotpy.graphics.synteny.plot_links(links: list, ax: Axes) None
Plots the links on the given axes.
- Parameters:
links (list): List of Link objects.
ax (plt.Axes): Matplotlib axes object to plot the links on.
- Returns:
None
- buscoplotpy.graphics.synteny.vertical_synteny_plot(ft_1: DataFrame, ft_2: DataFrame, karyotype_1: DataFrame, karyotype_2: DataFrame, title: str = 'Synteny plot', dim: int = 2, figsize=(18, 10), dpi: int = 300, round_edges: bool = False, link_colors: dict = {}, straight_line: bool = False, output_path: str = None, bbox_inches: str = 'tight', plt_show: bool = False)
Generate a vertical synteny plot.
- Parameters:
ft_1 (pd.DataFrame): Full table for the left karyotype.
ft_2 (pd.DataFrame): Full table for the right karyotype.
karyotype_1 (pd.DataFrame): Karyotype dataframe for the left karyotype.
karyotype_2 (pd.DataFrame): Karyotype dataframe for the right karyotype.
title (str, optional): The title of the plot. Defaults to ‘Synteny plot’.
dim (int, optional): The dimension of the chromosomes. Defaults to 2.
figsize (tuple, optional): The size of the plot figure. Defaults to (18, 10).
dpi (int, optional): The resolution of the plot figure. Defaults to 300.
round_edges (bool, optional): Whether to round the edges of the karyotype blocks. Defaults to False.
link_colors (dict, optional): A dictionary mapping link colors to chromosome pairs. Defaults to {}.
straight_line (bool, optional): Whether to use straight lines for links. Defaults to False.
output_path (str, optional): The path to save the plot to. Defaults to None.
plt_show (bool, optional): Whether to show the plot. Defaults to False.
- Returns:
None