Module: bbcflib.maplot

Creates an MA-plot to compare transcription levels of a set of genes (or other features) in two different conditions, from a CSV file. One can enter several datasets (CSV files) in the same format, each of which will be plotted in a different color, and be annotated if requested.

The class AnnoteFinder is used to create interactive - clickable - plots.

bbcflib.maplot.unique_filename(len=20, path=None)[source]

Return a len-characters random filename, unique in the given path.

bbcflib.maplot.guess_file_format(f, sep=None)[source]

Guess format of a sep-delimited file object f. Returns a csv.Dialect object and the header of the file.

bbcflib.maplot.MAplot(dataset, cols=['2', '3'], labels=['1'], annotate=None, mode='normal', data_format='counts', sep=None, limits=[None, None, None, None], slimits=[None, None], deg=3, bins=30, assembly_id=None, normalize='sf', quantiles=True, title='MA-plot', extremes=False, prefix=None)[source]

Creates an “MA-plot” to compare transcription levels of a set of genes in two different conditions. It returns the name of the .png file produced, and the name of a json containing enough information to reconstruct the plot using Javascript.

Parameters:
  • dataset – (list or string) names of up to six text files.
  • cols – (list or dict) 1-based indices of the two columns containing the numeric data to compare (e.g. [1,2]), or column names (e.g. [‘g1’,’g2’]), or a dict (e.g. {1:[`indices of group1], 2:[indices of group 2]}`).
  • labels – (int or list) 1-based indices of the columns used as labels, or column names.
  • annotate – (list) in normal mode, choose which for which datasets you want the points to be labeled. Enter 1 to annotate, 0 not to annotate, in the same order as datasets were entered. E.g. [0,0,1] to annotate only the third of 3 datasets.
  • mode – (str) display mode: If normal, name of genes over 99%/under 1% quantile are displayed. If interactive, click on a point to display its name. If json, a .json file is produced that allows to reproduce the graph. in a web interface using Javascript.
  • data_format – (str) counts or rpkm.
  • sep – (str) character delimiting the columns.
  • limits – (list) bounds of the region displayed on the output graph: [min_x, max_x, min_y, max_y].
  • slimits – (list) left and right bounds of the section of the splines to be displayed: [smin, smax]
  • deg – (int) the degree of the interpolating polynomial splines.
  • bins – (int) the number of divisions of the x axis for quantiles estimation.
  • assembly_id – (str or int) if an assembly ID is given, the json output will provide links to information on genes, using GenRep.
  • normalize – (str) tags (total tag count) or sf (size factors).
  • quantiles – (bool) if False, no quantile splines are drawn.
  • title – (str) title to be written on top of the graph.
  • extremes – (int) create an output file containing features for which ratios are outside the specified percentile (two-sided). The file is named extreme_ratios_xxxxx .
class bbcflib.maplot.AnnoteFinder(xdata, ydata, annotes, axis=None, xtol=None, ytol=None)[source]

Callback for matplotlib to display an annotation when points are clicked on. The point which is closest to the click and within xtol and ytol is identified.

Typical usage:

plot(xdata, ydata)
af = AnnoteFinder(xdata, ydata, annotes)
connect('button_press_event', af)
distance(x1, x2, y1, y2)[source]

Distance between two points (x1,y1) and (x2,y2)

drawAnnote(axis, x, y, annote)[source]

Draw on the plot the label of the point that was clicked

Previous topic

Subpackage: bbcflib.gfminer

Next topic

Subpackage: bbcflib.bein

This Page

Websites