tfcomb.plotting module
- tfcomb.plotting.bubble(rules_table, yaxis='confidence', size_by='TF1_TF2_support', color_by='lift', figsize=(7, 4), save=None)[source]
Plot bubble plot with TF1-TF2 pairs on the x-axis and a choice of measure on the y-axis, as well as color and size of bubbles.
- Parameters:
rules_table (pandas.DataFrame) – Dataframe containing data to plot.
yaxis (str, optional) – Column containing yaxis information. Default: “confidence”.
size_by (str) – Default: “TF1_TF2_support”.
color_by (str) – Default: None
figsize (tuple) – Default: (7,7).
save (str, optional) – Save the plot to the file given in ‘save’. Default: None.
- Return type:
ax
- tfcomb.plotting.heatmap(rules_table, columns='TF1', rows='TF2', color_by='cosine', figsize=(7, 7), save=None)[source]
Plot heatmap with TF1 and TF2 on rows and columns respectively. Heatmap colormap is chosen by .color_by.
- Parameters:
rules_table (pandas.DataFrame) – The <CombObj>.rules table calculated by market basket analysis
columns (str, optional) – The name of the column in rules_table to use as heatmap column names. Default: TF1.
rows (str, optional) – The name of the column in rules_table to use as heatmap row names. Default: TF2.
color_by (str, optional) – The name of the column in rules_table to use as heatmap colors. Default: “cosine”.
figsize (tuple) – The size of the output heatmap. Default: (7,7)
save (str) – Save the plot to the file given in ‘save’. Default: None.
- tfcomb.plotting.scatter(table, x, y, x_threshold=None, y_threshold=None, label=None, label_fontsize=9, label_color='red', title=None, save=None, **kwargs)[source]
Plot scatter-plot of x/y values within table. Can also set thresholds and label values within plot.
- Parameters:
table (pd.DataFrame) – A table containing columns of ‘measure’ and ‘pvalue’.
x (str) – Name of column in table containing values to map on the x-axis.
y (str) – Name of column in table containing values to map on the y-axis.
x_threshold (float, tuple of floats or None, optional) – Gives the option to visualize an x-axis threshold within plot. If None, no measure threshold is set. Default: None.
y_threshold (float, tuple of floats or None, optional) – Gives the option to visualize an y-axis threshold within plot. If None, no measure threshold is set. Default: None.
label (str or list, optional) – If None, no point labels are plotted. If “selection”, the . Default: None.
label_fontsize (float, optional) – Size of labels. Default: 9.
label_color (str, optional) – Color of labels. Default: ‘red’.
title (str, optional) – Title of plot. Default: None.
kwargs (arguments) – Any additional arguments are passed to sns.jointplot.
- tfcomb.plotting.go_bubble(table, aspect='MF', n_terms=20, threshold=0.05, save=None)[source]
Plot a bubble-style plot of GO-enrichment results.
- Parameters:
table (pandas.DataFrame) – The output of tfcomb.analysis.go_enrichment.
aspect (str) – One of [“MF”, “BP”, “CC”]
n_terms (int) – Maximum number of terms to show in graph. Default: 20
threshold (float between 0-1) – The p-value-threshold to show in plot.
save (str, optional) – Save the plot to the file given in ‘save’. Default: None.
- Return type:
ax
- tfcomb.plotting.network(network, color_node_by=None, color_edge_by=None, size_node_by=None, size_edge_by=None, engine='sfdp', size='8,8', min_edge_size=2, max_edge_size=8, min_node_size=14, max_node_size=20, legend_size='auto', node_border=False, node_cmap=None, edge_cmap=None, node_attributes={}, save=None, verbosity=1)[source]
Plot network of a networkx object using Graphviz for python.
- Parameters:
network (networkx.Graph) – A networkx Graph/DiGraph object containing the network to plot.
color_node_by (str, optional) – The name of a node attribute
color_edge_by (str, optional) – The name of an edge attribute
size_node_by (str, optional) – The name of a node attribute
size_edge_by (str, optional) – The name of an edge attribute
engine (str, optional) – The graphviz engine to use for finding network layout. Default: “sfdp”.
size (str, optional) – Size of the output figure. Default: “8,8”.
min_edge_size (float, optional) – Default: 2.
max_edge_size (float, optional) – Default: 8.
min_node_size (float, optional) – Default: 14.
max_node_size (float, optional) – Default: 20.
legend_size (int, optional) – Fontsize for legend explaining color_node_by/color_edge_by/size_node_by/size_edge_by. Set to 0 to hide legend. Default: ‘auto’.
node_border (bool, optional) – Whether to plot border on nodes. Can be useful if the node colors are very light. Default: False.
node_cmap (str, optional) – Name of colormap for node coloring. Default: None (colors are automatically chosen).
edge_cmap (str, optional) – Name of colormap for edge coloring. Default: None (colors are automatically chosen).
node_attributes (dict, optional) – Additional node attributes to apply to graph. Default: No additional attributes.
save (str, optional) – Path to save network figure to. Format is inferred from the filename - if not valid, the default format is ‘.pdf’.
verbosity (int, optional) – verbosity of the logging. Default: 1.
- Raises:
TypeError – If network is not a networkx.Graph object
InputError – If any of ‘color_node_by’, ‘color_edge_by’ or ‘size_edge_by’ is not in node/edge attributes, or if ‘engine’ is not a valid graphviz engine.
- tfcomb.plotting.genome_view(TFBS, window_chrom=None, window_start=None, window_end=None, window=None, fasta=None, bigwigs=None, bigwigs_sharey=False, TFBS_track_height=4, title=None, highlight=None, save=None, figsize=None, verbosity=1)[source]
Plot TFBS in genome view via the ‘DnaFeaturesViewer’ package.
- Parameters:
TFBS (list) – A list of OneTFBS objects or any other object containing .chrom, .start, .end and .name variables.
window_chrom (str, optional if 'window' is given) – The chromosome of the window to show.
window_start (int, optional if 'window' is given) – The genomic coordinates for the start of the window.
window_end (int, optional if 'window' is given) – The genomic coordinates for the end of the window.
window (Object with .chr, .start, .end) – If window_chrom/window_start/window_end are not given, window can be given as an object containing .chrom, .start, .end variables
fasta (str, optional) – The path to a fasta file containing sequence information to show. Default: None.
bigwigs (str, list or dict of strings, optional) – Give the paths to bigwig signals to show within graph. Default: None.
bigwigs_sharey (bool or list, optional) – Whether bigwig signals should share y-axis range. If True, all signals will be shared. It is also possible to give a list of bigwig indices (starting at 0), which should share y-axis values, e.g. [0,1,3] for the 1st, 2nd and 4th bigwig to share signal. If list of lists, each lists correspond to a grouping, e.g. [[0,2], [1,3]]. Default: False.
TFBS_track_height (float, optional) – Relative track height of TFBS. Default: 4.
title (str, optional) – Title of plot. Default: None.
highlight (list, optional) – A list of OneTFBS objects or any other object containing .chrom, .start, .end and .name variables.
figsize (tuple, optional) – The size of the figure. Default: None (8, TFBS_track_height + number of bigwig tracks).
save (str, optional) – Save the plot to the file given in ‘save’. Default: None.