Last data update: 2014.03.03

R: Draw text in a cell
circos.textR Documentation

Draw text in a cell

Description

Draw text in a cell

Usage

circos.text(x, y, labels, sector.index = get.cell.meta.data("sector.index"),
    track.index = get.cell.meta.data("track.index"), direction = NULL,
    facing = c("inside", "outside", "reverse.clockwise", "clockwise",
    "downward", "bending", "bending.inside", "bending.outside"), niceFacing = FALSE,
    adj = par("adj"), cex = 1, col = "black", font = par("font"), ...)

Arguments

x

Data points on x-axis

y

Data points on y-axis

labels

Labels for each points

sector.index

Index for the sector

track.index

Index for the track

direction

deprecated, use facing instead.

facing

Facing of text. Please refer to vignette for different settings

niceFacing

Should the facing of text be adjusted to fit human eyes?

adj

Adjustment for text. By default the text position adjustment is either horizontal or vertical in the canvas coordinate system. If the value which corresponds to the circular direction is wrapped by degree, the adjustment value is the degree that the text rotates. The sign of the degree is positive if the text rotates reverse clockwise and vice versa.

...

Pass to text

cex

Font size

col

Font color

font

Font style

Details

The function is similar to text. All you need to note is the facing settings.

References

Gu, Z. (2014) circlize implements and enhances circular visualization in R. Bioinformatics.

Examples

## Not run: 
library(circlize)
par(mar = c(1, 1, 1, 1), mfrow = c(2, 1))
factors = letters[1:4]
circos.par(points.overflow.warning = FALSE)
circos.initialize(factors = factors, xlim = c(0, 10))
circos.trackPlotRegion(factors = factors, ylim = c(0, 10), track.height = 0.5,
    panel.fun = function(x, y) {
    circos.text(3, 9, "inside", facing = "inside", cex = 0.8)
    circos.text(7, 9, "outside", facing = "outside", cex = 0.8)
    circos.text(0, 5, "reverse.clockwise", facing = "reverse.clockwise", 
        adj = c(0.5, 0), cex = 0.8)
    circos.text(10, 5, "clockwise", facing = "clockwise", adj = c(0.5, 0), cex = 0.8)
    circos.text(3, 9, "====bending.inside====", facing = "bending.inside", cex = 0.8)
    circos.text(7, 9, "====bending.outside====", facing = "bending.outside", cex = 0.8)
})
circos.clear()

factors = LETTERS[1:20]
circos.par(points.overflow.warning = FALSE)
circos.initialize(factors = factors, xlim = c(0, 1))
circos.trackPlotRegion(factors = factors, ylim = c(0, 1), track.height = 0.5, 
    panel.fun = function(x, y) {
        xlim = get.cell.meta.data("xlim")
        ylim = get.cell.meta.data("ylim")
        theta = mean(get.cell.meta.data("xplot")) %% 360
        sector.index = get.cell.meta.data("sector.index")
        if(theta < 90 || theta > 270) {
            text.facing = "clockwise"
            text.adj = c(0, 0.5)
        } else {
            text.facing = "reverse.clockwise"
            text.adj = c(1, 0.5)
        }
        circos.text(mean(xlim), ylim[1],
            labels = paste(rep(sector.index, 8), collapse = ""),
            facing = text.facing, adj = text.adj, cex = 0.8)
})
circos.clear()


## End(Not run)

Results