FIN=read.table(IN,header=TRUE)
circos.clear()
circos.par("start.degree" = 90)
circos.initialize("chrB", xlim = c(0, 171823))
circos.track(ylim = c(0, 1), bg.border = "white")
for (i in 1:nrow(FIN)){
COL1<- scales::alpha(ifelse(FIN[i,]$lib=="a","#4CAF50",ifelse(FIN[i,]$lib=="b","#FF6A6A","#00FA9A")),alpha=ifelse(FIN[i,]$lib=="a",0.8,ifelse(FIN[i,]$lib=="b",0.4,0.0)))
WID1<-ifelse(FIN[i,]$lib=="a",FIN[i,]$petnum/9,ifelse(FIN[i,]$lib=="b",FIN[i,]$petnum/10,FIN[i,]$petnum/10))
mid1<-FIN[i,]$start1+(FIN[i,]$end1-FIN[i,]$start1)/2
mid2<-FIN[i,]$start2+(FIN[i,]$end2-FIN[i,]$start2)/2
circos.link(FIN[i,]$chr1,mid1,FIN[i,]$chr2,mid2,lwd=WID1,col=COL1)}
library(ggbio)
N <- 100
library(GenomicRanges)
## ======================================================================
## simmulated GRanges
## ======================================================================
gr <- GRanges(seqnames =
sample(c("chr1", "chr2", "chr3"),
size = N, replace = TRUE),
IRanges(
start = sample(1:300, size = N, replace = TRUE),
width = sample(70:75, size = N,replace = TRUE)),
strand = sample(c("+", "-", "*"), size = N,
replace = TRUE),
value = rnorm(N, 10, 3), score = rnorm(N, 100, 30),
sample = sample(c("Normal", "Tumor"),
size = N, replace = TRUE),
pair = sample(letters, size = N,
replace = TRUE))
seqlengths(gr) <- c(400, 500, 700)
values(gr)$to.gr <- gr[sample(1:length(gr), size = length(gr))]
## doesn‘t pass gr to the ggplot
ggplot() + layout_circle(gr, geom = "ideo", fill = "gray70", radius = 7, trackWidth = 3) +
layout_circle(gr, geom = "bar", radius = 10, trackWidth = 4, aes(fill = score, y = score)) +
layout_circle(gr, geom = "point", color = "red", radius = 14,
trackWidth = 3, grid = TRUE, aes(y = score)) +
layout_circle(gr, geom = "link", linked.to = "to.gr", radius = 6,
trackWidth = 1)
library(ggplot2)
ggplot(SIN,aes(start,score1))+
geom_line()+
geom_rect(xmin=0,xmax=max(SIN$score1),ymin=-100000,ymax=0,fill="red")+
coord_polar()
library(gcookbook) # Load gcookbook for the wind data set
ggplot(wind, aes(x = DirCat, fill = SpeedCat)) +
geom_histogram(binwidth = 15, boundary = -7.5) +
coord_polar() +
scale_x_continuous(limits = c(0,360))
circos plot in R