jokergoo / circlize

Circular visualization in R
http://jokergoo.github.io/circlize_book/book/
Other
966 stars 146 forks source link

No track has been created #90

Closed moshl closed 5 years ago

moshl commented 6 years ago

hi, jokergoo. I try to plot circos plot by circlize. but I meet a trouble: No track has been created, when I initialize circular plot. the code as below:

library(circlize) factors = 1:20 circos.par("gap.degree" = 0, "cell.padding" = c(0, 0, 0, 0),

  • start.degree = 360/40, track.margin = c(0, 0), "clock.wise" = FALSE) circos.initialize(factors = factors, xlim = c(0, 1)) circos.info()

All your sectors: [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" [15] "15" "16" "17" "18" "19" "20"

No track has been created

Hope your reply. Thanks

jokergoo commented 6 years ago

The layout is initialized but you haven't added any track.

Try to add one track by circos.track().

moshl commented 6 years ago

thank you. I solved this problem. but it is so sad I meet a new problem: the the regions i targeted have mismatched with genomic axis on circos plot. the code as below:

circos.clear() circos.par("start.degree" = 80,gap.degree=20,ADD=TRUE,cex.axis=1,col.lab="red") circos.initializeWithIdeogram(species = "hg19",chromosome.index = c("chr11"), major.by=10000000, +ideogram.height = convert_height(2, "mm"),sector.width=2)

text(0, 0, "default", cex = 1)

D0=read.table("No5_chr11_D0.txt",sep="\t",header=T) D0<-D0[,c(1,2,3,5)] D0 chromosome start stop seg.mean 1 chr11 70001 51594226 4 2 chr11 54694227 55011226 3 3 chr11 55011227 134935557 4 4 chr11 134935558 134946557 2 f = colorRamp2(breaks = c(0,1,2,3,4,5,6), colors = c("blue", "blue", "grey","pink","red","red","red")) circos.genomicTrackPlotRegion(D0, stack = TRUE, +panel.fun = function(region, value, ...) {circos.genomicRect(region, value, col = f(value[[1]]), border = +f(value[[1]]), lwd = 0.1, posTransform = posTransform.default, ...)}, +bg.border = NA, track.height = 0.1)

The result: result1

how to solve it ? Looking forward to your reply. thanks!

jokergoo commented 6 years ago

Following is the plot I have:

test

I cleaned your code a little bit and also can you try with circlize 0.4.5?

circos.clear()
circos.par("start.degree" = 80, gap.degree=20)
circos.initializeWithIdeogram(species = "hg19",chromosome.index = c("chr11"), 
    major.by=10000000, ideogram.height = convert_height(2, "mm"))

D0 = read.table(textConnection(
"chromosome start stop seg.mean
chr11 70001 51594226 4
chr11 54694227 55011226 3
chr11 55011227 134935557 4
chr11 134935558 134946557 2
"), sep = " ", header = TRUE)

f = colorRamp2(breaks = c(0,1,2,3,4,5,6), colors = c("blue", "blue", "grey","pink","red","red","red"))

circos.genomicTrackPlotRegion(D0, stack = TRUE, 
    panel.fun = function(region, value, ...) {
        circos.genomicRect(region, value, col = f(value[[1]]), 
            border = f(value[[1]]), lwd = 0.1, ...)
    },
    bg.border = NA, track.height = 0.1)
moshl commented 6 years ago

thank you so much! I get the actual result when i run your code. So how to set the size of axis-label? I try to use par(), but i failed.

jokergoo commented 5 years ago

In circos.initializeWithIdeogram(), set axis.labels.cex argument. I think par(cex = ...) should work, but it works globally.