Created
December 9, 2022 19:48
-
-
Save jokergoo/c1a8f6b49f14275895a916df5db74347 to your computer and use it in GitHub Desktop.
intra- and inter-translocations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = sort(runif(20)) | |
df1 = data.frame(x1 = x[1:20 %% 2 == 0], x2 = x[1:20 %% 2 == 1]) | |
df1 = cbind(gene = "A", df1) | |
x = sort(runif(10, max = 0.5)) | |
df2 = data.frame(x1 = x[1:10 %% 2 == 0], x2 = x[1:10 %% 2 == 1]) | |
df2 = cbind(gene = "B", df2) | |
x = sort(runif(30, max = 2)) | |
df3 = data.frame(x1 = x[1:30 %% 2 == 0], x2 = x[1:30 %% 2 == 1]) | |
df3 = cbind(gene = "C", df3) | |
df = rbind(df1, df2, df3) | |
link = data.frame(gene1 = sample(c("A", "B", "C"), nrow(df), replace = TRUE), | |
x1 = 0, | |
gene2 = sample(c("A", "B", "C"), nrow(df), replace = TRUE), | |
x2 = 0) | |
for(i in seq_len(nrow(link))) { | |
if(link$gene1[i] == "A") { | |
link$x1[i] = runif(1) | |
} else if(link$gene1[i] == "B") { | |
link$x1[i] = runif(1, max = 0.5) | |
} else if(link$gene1[i] == "C") { | |
link$x1[i] = runif(1, max = 2) | |
} | |
if(link$gene2[i] == "A") { | |
link$x2[i] = runif(1) | |
} else if(link$gene2[i] == "B") { | |
link$x2[i] = runif(1, max = 0.5) | |
} else if(link$gene2[i] == "C") { | |
link$x2[i] = runif(1, max = 2) | |
} | |
} | |
circos.par(circle.margin = 0.1, gap.degree = 5) | |
circos.initialize(c("A", "B", "C"), xlim = cbind(c(0, 0, 0), c(1, 0.5, 2))) | |
circos.track(ylim = c(0, 1), panel.fun = function(x, y) { | |
tb = df[df[, 1] == CELL_META$sector.index, ] | |
circos.lines(CELL_META$xlim, c(0.5, 0.5), col = "grey") | |
circos.rect(tb[, 2], 0.1, tb[, 3], 0.9, col = 1+CELL_META$sector.numeric.index, border = "grey") | |
}, track.height = mm_h(4), bg.border = NA, bg.col = "#EEEEEE") | |
for(i in seq_len(nrow(link))) { | |
if(link$gene1[i] == link$gene2[i]) { | |
circos.link(link$gene1[i], link$x1[i], link$gene2[i], link$x2[i], h = -0.1, rou = 1, col = 5, w = 0.1) | |
} else { | |
circos.link(link$gene1[i], link$x1[i], link$gene2[i], link$x2[i], col = 6) | |
} | |
} | |
circos.clear() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment