Plot a single cell copy number profile

plotCNprofile(
  CNbins,
  cellid = NULL,
  chrfilt = NULL,
  pointsize = 1,
  alphaval = 0.6,
  maxCN = 10,
  cellidx = 1,
  statecol = "state",
  returnlist = FALSE,
  raster = FALSE,
  genome = "hg19",
  y_axis_trans = "identity",
  xaxis_order = "genome_position",
  legend.position = "bottom",
  annotateregions = NULL,
  annotateregions_linetype = 2,
  SV = NULL,
  SVcol = TRUE,
  svalpha = 0.5,
  svwidth = 1,
  adj = 0.03,
  genes = NULL,
  tickwidth = 50,
  chrstart = NULL,
  chrend = NULL,
  shape = 16,
  positionticks = FALSE,
  ideogram = FALSE,
  overwrite_color = NULL,
  sv_style = "curves",
  sv_arc_alpha = 0.3,
  sv_arc_height = 0.2,
  show_sv_read_axis = TRUE,
  sv_read_axis_scale = NULL,
  show_sv_legend = FALSE,
  sv_arcs_above = FALSE,
  sv_band_frac = 0.25,
  sv_arc_scale = "span",
  sv_arc_side = NULL,
  sv_foldback_dist = 30000,
  sv_arc_min_height = 0.15,
  sv_arc_min_width = 0.004,
  show_chrbreaks = TRUE,
  ybreaks = NULL,
  sv_show_lines = TRUE,
  sv_line_alpha = NULL,
  regions = NULL,
  region_gap = 5,
  show_region_labels = TRUE,
  ...
)

Arguments

CNbins

Single cell copy number dataframe with the following columns: cell_id, chr, start, end, state, copy

cellid

Which cell to plot, if no cell is specific will plot the first cell in the dataframe

chrfilt

Vector of chromosomes to plot, if NULL (default) will plot all chromosomes

pointsize

The point size in the plot

alphaval

Alpha value of points

maxCN

The maximum on the y axis, if any points are above this value they will be winsorized rather than removed

cellidx

idx of cell to plot if cellid = NULL

statecol

The colour mapping, default is to map colours to the state column

returnlist

Return a list rather than the ggplot object

raster

use ggrastr or not, default = FALSE

genome

genome to use, default = "hg19" (only used for ideogram)

y_axis_trans

What transformation to use on the y-axis, default is identity, the other option is "squashy" which uses a tanh transformation

xaxis_order

Default is "genome_position"

legend.position

Where to place the legend, default is "bottom"

annotateregions

Dataframe with chr start and end positions to annotate, will draw a dashed vertical line at this position

annotateregions_linetype

linetype for region annotation, default = 2 (dashed)

SV

Default is NULL. If a dataframe with structural variant position is passed it will add rearrangement links between bins. For lines_and_arcs style, SV must include columns: strand_1, strand_2 (values '+' or '-'), and read_count.

SVcol

Default is TRUE. Colour SVs or not

svalpha

the alpha scaling of the SV lines, default = 0.5

svwidth

Width of SV width curves, default = 1.0

adj

adjustment for gene labels

genes

vector of genes to annotate, will add a dashed vertical line and label

tickwidth

Spacing of ticks (in Mb) when only 1 chromosome is plotted

chrstart

Start of region (in Mb) when plotting a single chromosome

chrend

End of region (in Mb) when plotting a single chromosome

shape

shape for plotting, default = 16

positionticks

set to TRUE to use position ticks rather than chromosome ticks

ideogram

plot ideogram at the top, default = TRUE

sv_style

visualization style for structural variants: "curves" (default, bezier curves), "lines_and_arcs" (colored lines with arcs), or "both"

sv_arc_alpha

transparency of SV arcs when using lines_and_arcs style, default = 0.3

sv_arc_height

height of SV arcs as fraction of maxCN when using lines_and_arcs style, default = 0.2

show_sv_read_axis

show secondary y-axis for SV read support when using lines_and_arcs style, default = TRUE. Works with both identity and squashy y-axis transformations.

sv_read_axis_scale

maximum value for SV read support axis (auto-scaled if NULL), default = NULL

show_sv_legend

show legend for SV orientations when using lines_and_arcs style, default = FALSE

sv_arcs_above

draw SV arcs in a dedicated band above the copy number panel rather than on top of it, default = FALSE. Read count is no longer encoded as arc height and the SV read support secondary axis is switched off.

sv_band_frac

height of the SV band as a fraction of the total panel height when sv_arcs_above = TRUE, default = 0.25. Consider ~0.35 when sv_arc_side is set, since each side then gets half the band.

sv_arc_scale

how the apex of each arc is chosen when sv_arcs_above = TRUE: "span" (default, apex scales with the sqrt of the arc's width so nested SVs nest visually) or "fixed" (every arc reaches the same height).

sv_arc_side

split arcs onto both sides of a baseline inside the SV band. NULL (default) draws all arcs upwards. One of the built-in rules "cn_effect" (gain-associated junctions up, loss-associated and CN-neutral down), "translocation" or "foldback", or the name of a column in SV holding "up"/"down".

sv_foldback_dist

maximum breakpoint distance (bp) for a "++"/"–" inversion to count as a foldback in the sv_arc_side rules, default = 30000

sv_arc_min_height

minimum apex of an arc as a fraction of the available band half-height, default = 0.15. Only used when sv_arc_scale = "span". Raise it so short-range SVs such as foldbacks stay visible.

sv_arc_min_width

minimum width of an arc as a fraction of the plotted x range, default = 0.004. An SV whose two breakends fall in the same bin (a foldback at 10kb bins, say) would otherwise have zero width and not render at all.

show_chrbreaks

draw the light grey vertical lines separating chromosomes, or regions when regions is supplied. Default = TRUE.

ybreaks

y axis breaks. Default NULL uses c(0, 2, 5, 10, maxCN) for the squashy transform and seq(0, maxCN, 2) otherwise. Useful for short panels, where the default breaks collide: the squashy transform packs 0/2/5 into the lower part of the axis, so their labels overlap once the panel drops below roughly 7 mm.

sv_show_lines

draw the vertical line at each breakpoint, default = TRUE. Set to FALSE for arcs only. In band mode the lines run from 0 up to the arc baseline; in read count mode they run from the bottom of the panel to a height set by read_count.

sv_line_alpha

transparency of the vertical breakpoint lines. Default NULL uses sv_arc_alpha. Because the lines are drawn behind the copy number points they can be made stronger than the arcs without obscuring the data.

regions

Optional data.frame with columns chr, start, end (in Mb) to plot multiple regions. If provided, takes precedence over chrfilt/chrstart/chrend.

region_gap

Gap size between regions in Mb, default = 5 Mb. Only used when regions is provided.

show_region_labels

Annotate each region with its chromosome name at the top of the panel. Only used when regions is provided. Default = TRUE.

Value

ggplot2 plot

Examples


plotCNprofile(CNbins)
#> Making CN profile and BAF plot for cell - SA921-A90554A-R03-C44
#> Making fixed-width bins for bin size 500000 ...