#Install packages install.packages("devtools") devtools::install_github("mattflor/chorddiag", build_vignettes = TRUE) library(tidyverse) library(hrbrthemes) library(circlize) library(chorddiag) library(igraph) library(tidygraph) #Import dataset data <- read.csv ("your file location", header=TRUE) #Step1 circos.clear() circos.par(start.degree = 75, gap.degree =2, track.margin = c(-0.3, 0.3), points.overflow.warning = FALSE) #Step2 #Inorder to define color according to your needs or in this case by class we need to create an object called col col= c(LISINOPRIL= "plum3", "ENALAPRIL"="plum3", "BENAZEPRIL"="plum3", #ACE inhibitors DOXAZOSIN= "blue", #Alpha1 blocker CLONIDINE="grey", #Alpha2 Agonist LOSARTAN="purple", #ARB ATENOLOL= "hotpink",CARVEDILOL="hotpink", METOPROLOL= "hotpink", LABETALOL="hotpink", PROPRANOLOL="hotpink", BISOPROLOL="hotpink", #Beta blockers AMLODIPINE="powderblue", #DHPCCB SPIRONOLACTONE="lightskyblue", #K-sparing diuretics FUROSEMIDE='moccasin', BUMETANIDE='moccasin', #Loop diuretics DILTIAZEM="brown", #Non-PHP CCB HYDROCHLOROTHIAZIDE="gold",CHLORTHALIDONE="gold", # Thiazide Diuretics HYDRALAZINE="darkgreen" )#Vasodilator" #Step3 # Base plot chordDiagram( x = data, grid.col = col, directional = 0, #data flow diffHeight = -0.04, annotationTrack = "grid", annotationTrackHeight = c(0.05, 0.1), link.largest.ontop = TRUE ) #Step4 # Add text and axis circos.trackPlotRegion( track.index = 1, bg.border = NA, panel.fun = function(x, y) { xlim = get.cell.meta.data("xlim") sector.index = get.cell.meta.data("sector.index") # Add names to the sector. circos.text( x = mean(xlim), y = 1.2, #adjust space between the labels and the circle adj = c(0, 0.5), labels = sector.index, facing = "clockwise", niceFacing = TRUE, cex = 0.5 ) } )