Как связать начало и конец ссылки с одинаковым значением цели и источника в пакете Circlize - PullRequest
0 голосов
/ 15 января 2020

У меня есть следующие данные, используя Circlize package :

library(circlize)
library(tidyverse)

df <- structure(list(ligand = c(
  "  Cxcr4", "  Cd44", "  Cxcr4", "   Cxcr4",
  "   Csf2rb", "   Plaur", "    Plaur", "    Cxcr4", "    Csf3r",
  "    Sell", "     Tnfrsf1b", "      Sell", "       Csf2rb", "       Tnfrsf1b",
  "       Csf2rb", "       Il1r2", "       Plaur", "       Calm1",
  "       Cd44", "        Ptafr", "         Il1r2", "         Calm1",
  "          Cxcr2", "          Cxcr2"
), receptor = c(
  "  Dsg2",
  "  Itgb1", "  Cxcl10", "  Cxcl10", "  Itgb1", "  Itgb1", "  Agt",
  "  Csf1", "  Csf1", "  Icam1", "   Calm1", "  Calm1", "  Tnf",
  "  App", "  Il1b", "  Tnf", "  Il1b", "  Tnf", "  Mmp9", "  Anxa1",
  "  Il1b", "  Il1b", "  Cxcl10", "  Calr"
)), class = c(
  "tbl_df",
  "tbl", "data.frame"
), row.names = c(NA, -24L))

gaps <- c(
  0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
  0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 3,
  0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
  0.25, 0.25, 3
)

grid_col <- c(`  Cxcr4` = "#8DD3C7", `  Cd44` = "#8DD3C7", `   Cxcr4` = "#FFFFB3", 
`   Csf2rb` = "#FFFFB3", `   Plaur` = "#FFFFB3", `    Plaur` = "#BEBADA", 
`    Cxcr4` = "#BEBADA", `    Csf3r` = "#BEBADA", `    Sell` = "#BEBADA", 
`     Tnfrsf1b` = "#FB8072", `      Sell` = "#80B1D3", `       Csf2rb` = "#FDB462", 
`       Tnfrsf1b` = "#FDB462", `       Il1r2` = "#FDB462", `       Plaur` = "#FDB462", 
`       Calm1` = "#FDB462", `       Cd44` = "#FDB462", `        Ptafr` = "#B3DE69", 
`         Il1r2` = "#FCCDE5", `         Calm1` = "#FCCDE5", `          Cxcr2` = "#D9D9D9", 
`  Dsg2` = "#000000", `  Itgb1` = "#000000", `  Cxcl10` = "#000000", 
`  Agt` = "#000000", `  Csf1` = "#000000", `  Icam1` = "#000000", 
`   Calm1` = "blue", `  Calm1` = "#000000", `  Tnf` = "#000000", 
`  App` = "#000000", `  Il1b` = "#000000", `  Mmp9` = "#000000", 
`  Anxa1` = "#000000", `  Calr` = "#000000")

order <- c("  Cxcr4", "  Cd44", "   Cxcr4", "   Csf2rb", "   Plaur", "    Plaur", 
"    Cxcr4", "    Csf3r", "    Sell", "     Tnfrsf1b", "      Sell", 
"       Csf2rb", "       Tnfrsf1b", "       Il1r2", "       Plaur", 
"       Calm1", "       Cd44", "        Ptafr", "         Il1r2", 
"         Calm1", "          Cxcr2", "   Calm1", "  Dsg2", "  Itgb1", 
"  Cxcl10", "  Agt", "  Csf1", "  Icam1", "  Calm1", "  Tnf", 
"  App", "  Il1b", "  Mmp9", "  Anxa1", "  Calr")

И с этим кодом:

circos.par(gap.degree = gaps)
chordDiagram(df,
             directional = TRUE, 
             order = order, 
             link.sort = TRUE,
             link.decreasing = FALSE,
             grid.col = grid_col,
             diffHeight = 0.005,
             direction.type = c("diffHeight", "arrows"),
             # link.overlap = TRUE,
             link.arr.type = "big.arrow",
             annotationTrack = "grid",
             preAllocateTracks = list(track.height = 0.075)
)
# we go back to the first track and customize sector labels
circos.track(track.index = 1, panel.fun = function(x, y) {
  circos.text(CELL_META$xcenter, CELL_META$ylim[1], CELL_META$sector.index,
              facing = "clockwise", niceFacing = TRUE,
              adj = c(0, 0.55),
              cex = 0.5
  )
}, bg.border = NA)

circos.clear()

Я могу сделать этот участок:

enter image description here

Как указано на графике выше, как Cand I связать начало и конец ссылки с одинаковыми целевым и исходным значением?

Так, например, Cxcr1 будет иметь только один блок в качестве отправителя с серым цветом.

...