简体   繁体   English

在R中作圆图

[英]circlize in R to make a circular plot

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 我发现R中的circlize包可以做到这一点,而我试图遵循此http://cran.r-project.org/web/packages/circlize/vignettes/genomic_plot.pdf

I manage to get to: 6. Create plotting regions 我设法达到:6.创建绘图区域

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 区域是具有205个观测值和7个变量的数据框:染色体,开始位置,结束位置,然后是一些值value是具有205个观测值和2个变量的数据框:两个数值

Im completely new to this kind of plot, so any help is appreciated 我对这种情节完全陌生,因此不胜感激

Thanks 谢谢

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). region在低级别的功能,例如circos.genomicPointscircos.genomicLines应该是一个数据帧只包含两列(开始位置和结束位置)。 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 . 由于诸如circos.genomicPoints功能circos.genomicPoints只能作用于一个染色体,因此无需将染色体信息放入该region

A recommended way to call circos.genomicPoints is to put into panel.fun when calling circos.genomicTrackPlotRegion : 推荐的方法来调用circos.genomicPoints是投入panel.fun致电时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. 在上面的示例代码中, panel.fun是一个自定义函数,将在每个染色体中执行。 region and value in panel.fun are corresponding data frames in 'current chromosome' that are extracted from bed . panel.fun中的regionvalue是从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: 如果你想通过调用微调您的情节circos.genomicPointscircos.genomicTrackPlotRegion ,你需要建立你的regionvalue的变量,也不要忘记设置sector.indextrack.index指定哪些染色体和轨道您要放置图形:

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, ...)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM