This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Circlize genomicLabel won't plot outside.

Hi,

I'm a beginner to using circlize and can't get past this issue where the genomicLabels will not plot to the outside of the circle.

Here is a small example using 3 exons as the track.

> x
 ID    x   y
 exon1 0 100
 exon2 0 200
 exon3 0 166

And the 3 miRs that bind to them:

> ann
chr   UTR_start UTR_end value miRNA_family_ID
exon1        24      31     1    miR-4524a-3p
exon1        38      44     1         miR-657
exon3       398     404     1    miR-4524b-3p

circos code:

col_text = "grey25"
circos.clear()
circos.initialize(factors=x$ID,
                  xlim=matrix(c(rep(0,3),x$y), ncol=2))
circos.track(ylim=c(0,1), panel.fun=function(x,y){
  chr=CELL_META$sector.index
  xlim=CELL_META$xlim
  ylim=CELL_META$ylim
  circos.text(mean(xlim),mean(ylim),chr)
})
brk <- seq.int(0,466,25)
circos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {
circos.axis(h="top",major.at=brk,labels=round(brk/1,1),labels.cex=0.4,
col=col_text,labels.col=col_text,lwd=0.7,labels.facing="clockwise")
},bg.border=F)
circos.genomicLabels(ann,labels.column = 5, side = "outside")

Behaviour: Screenshot-from-2020-10-23-10-50-11

Expected Behaviour: Screenshot-from-2020-10-23-10-50-31

circlize

1 answer

x = read.table(textConnection(
"ID    x   y
exon1 0 100
exon2 0 200
exon3 0 166 
"), header = TRUE)

ann = read.table(textConnection(
"chr UTR_start UTR_end value miRNA_family_ID
exon1        24      31     1    miR-4524a-3p
exon2       41     47     1     miR-7855-5p
exon3       55     61     1     miR-6840-3p
"), header = TRUE)

The first issue with my data was the coordinates of the miRs. Initially their coordinates were based on their position within the circle. The correct way is to represent their coordinates with respect to the chromosome (exon in this case) in which they lie.

Secondly, I was calling the circos.genomicLabels() in the wrong order. To create the correct plot, call circos.genomicLabels() after initialising the circos plot, and before adding tracks.

col_text="grey25"
circos.initialize(factors=x$ID, xlim=matrix(c(rep(0,3),x$y), ncol=2))
circos.genomicLabels(ann,labels.column = 5, side = "outside", niceFacing = TRUE)
circos.track(ylim=c(0,1), panel.fun=function(x,y){
    chr=CELL_META$sector.index
    xlim=CELL_META$xlim
    ylim=CELL_META$ylim
    circos.text(mean(xlim),mean(ylim),chr)
})
brk <- seq.int(0,466,25)
circos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {
    circos.axis(h="top",major.at=brk,labels=round(brk/1,1),labels.cex=0.4,
    col=col_text,labels.col=col_text,lwd=0.7,labels.facing="clockwise")},bg.border=F)

Screenshot-from-2020-11-02-10-58-22

Log in to answer this question.