Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

arrange_links_evenly

Arrange links evenly on each sector


Description

Arrange links evenly on each sector

Usage

arrange_links_evenly(df, directional = 0)

Arguments

df

A data frame with two columns. The values should only contain sector names.

directional

Whether the links are directional.

Details

This function only deals with single-line links.

Value

A data frame with four columns of the sectors and the positions of the links.

Examples

sectors = letters[1:20]
df = data.frame(from = sample(sectors, 40, replace = TRUE),
                to   = sample(sectors, 40, replace = TRUE),
                stringsAsFactors = FALSE)
df = unique(df)
df = df[df$from != df$to, ]

circos.initialize(sectors, xlim = c(0, 1))
circos.track(ylim = c(0, 1), panel.fun = function(x, y) {
    circos.text(CELL_META$xcenter, CELL_META$ycenter, CELL_META$sector.index)
})

df2 = arrange_links_evenly(df, directional = 1)

for(i in seq_len(nrow(df2))) {
    s1 = df$from[i]
    s2 = df$to[i]
    circos.link(df2[i, "sector1"], df2[i, "pos1"], 
                df2[i, "sector2"], df2[i, "pos2"],
                directional = 1)
}

circlize

Circular Visualization

v0.4.12
MIT + file LICENSE
Authors
Zuguang Gu
Initial release
2021-1-8

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.