plotting - plotting utilities#
Utilities for plotting.
- bulkdgd.plotting.plots.plot_representations_time(df: DataFrame, output_file: str | None = None, config: dict[str, object] | None = None, **kwargs: dict[str, object] | None) None#
Plot the CPU/wall clock time spent in each epoch of each round of optimization when finding the representations for a set of samples (both for the full epoch and for the backward step performed in each epoch).
- Parameters:
- df
pandas.DataFrame A data frame containing the time data. This data frame is produced as an output by the
bulkdgd.core.model.BulkDGD.get_representationsmethod.- output_file
str, optional The file where the plot will be saved. If not provided, the plot will be generated but not saved.
- config
dict, optional A dictionary containing the configuration for the plot’s aesthetics.
Alternatively, the options for the plot’s aesthetics can be provided using keyword arguments.
The available options can be found in the documentation.
If no configuration is provided, the default configuration (taken from the
configs/plotting/lineplot.yamlfile) will be used.- **kwargs
Additional keyword arguments representing options for the plot’s aesthetics.
The available options can be found in the documentation.
- df
- bulkdgd.plotting.plots.plot_dimensionality_reduction(dfs: list[DataFrame], output_file: str | None = None, config: dict[str, object] | None = None, max_plots_per_output: int = 9, columns: list[str] = ['C1', 'C2'], groups_column: str | None = None, groups: list[str] | None = None, plot_other_groups: bool = False, dfs_names: list[str] | None = None, **kwargs: dict[str, object] | None) None#
Plot the results of one or several dimensionality reduction analyses on a single figure (which may be split in multiple output files).
- Parameters:
- dfs
pandas.DataFrame A list of data frames containing the results of the dimensionality reduction analyses.
The rows of each data frame should contain the data points, while the columns should contain the values of each data point’s projection along the principal components.
- output_file
str, optional The file where the plot will be saved. If not provided, the plot will be generated but not saved.
- config
dict, optional A dictionary containing the configuration for the plot’s aesthetics.
Alternatively, the options for the plot’s aesthetics can be provided using keyword arguments.
The available options can be found in the documentation.
If no configuration is provided, the default configuration (taken from the
configs/plotting/scatterplot.yamlfile) will be used.- max_plots_per_output
int,9 The maximum number of plots for each output file.
- columns
list,["PC1", "PC2"] A list with the names of the two columns in each data frame that contain the values of the two dimensions of the projection’s space to be considered when plotting.
- groups_column
str, optional The name of the column containing the labels of different groups of data points in the data frames, if any.
If provided, the data points will be colored according to the group they belong.
If not provided, the data points will be assumed to belong to one group.
- groups
list, optional A list of groups of interest.
If a list of groups is provided and
plot_other_groupsisFalse, only data points belonging to the groups of interest will be plotted.If
plot_other_groupsisTrue, the other groups will be plotted according to the aesthetic specifications provided in the configuration.- plot_other_groups
bool,False If a list of
groupsof interest if provided, set whether to plot data points belonging to the other groups according to the aesthetic specifications provided in the configuration (True) or not to plot the data points belonging to the other groups at all (False).- dfs_names
list, optional A list of names for the data frames passed. These names, if passed, will be used as the titles of the corresponding plots.
- **kwargs
Additional keyword arguments representing options for the plot’s aesthetics.
The available options can be found in the documentation.
- dfs
- bulkdgd.plotting.plots.plot_enrichment_scores(df: DataFrame, groups_column: str, gene_set: str, gene_set_column: str = 'gene_set', num_genes_in_set_column: str = 'num_genes_in_set', num_genes_significant_column: str = 'num_genes_significant', e_score_column: str = 'e_score', groups: list[str] | None = None, config: dict[str, object] | None = None, output_file: str | None = None, **kwargs: dict[str, object] | None) None#
Plot the enrichment scores for sets of samples belonging to different groups.
- Parameters:
- df
pandas.DataFrame A data frame containing the enrichment scores.
- groups_column
str The name of the column containing the labels of different groups in the data frame.
- gene_set
str The name of the gene set for which the enrichment scores will be plotted.
- gene_set_column
str,"gene_set" The name of the column containing the labels of the gene sets in the data frame.
- num_genes_in_set_column
str,"num_genes_in_set" The name of the column containing the number of genes in each gene set in the data frame.
- num_genes_significant_column
str,"num_genes_significant" The name of the column containing the number of significant genes in the data frame.
- e_score_column
str,"e_score" The name of the column containing the enrichment scores in the data frame.
- groups
list, optional A list of groups of interest.
If a list of groups is provided, only the enrichment scores of the samples belonging to the groups of interest will be plotted.
If not provided, the enrichment scores of all the samples will be plotted.
- config
dict, optional A dictionary containing the configuration for the plot’s aesthetics.
Alternatively, the options for the plot’s aesthetics can be provided using keyword arguments.
The available options can be found in the documentation.
- output_file
str, optional The file where the plot will be saved.
- **kwargs
Additional keyword arguments representing options for the plot’s aesthetics.
The available options can be found in the documentation.
- df
- bulkdgd.plotting.plots.plot_rvalues(dfs: list[DataFrame] | DataFrame, genes: list[str], output_file: str | None = None, plot_type: str = 'histogram', config: dict[str, object] | None = None, max_plots_per_output: int = 9, categories: list[str] | None = None, **kwargs: dict[str, object] | None) None#
Plot the distribution of r-values for specific genes for one set of samples or two paired sets of samples (for instance, normal samples and cancer samples for the same tissue).
- Parameters:
- dfs
listorpandas.DataFrame One or two data frames containing the r-values values for one or two sets of samples.
The rows should contain the samples, while the columns should contain the r-values of the negative binomial distributions modeling the genes.
- genes
list A list of the names of the genes for which the r-values will be plotted.
- output_file
str, optional The file(s) where the plot(s) will be saved.
If multiple files need to be generated, the output file name will be constructed by appending a number to the name provided.
The format of the output file is inferred from its extension.
If not provided, the plot(s) will be generated but not saved.
- plot_type
str, {"histogram","histogram_dual,"histogram_overlap","boxplot","violinplot"},"histogram" The type of plot to generate. The available options are:
"histogram": histograms of the r-values of the genes of interest for one set of samples."histogram_bihist": bi-histograms showing the distributions of r-values of the genes of interest for two paired sets of samples."histogram_overlap": two overlapping histograms showing the distribution of r-values of the genes of interest for two paired sets of samples."boxplot": box plots showing the distributions of r-values of the genes of interest in either a set of samples or in two paired sets of samples (paired box plots)."violinplot": violin plots showing the distributions of r-values of the genes of interest in either a set of samples or in two paired sets of samples (paired violin plots).
- config
dict, optional A dictionary containing the configuration for the plot’s aesthetics.
Alternatively, the options for the plot’s aesthetics can be provided using keyword arguments.
The available options can be found in the documentation.
- max_plots_per_output
int,9 The maximum number of plots for each output file.
- categories
list, optional A list of two categories used when generating dual histograms or paired box plots or violin plots.
If provided, they are used to generate the legend of the plot.
- **kwargs
Additional keyword arguments representing options for the plot’s aesthetics.
The available options can be found in the documentation.
- dfs