arrange_links_evenly: Arrange links evenly on each sector

View source: R/link.R

arrange_links_evenlyR Documentation

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 documentation built on May 29, 2024, 1:59 a.m.