Set of basic plotting functions.
lcdblib.plotting.basic.PairGrid(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None, x_vars=None, y_vars=None, diag_sharey=True, size=2.5, aspect=1, despine=True, dropna=True, subplots_kws={})[source]¶Bases: seaborn.axisgrid.PairGrid
lcdblib.plotting.basic.corrfunc(x, y, loc=(0.1, 0.5), template='r = {:0.4f}', type='spearman', **kwargs)[source]¶Adds text to the current axes with either the sparman or pearson r.
| Parameters: |
|
|---|
lcdblib.plotting.basic.lowerTriangle(df, func, func_kw={}, pairgrid_kw={}, **kwargs)[source]¶Create a PairGrid lower triangle panel.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | seaborn.PairGrid |
lcdblib.plotting.basic.maPlot(x, y, data=None, title=None, log=False, **kwargs)[source]¶Creates a MA plot.
| Parameters: |
|
|---|---|
| Returns: | matplotlib.axes.Axes |
| Return type: | A matplotlib axes. |
Example
>>> maPlot('x', 'y', data=df, log=True, fig_reg=True,
... line_kws={'color': 'red'})
>>> maPlot(x, y, log=True, fig_reg=True, line_kws={'color': 'red'})
Module to handle custom colormaps.
cmap_powerlaw_adjust, cmap_center_adjust, and cmap_center_adjust are from https://sites.google.com/site/theodoregoetz/notes/matplotlib_colormapadjust
lcdblib.plotting.colormap_adjust.cmap_center_adjust(cmap, center_ratio)[source]¶Returns a new colormap based on the one given but adjusted so that the old center point higher (>0.5) or lower (<0.5)
| Parameters: |
|
|---|
lcdblib.plotting.colormap_adjust.cmap_center_point_adjust(cmap, range, center)[source]¶Converts center to a ratio between 0 and 1 of the range given and calls cmap_center_adjust(). returns a new adjusted colormap accordingly
| Parameters: |
|
|---|
lcdblib.plotting.colormap_adjust.cmap_powerlaw_adjust(cmap, a)[source]¶Returns a new colormap based on the one given but adjusted via power-law, newcmap = oldcmap**a.
| Parameters: |
|
|---|
lcdblib.plotting.colormap_adjust.color_test(color)[source]¶Figure filled in with color; useful for troubleshooting or experimenting with colors
lcdblib.plotting.colormap_adjust.smart_colormap(vmin, vmax, color_high='#b11902', hue_low=0.6)[source]¶Creates a “smart” colormap that is centered on zero, and accounts for asymmetrical vmin and vmax by matching saturation/value of high and low colors.
It works by first creating a colormap from white to color_high. Setting this color to the max(abs([vmin, vmax])), it then determines what the color of min(abs([vmin, vmax])) should be on that scale. Then it shifts the color to the new hue hue_low, and finally creates a new colormap with the new hue-shifted as the low, color_high as the max, and centered on zero.
| Parameters: |
|
|---|
lcdblib.plotting.compare_rnaseq_and_chipseq.plot(de_results, regions=None, peaks=None, selected=None, x='baseMean', y='log2FoldChange', disable_logx=False, logy=False, pval_col='padj', alpha=0.1, lfc_cutoff=0, plot_filename=None, disable_raster_points=False, genes_to_label=None, label_column=None, report=None, gene_lists=None)[source]¶M-A plot showing up- and downregulated genes with optional labeling and Fishers exact tests.
If –plot-filename is not specified, then the plot will be displayed and points can be clicked for interactive exploration.
If –peaks and –regions are specified, then results from Fishers exact tests will be printed to stdout, or to –report if specified.
| Parameters: |
|
|---|
lcdblib.plotting.results_table.DESeq2Results(data, db=None, header_check=True, **kwargs)[source]¶Bases: lcdblib.plotting.results_table.DESeqResults
Class for working with results from DESeq2.
Just like a DifferentialExpressionResults object, but sets the pval_column, lfc_column, and mean_column to the names used in edgeR’s output.
The underlying pandas.DataFrame is always available with the data attribute.
Any attributes not explicitly in this class will be looked for in the underlying pandas.DataFrame.
| Parameters: |
|
|---|
lfc_column = 'log2FoldChange'¶mean_column = 'baseMean'¶pval_column = 'padj'¶lcdblib.plotting.results_table.DESeqResults(data, db=None, header_check=True, **kwargs)[source]¶Bases: lcdblib.plotting.results_table.DifferentialExpressionResults
Class for working with results from DESeq.
Just like a DifferentialExpressionResults object, but sets the pval_column, lfc_column, and mean_column to the names used in DESeq (v1) output.
The underlying pandas.DataFrame is always available with the data attribute.
Any attributes not explicitly in this class will be looked for in the underlying pandas.DataFrame.
| Parameters: |
|
|---|
autosql_file()[source]¶Generate the autosql for DESeq results (to create bigBed)
Returns a temp filename containing the autosql defining the extra fields.
This for creating bigBed files from BED files created by colormapped_bed. When a user clicks on a feature, the DESeq results will be reported.
colormapped_bedfile(genome, cmap=None)[source]¶Create a BED file with padj encoded as color
Features will be colored according to adjusted pval (phred transformed). Downregulated features have the sign flipped.
| Parameters: | cmap (matplotlib colormap) – Default is matplotlib.cm.RdBu_r |
|---|
Notes
Requires a FeatureDB to be attached.
lcdblib.plotting.results_table.DifferentialExpressionResults(data, db=None, header_check=True, **kwargs)[source]¶Bases: lcdblib.plotting.results_table.ResultsTable
A ResultsTable subclass for working with differential expression results.
Adds methods for up/down regulation, ma_plot, and sets class variables for which columns should be considered for pval, log fold change, and mean values. This class acts as a parent for subclasses like DESeqResults, EdgeRResults, and others/
The underlying pandas.DataFrame is always available with the data attribute.
Any attributes not explicitly in this class will be looked for in the underlying pandas.DataFrame.
| Parameters: |
|
|---|
changed(alpha=0.1, lfc=0, idx=True)[source]¶Changed features.
Helper function to get where the pval is <= alpha and the absolute value log2foldchange is >= lfc.
| Parameters: |
|
|---|
downregulated(alpha=0.1, lfc=0, idx=True)[source]¶Downregulated features.
Helper function to get where the pval is <= alpha and the log2foldchange is <= lfc.
| Parameters: |
|
|---|
lfc_column = 'log2FoldChange'¶ma_plot(alpha, up_kwargs=None, dn_kwargs=None, zero_line=None, **kwargs)[source]¶MA plot.
Plots the average read count across treatments (x-axis) vs the log2 fold change (y-axis).
Additional kwargs are passed to self.scatter (useful ones might include genes_to_highlight)
| Parameters: |
|
|---|
mean_column = 'baseMean'¶pval_column = 'padj'¶unchanged(alpha=0.1, lfc=0, idx=True)[source]¶Unchanged features.
Helper function to get where the pval is > alpha and the absolute value of the log2foldchange is < lfc.
| Parameters: |
|
|---|
upregulated(alpha=0.1, lfc=0, idx=True)[source]¶Upregulated features.
Helper function to get where the pval is <= alpha and the log2foldchange is >= lfc.
| Parameters: |
|
|---|
lcdblib.plotting.results_table.EdgeRResults(data, db=None, header_check=True, **kwargs)[source]¶Bases: lcdblib.plotting.results_table.DifferentialExpressionResults
Class for working with results from edgeR.
Just like a DifferentialExpressionResults object, but sets the pval_column, lfc_column, and mean_column to the names used in edgeR’s output.
The underlying pandas.DataFrame is always available with the data attribute.
Any attributes not explicitly in this class will be looked for in the underlying pandas.DataFrame.
| Parameters: |
|
|---|
lfc_column = 'logFC'¶mean_column = 'logCPM'¶pval_column = 'FDR'¶lcdblib.plotting.results_table.LazyDict(fn_dict, index_file=None, index_from=None, extra=None, cls=<class 'lcdblib.plotting.results_table.DESeqResults'>)[source]¶Bases: object
lcdblib.plotting.results_table.MarginalHistScatter(ax, hist_size=0.6, pad=0.05)[source]¶Bases: object
append(x, y, scatter_kwargs, hist_kwargs=None, xhist_kwargs=None, yhist_kwargs=None, num_ticks=3, labels=None, hist_share=False, marginal_histograms=True)[source]¶Adds a new scatter to self.scatter_ax as well as marginal histograms for the same data, borrowing addtional room from the axes.
| Parameters: |
|
|---|
limits¶xmax¶xmin¶ymax¶ymin¶lcdblib.plotting.results_table.ResultsTable(data, db=None, import_kwargs=None)[source]¶Bases: object
Wrapper around a pandas.DataFrame that adds additional functionality.
The underlying pandas.DataFrame is always available with the data attribute.
Any attributes not explicitly in this class will be looked for in the underlying pandas.DataFrame.
| Parameters: |
|
|---|
attach_db(db)[source]¶Attach a gffutils.FeatureDB for access to features.
Useful if you want to attach a db after this instance has already been created.
| Parameters: | db (gffutils.FeatureDB) – |
|---|
features(ignore_unknown=False)[source]¶Generator of features.
If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for every feature in the dataframe’s index.
| Parameters: | ignore_unknown (bool) – If True, silently ignores features that are not found in the db. |
|---|
radviz(column_names, transforms={}, **kwargs)[source]¶Radviz plot.
Useful for exploratory visualization, a radviz plot can show multivariate data in 2D. Conceptually, the variables (here, specified in column_names) are distributed evenly around the unit circle. Then each point (here, each row in the dataframe) is attached to each variable by a spring, where the stiffness of the spring is proportional to the value of corresponding variable. The final position of a point represents the equilibrium position with all springs pulling on it.
In practice, each variable is normalized to 0-1 (by subtracting the mean and dividing by the range).
This is a very exploratory plot. The order of column_names will affect the results, so it’s best to try a couple different orderings. For other caveats, see [1].
Additional kwargs are passed to self.scatter, so subsetting, callbacks, and other configuration can be performed using options for that method (e.g., genes_to_highlight is particularly useful).
| Parameters: |
|
|---|
Notes
This method adds two new variables to self.data: “radviz_x” and “radviz_y”. It then calls the self.scatter method, using these new variables.
The data transformation was adapted from the pandas.tools.plotting.radviz function.
References
reindex_to(x, attribute=None)[source]¶Returns a copy that only has rows corresponding to feature names in x.
| Parameters: |
|
|---|
scatter(x, y, xfunc=None, yfunc=None, xscale=None, yscale=None, xlab=None, ylab=None, genes_to_highlight=None, marginal_histograms=False, general_kwargs={'alpha': 0.2, 'color': 'k', 'picker': True}, general_hist_kwargs=None, offset_kwargs={}, label_kwargs=None, ax=None, one_to_one=None, callback=None, hist_size=0.3, hist_pad=0.0, nan_offset=0.015, pos_offset=0.99, linelength=0.01, neg_offset=0.005)[source]¶Do-it-all method for making annotated scatterplots.
Includes rugplots for NaN/Inf/-Inf, a default callback that prints the entries of the underlying dataframe when a point is clicked, point labeling options, marginal histograms for multiple subsets, arbitrary styling of points for arbitrary subsets, and more.
| Parameters: |
|
|---|