1

Im trying to make a circular plot similar to gene expression plots. I found the circlize package in R could do this, and Im trying to follow this http://cran.r-project.org/web/packages/circlize/vignettes/genomic_plot.pdf

I manage to get to: 6. Create plotting regions

But when I type

circos.genomicPoints(Region, value, numeric.column = c(1,2))

I get this error:

Error in get.cell.meta.data("sector.index") : 
Length of `sector.index` should only be 1.

And when I type

circos.genomicLines(Region, value, numeric.column = c(1, 2))

I get this error:

Error in region[[1]] + region[[2]] : 
  non-numeric argument to binary operator

Region is a data frame with 205 observations and 7 variables: chromosome, start position, end position, and then some values value is a data frame with 205 observations and 2 variables: both numeric values

Im completely new to this kind of plot, so any help is appreciated

Thanks

rawr
  • 20,481
  • 4
  • 44
  • 78
user2335015
  • 111
  • 11
  • You need to supply more detail. Did everything up to that point plot correctly? Did you build the functions exactly as written in Section 6? – Carl Witthoft Sep 02 '14 at 11:40
  • Yes, everything up to that point worked and plotted correctly – user2335015 Sep 02 '14 at 12:02
  • Since the referenced vignette does not supply `data` or `region`, (not to mention that multiple warnings and errors popped up as I executed the code provided), there may be errors in the vignette and/or the way you built your own `region` . – Carl Witthoft Sep 02 '14 at 14:45

1 Answers1

2

region in low-level functions such as circos.genomicPoints or circos.genomicLines should be a data frame which only contains two columns (start positions and end positions). Because functions such as circos.genomicPoints only work for one chromosome at a time, it is not necessary to put chromosome information in the region.

A recommended way to call circos.genomicPoints is to put into panel.fun when calling circos.genomicTrackPlotRegion:

bed  # your data frame which is bed-file format
circos.initializeWithIdeogram()
circos.genomicTrackPlotRegion(bed, panel.fun = function(region, value, ...) {
    circos.genomicPoints(region, value, ...)
})

In above example code, panel.fun is a self-defined function which will be executed in every chromosome. region and value in panel.fun are corresponding data frames in 'current chromosome' that are extracted from bed.

If you want to fine-tune your plot by calling circos.genomicPoints outside circos.genomicTrackPlotRegion, you need to construct your region and value variables and also don't forget to set sector.index or track.index to specify which chromosome and which track you want to put the graphics:

for(chr in chromosomes) {
    region = bed[bed[[1]] == "chr", 2:3]
    value = bed[bed[[1]] == "chr", some_column_index]
    circos.genomicPoints(region, value, sector.index = chr, ...)
}
Zuguang Gu
  • 1,301
  • 7
  • 11
  • Btw, some example code in 'genomic_plot.pdf' vignette is just for demonstration while cannot be executed. It is because drawing a genomic-level plot always needs more chunk of code, if putting all the code in the vignette, it will look terrible. The use of genomic circos functions are quite similar as use of general circos functions, they have the same idea behind. It's better for users to read main vignette (circlize.pdf) first. Also users can go to [http://jokergoo.github.io/circlize/](http://jokergoo.github.io/circlize/) for executable examples. – Zuguang Gu Sep 02 '14 at 21:00