- Clone names are set in the regular weight: the clone labels beside the integer-CN profile
and the
<label> (<pct>%)row-block labels on the heatmap. The CN key'sCNAtitle is regular as well. BAF_LIM = (-0.01, 1.01): default limits for a BAF-like axis on [0, 1], exported fromcnplot. The pad keeps points at exactly 0 or 1 off the spine while the ticks still run 0.0 to 1.0. Used by the gallery/README BAF row (ylim) and the RDR-vs-BAF scatter (xlim), which previously used(-0.05, 1.05)and(0, 1).- Fonts are configured in one module,
cnplot.cnplot_style: the family list (FONT_FAMILY), the embedding types (FONT_TYPE), theFS_*sizes, andapply_style(), which writes them into rcParams on import. No other module names a family, a size or an embedding type.FONT_FAMILYandapply_styleare exported fromcnplot. - One type scale for every figure. The heatmap page, the integer-CN profile, the CN key,
the proportion legends and the 2D scatter no longer carry their own literal font sizes
(6 to 15 pt); they take
FS_TICK,FS_LEGEND,FS_AXLABEL,FS_AXTITLEandFS_TITLE, and the same sizes are set as rc defaults on import so text drawn without an explicit size (a colorbar's ticks) follows.FS_ANNOTis new, for labels written on the data. - Layout measured instead of assumed, so it holds at any font size:
- the CN key labels each state
(a,b)and wraps its groups onto further rows until the widest label fits under one swatch; it never shrinks the type or the notation; plot_strip_legendstacks legends by their rendered height. Itsentry_hargument is removed andgapdefaults to half a legend line;- the heatmap colorbar grows until neighbouring tick labels clear each other, and the strip legends start to the right of its rendered tick labels;
- the
plot_heatmap_cnptitle is anchored above the mesh rather than at a fixed figure height.
- the CN key labels each state
- Genome-axis labels are placed so they clear each other at the type scale:
- chromosome names keep their
rotation(60 degrees by default); names closer together than a line at that angle are nudged apart along the axis, and on an axes too narrow to hold them in one row, alternate crowded names go on a second row (chrname_tierstells a layout which case applies); - in Mb mode an Mb label within a line of the previous one is left blank (its tick mark stays), the chromosome names under the Mb labels are offset in points rather than as a fraction of the axes, and on a stacked page only the last row labels its Mb ticks;
- the gap between a row and the profile under it is sized in inches from the labels it
holds (
genome_label_room) byplot_scatter_1d_multisampleandplot_heatmap_cnp, andplot_heatmap_cnpno longer opens the same gap between the profile and its key.
- chromosome names keep their
- The README gallery is drawn 20 in wide, the width the type scale assumes.
FigureSaver.close()can be called twice on every supported matplotlib.- Importing cnplot stops matplotlib's PDF backend storing rasterized layers as
/Indexedpalette images. Withpdf.compressionon, the backend converts any RGB raster of 256 or fewer colours to a palette and packs the indices at 1, 2 or 4 bits per pixel when the palette is small, which vector editors misread, so a copy-number raster opened in the wrong colours. Rasters are now written at 8 bits per component in DeviceRGB, still Flate-compressed. The hook is onPdfFile._writeImg, so it applies to every PDF the process writes, throughFigureSaver,PdfPagesorFigure.savefig. Rendered pixels are unchanged; a PDF holding such rasters is larger. This works around a known matplotlib bug, wrong colours when such a PDF is opened in Adobe Illustrator (matplotlib#27893), for which matplotlib has no setting; remove the hook once that is fixed upstream. FigureSaverno longer holds a whole-figure raster buffer per rasterized artist. matplotlib renders each rasterized artist into a buffer the size of the entire figure and passes the PDF backend a view of it, and the backend keeps every image until the file is finalized, so a multi-page PDF pinnedn_artists * fig_w_in * fig_h_in * dpi^2bytes until close.FigureSaver.savefignow copies each image on the way in, so only the cropped pixels are retained. Written output is byte-identical.
Backward-compatible additions; existing calls and output are unchanged.
decorate_genome_axisgainsmb_ticks/mb_tick_step: label x in Mb everymb_tick_stepbp within each chromosome (reset per chromosome), with chromosome names drawn as compact off-axis text - the denser mode for genome-wide scatter QC. Plumbed throughplot_scatter_1d,plot_scatter_1d_multisample,plot_heatmap, andplot_heatmap_cnp. Default off, 50Mb step; the Mb labels are rotated byrotation(default 60 degrees) so the dense ticks do not overlap.- Version lives in the repo-root
VERSIONfile:pyproject.tomlbuilds from it (dynamic version = {file = "VERSION"}) andcnplot.__version__reads it back, falling back to the installed metadata outside a source checkout. One edit per bump. GenomeAxis(region_bed=None): build one full-length region per chromosome fromchrom_sizes, i.e. a plain whole-genome axis with no gaps, for callers that only have a sizes file.
First release of cnplot, the shared copy-number plotting library.
GenomeAxis: a genome coordinate transform built from a region BED and chromosome sizes, mapping any bin table by(#CHR, START, END).- Colormaps:
get_cn_cmap,get_ascn_cmap,get_baf_cmap,get_log2rdr_cmap,get_mixcn_cmap,get_multiclass_cmap,set_palette. - Integer copy-number profiles:
plot_cnv_profileover the seg.ucn table. - 1D genome scatter:
plot_scatter_1dand theplot_scatter_1d_multisamplebuilder, withhue/palette and an optionalexpected_dfoverlay. - 2D RDR/BAF scatter:
plot_scatter_2d(seabornJointGrid) with copy-number landmarks. - Single-cell heatmap:
plot_heatmap/plot_heatmap_cnpwith ordered categorical and posterior sidestripsand an optional value colorbar.