Skip to content

Modify Cluster Settings ​

This function can switch prevention of gene overlap on, adjust the spacing between tracks and alter the styling of specified clusters.

Usage ​

r
GC_cluster(
  GC_chart,
  separate_strands = NULL,
  strand_spacing = NULL,
  prevent_gene_overlap = NULL,
  overlap_min = NULL,
  overlap_spacing = NULL,
  cluster = NULL,
  style = list(),
  ...
)

Arguments ​

ArgumentDescription
GC_chartThe gene chart object to be modified.
separate_strandsLogical, indicating whether to vertically separate forward and reverse genes.
strand_spacingNumeric, specifies the spacing between genes on different strands. Used only if separate_strands is TRUE.
prevent_gene_overlapWhether to put overlapping genes on separate tracks, below each other: TRUE for all genes that overlap, or "nested" for only the genes that lie inside another gene (e.g. an ORF inside another reading frame), which go on the tracks below; the other genes stay on the first track, also where they overlap. A gene goes on the first track where it overlaps no gene placed before it. The track of each gene is in the geneTrack column, for the style_by of GC_genes() and GC_labels(), e.g. to draw the genes of the second track smaller.
overlap_minThe overlap two genes need to go on separate tracks with prevent_gene_overlap: a number of base pairs, or a share of the shorter gene as a string, e.g. "10%". Genes that overlap by no more, e.g. two genes that share a base or a stop codon, stay on the same track. Default NULL: any overlap.
overlap_spacingNumeric, specifies the spacing between overlapping genes Used only if prevent_gene_overlap is TRUE.
clusterOptional; used to specify which clusters in the chart should have tooltips.
styleA list of CSS styles to be applied to the gene track. Each element of the list should be a valid CSS property-value pair. For example, list(backgroundColor = "red", color = "white").
...Additional arguments to be passed to the underlying functions.

Value ​

Returns the modified gene chart object.

Examples ​

r
genes_data <- data.frame(
  start = c(1, 10, 200, 220, 600),
  end = c(10, 150, 180, 400, 400),
  name = c('Gene 1', 'Gene 2', 'Gene 3', 'Gene 4', 'Gene 5'),
  group = c('A', 'A', 'A', 'A', 'A')
)


GC_chart(genes_data, group = "group", height = "150px") %>%
  GC_cluster(separate_strands=TRUE, strand_spacing = 0) %>%
  GC_legend(FALSE)

# Only the gene inside another one goes below, drawn smaller
nested_genes <- data.frame(
  start = c(1, 120, 300, 340), end = c(125, 400, 380, 600),
  name = c("A", "B", "B2", "C")
)
GC_chart(nested_genes, height = "150px") %>%
  GC_cluster(prevent_gene_overlap = "nested") %>%
  GC_genes(style_by = "geneTrack",
           groupStyle = list("2" = list(markerHeight = 8, arrowheadHeight = 8))) %>%
  GC_labels("name")