Coder Social home page Coder Social logo

circlize's Introduction

Anurag's github stats

Activities on my repos (R packages, 2013-04-18 ~ 2022-12-10): (code for generating this plot: https://jokergoo.github.io/spiralize_vignettes/examples.html#github-commits)

code
library(spiralize)
library(grid)

repos = c("GlobalOptions", "GetoptLong", "circlize", "bsub", "pkgndep", "ComplexHeatmap", "EnrichedHeatmap", 
    "HilbertCurve", "gtrellis", "cola", "simplifyEnrichment", "InteractiveComplexHeatmap", "spiralize", "rGREAT", "simona")

df_all = data.frame(commits = numeric(0), date = character(0), repo = character(0))
for(r in repos) {
    # go to each repo folder
    setwd(paste0("~/project/development/", r))
    df = read.table(pipe("git log --date=short --pretty=format:%ad | sort | uniq -c"))
    colnames(df) = c("commits", "date")
    df$repo = r

    df_all = rbind(df_all, df)
}

df_all$date = as.Date(df_all$date)

start = min(df_all$date)
end = max(df_all$date)

d = start + seq(1, end - start + 1) - 1
n = numeric(length(d))
nl = lapply(repos, function(x) numeric(length(d)))
names(nl) = repos

for(i in seq_len(nrow(df_all))) {
    ind = as.double(difftime(df_all[i, "date"], start), "days") + 1
    n[ind] = n[ind] + df_all[i, "commits"]

    nl[[ df_all[i, "repo"] ]][ind] = nl[[ df_all[i, "repo"] ]][ind] + df_all[i, "commits"]
}

calc_pt_size = function(x) {
    pt_size = x
    pt_size[pt_size > 20] = 20
    pt_size[pt_size < 2 & pt_size > 0] = 2
    pt_size
}
xlim = range(d)

pl = list()
pl[[1]] = grid.grabExpr({
    spiral_initialize_by_time(xlim, verbose = FALSE, normalize_year = TRUE)
    spiral_track()
    spiral_points(d, 0.5, pch = 16, size = unit(calc_pt_size(n), "pt"))
    grid.text("All packages", x = 0, y = 1, just = c("left", "top"), gp = gpar(fontsize = 14))

    for(t in c("2013-01-01", "2014-01-01", "2015-01-01", "2016-01-01", "2017-01-01",
               "2018-01-01", "2019-01-01", "2020-01-01", "2021-01-01", "2022-01-01", "2023-01-01")) {
        spiral_text(t, 0.5, gsub("-\\d+-\\d+$", "", as.character(t)), gp = gpar(fontsize = 8), facing = "inside")
    }
})

for(i in order(sapply(nl, sum), decreasing = TRUE)) {
    pl[[ names(nl)[i] ]] = grid.grabExpr({
        spiral_initialize_by_time(xlim, verbose = FALSE, normalize_year = TRUE)
        spiral_track()
        spiral_points(d, 0.5, pch = 16, size = unit(calc_pt_size(nl[[i]]), "pt"))
        grid.text(names(nl)[i], x = 0, y = 1, just = c("left", "top"), gp = gpar(fontsize = 14))

        for(t in c("2013-01-01", "2014-01-01", "2015-01-01", "2016-01-01", "2017-01-01",
                   "2018-01-01", "2019-01-01", "2020-01-01", "2021-01-01", "2022-01-01", "2023-01-01")) {
            spiral_text(t, 0.5, gsub("-\\d+-\\d+$", "", as.character(t)), gp = gpar(fontsize = 8), facing = "inside")
        }
    })
}

library(cowplot)
png("~/test.png", 300*4*1.5, 300*4*1.5, res = 72*1.5)
plot_grid(plotlist = pl, ncol = 4)
dev.off()

test

circlize's People

Contributors

dgabbe avatar guyabel avatar jokergoo avatar kant avatar raredd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circlize's Issues

outputting circos charts

Thanks for a very interesting package. I would like to include a circos chart I have built in a document I am working on, however am unclear on how and where the circos stores its data.

Is there a way to use the print() command to put the circos out to a document similar to what ggplot can do (eg. myplot <- ggplot(...) followed by print(myplot))

Thanks for your help

genomicHeatmap bug when plotting 1 column

It looks like there's a bug when you try and make a genomic heatmap from a 4-columns bed file.
Works fine:
col_fun = colorRamp2(c(-1, 0, 1), c("green", "black", "red"))
bed <- generateRandomBed(100, 2)
circos.initializeWithIdeogram()
circos.genomicHeatmap(bed, col=col_fun, side='inside', border='white')

Breaks:
col_fun = colorRamp2(c(-1, 0, 1), c("green", "black", "red"))
bed <- generateRandomBed(100, 1)
circos.initializeWithIdeogram()
circos.genomicHeatmap(bed, col=col_fun, side='inside', border='white')

With error message:
Error in apply(mat, 2, "is.numeric") : dim(X) must have a positive length

-August

Genomic density not circular

hello,

I have the following problem using circos.genomicDensity: the density for one of the chromosome is not represented in a circular way. It happens only for chromosome1, and only when the density of regions is calculated.

circos.par(gap.after = c(rep(3,13)),start.degree=90)
circos.initializeWithIdeogram(cytoband=paste(file),plotType=c("axis","labels"))
circos.genomicDensity(CGhyper, col = ("red"), track.height = 0.1)
circos.genomicDensity(CGhypo, col = ("blue"), track.height = 0.1)
circos.genomicRainfall(CGbed_list, col=c("red","blue"), cex=0.4, pch=16,track.height = 0.1)

CGhypo
chr start end diff.Methy
1: 6 12358260 12797896 -0.6121601
2: 2 9368024 9641216 -0.6642008
3: 6 12850040 12966736 -0.5745515
4: 2 12835299 12963901 -0.6535511
5: 12 22619618 22745700 -0.6126661
---
221720: 10 8522065 8522121 -0.4997741
221721: 5 52644467 52644794 -0.4895397
221722: 1 96299161 96299417 -0.5426681
221723: 6 45001157 45001240 -0.4661826
221724: 7 8707959 8708402 -0.0553777

and this is what I get:

image

Any idea what could be the problem here?

Thanks,
Fred

Error for CELL_META

I run into the following error when I try the example in the tutorial.

> set.seed(999)
> n = 1000
> df = data.frame(factors = sample(letters[1:8], n, replace = TRUE),
+     x = rnorm(n), y = runif(n))
> library(circlize)
> circos.par("track.height" = 0.1)
> circos.initialize(factors = df$factors, x = df$x)
> circos.track(factors = df$factors, y = df$y,
+     panel.fun = function(x, y) {
+         circos.text(CELL_META$xcenter, CELL_META$cell.ylim[2] + uy(5, "mm"),
+             CELL_META$sector.index)
+         circos.axis(labels.cex = 0.6)
+ })
Error in circos.text(CELL_META$xcenter, CELL_META$cell.ylim[2] + uy(5,  :
  object 'CELL_META' not found

Error in if (ncut) { : argument is not interpretable as logical

Here is a working example of my error

df_genome <- data.frame(name=c("a","b","c"),start=c(1,1,1),end=c(10,20,50))
df_genes <- data.frame(name=c("a","a","a","b","b","c"),start=c(3,4,9,6,14,20),end=c(5,7,10,10,18,40))
#adding a column value since it is needed in circos.genomicTrackPlotRegion
df_genes$value <- rep(1,nrow(df_genes))

circos.genomicInitialize(df_genome)
circos.genomicTrackPlotRegion(df_genes, panel.fun = function(region, value, ...) {
  circos.genomicLines(region, value, type = "segment", lwd = 2, ...)
})

Error in if (ncut) { : argument is not interpretable as logical

Link width in chord diagram of symmetric matrix with diagonal

Thank you for providing a great package and for your help!

I stumbled across an issue with a special case of chord diagrams. Links on the diagonal of a symmetric matrix return to the originating segment. The width of the link symbolizes the strength of the relationship. For the returning links this width weighs in doubly on a segment (outbound and inbound). Therefore, these segments as well as the links appear broader than they should. At least to may understanding.

In addition, it would look nicer if a returning chord would not arch the segment but rather return next to itself basically forming a "hill". Would it be feasible and possible to change the place where the cord returns? I very much like a diagram produced with D3.js where this is done: http://bl.ocks.org/mbostock/1046712

Plot genome density

Hi jokergoo;
I'm so sorry to trouble you again,can the circlize plot the Gene density like that? using a gradient color plot the Optical marker and gene density
Thanks
Alex
lz awqp wq c_ _c4442s9f

eps support for "genomicRainfall" function

Hi, you made a great job to generate a "circos"-like graph for human genome. When I try the genomicRainfall function via example page, it shows the figure.
But when I tried to output as a eps file, adding postgres("test.eps") before par() command, the genomicRainfall command outputs an error as the following figure:

screenshot from 2015-10-23 17 45 19

My environment:

  • Ubuntu: 15.04;
  • R: 3.1.2;
  • Circlize: 0.3.2.

Bug in numeric.column with a list of bedfiles

The following code fails:
bedlist = list(generateRandomBed(nc=2), generateRandomBed(nc=2))
circos.initializeWithIdeogram()
circos.genomicTrackPlotRegion(bedlist, numeric.column = c(4, 5),
panel.fun = function(region, value, ...) {
i = getI(...)
circos.genomicPoints(region, value, col = i, ...)
})

Error in circos.genomicTrackPlotRegion(bedlist, numeric.column = c(4, : Some of your numeric.column are not numeric.

Add "axis" type to the function "circos.genomicInitialize"

Current, we can only create a circle plot in two type: 1. axis + labels 2. labels. It will be better to let user can make a plot with axis and without labels. So I think in the line 193 - 198 in "circos.genomicInitialize" function

`if(all(c("axis", "labels") %in% plotType)) {

circos.axis(h = 0, major.at = major.at, labels = major.tick.labels, labels.cex = 0.3*par("cex"), labels.facing = "clockwise", major.tick.percentage = 0.2)

circos.text(mean(xlim), 1.2, labels = sector.names[sector.index], cex = par("cex"), adj = c(0.5, 0), niceFacing = TRUE)

} else if("labels" %in% plotType) {

circos.text(mean(xlim), 0, labels = sector.names[sector.index], cex = par("cex"), adj = c(0.5, 0), niceFacing = TRUE)

}`

We can add one if statement:

`if(all(c("axis", "labels") %in% plotType)) {

circos.axis(h = 0, major.at = major.at, labels = major.tick.labels, labels.cex = 0.3*par("cex"), labels.facing = "clockwise", major.tick.percentage = 0.2)

circos.text(mean(xlim), 1.2, labels = sector.names[sector.index], cex = par("cex"), adj = c(0.5, 0), niceFacing = TRUE)

} else if("axis" %in% plotType) {

circos.axis(h = 0, major.at = major.at, labels = major.tick.labels, labels.cex = 0.3*par("cex"), labels.facing = "clockwise", major.tick.percentage = 0.2)

} else if("labels" %in% plotType) {

circos.text(mean(xlim), 0, labels = sector.names[sector.index], cex = par("cex"), adj = c(0.5, 0), niceFacing = TRUE)

}`

Linear coordinates?

Is it possible to turn off the circular polar coordinates and just plot everything in a straight line? Tracks just one above the other.

Genome location label are mess

Hello:

I like the circlize very much. And it's very good to include the genome circlize version here. However, i try both circlize_0.4.0 and circlize_0.4.1 version. The label for the chromosome axis is a little bit mess. It's not line up to the ticks.
untitled

Check the attached files. For example, in chr5, it should have enough space to separate 90MB and 180MB. Can you help to fix this. Thanks.

(I found in your example file. it's looks like pretty good...)

adding a title to chordDiagram

Thanks for the awesome package! Is there a way to add titles to the visualizations? Moreover, the value returned from chordDiagram is a matrix, is there any way to store the image itself?

add links to the picture

Hi jokergoo;
I meet another problem when plot the genomic link to the picture,I want to plot the genomic link into the i picture which have drawn some point and lines. however I find no example to do it .have any methods to achieve it ?

Alex
image

Add histograms to the circos

Dear authors
I want to add the histogram and density to the circos picture,while it can't work well,the picture like this
1,and my commands like that :
circos.clear()
circos.par(gap.after=c(rep(3,6),7,rep(3,6),7),start.degree=90)
circos.genomicInitialize(bed1,track.height=0.05)
circos.trackHist(factors = bed2$chr, x = bed3$value, track.height = 0.1, col = "#999999", border = "#999999")

Animation support/Transition

Hi,

I have a network for which I produce a circelize graph every month. It turns out that there are a lot of variations over months. I would now like to make an animation of the network over time.

I was wondering if it is possible to calculate or produce 'intermediary' networks that would make transistions from month t-1 to t smooth? In other words I want to replicate the transition() function of d3.js. The two things that would be most helpful to animate are:

  • changes in the relative size of nodes
  • changes in edges

I don't mind a fixed order for nodes.

I don't relly understand the internal data representation of circlize, so I'm not sure what is the best way to tackle this.

Thanks,
Rasmus

Specifying colors for genomicPosTransformLines

What is the best way to specify colors for individual posTransform lines? The following code snippet works, but does not respect the ordering of columns (i.e. the lines are colored with the wrong color)

i_track = get.cell.meta.data("track.index") 
circos.genomicPosTransformLines(bedwithcolor, track.height=0.05,
    posTransform = function(region, value) {
                        posTransform.default(region, y = 0,
                                             labels = value[[1]], 
                                             cex = 0.8, padding = 0.2, 
                                             track.index = i_track)
                   },
    direction = "outside", col=bedwithcolor$Color, lwd=2
)

how to change sector character in png firgue

When I need export into png with high resolution (dpi = 600) as (width = 20, height = 20,res = 600,units = "in"), the labeled character is so small, and sector width is also shrinking.
How can I fix this problem?
I have tried par() to adjust but doesn't work at all.

What does circos.genomicDensity function plot?

Hello all,

I'm new to circos plots. Recently, I've been trying to plot fold enrichment of peaks I got from Chip-seq data. My peak file looks like a BED file. When I give this file to circos.genomicDensity function it gives me peaks plot, But what does these peaks represent? In manual it says "genomic density track". I don't know what's that ..

Please help me out. Can I use circlize for plotting Fold enrichment of Chip-seq data?

Thank you.

Best,
Anupriya

My file:
seqnames start end width strand length pileup X.log10.pvalue. fold_enrichment X.log10.qvalue.
Chromosome 161 3260 3100 * 3101 439.26 8.57279 1.31034 6.89738
Chromosome 4351 6741 2391 * 2392 521.45 6.97062 1.24202 5.44819
Chromosome 7841 11754 3914 * 3915 525.47 7.98465 1.25315 6.42158
Chromosome 14344 16848 2505 * 2506 460.84 5.40914 1.22931 3.99265
Chromosome 22050 22541 492 * 493 381.45 2.35655 1.14413 1.3518
Chromosome 27196 28557 1362 * 1363 382.71 2.45203 1.14792 1.43171
Chromosome 29741 31278 1538 * 1539 392.39 3.2509 1.17687 2.11031
Chromosome 32860 33309 450 * 451 390.46 2.84085 1.16303 1.75883
Chromosome 36419 39678 3260 * 3261 434.3 4.054 1.19718 2.79769

Plotting specific gene set around circos plot

Good Morning @jokergoo

I'm trying to plot specific genes around the genomic density plot. I'm able to plot it but inside the initialised plot like this:
moxi_uniq_list_trial

These are the commands I used :


library(circlize)
require (ChIPseeker)
library(GenomicFeatures)
source("/media/scripts/circos.genomicDensity.R")

txdb <- makeTxDbFromGFF("/home/m.tub1.gff3",circ_seqs=character(), organism="Mycobacterium tuberculosis")
annoData <- genes(txdb)
annoData1 <- as.data.frame(annoData)
a <- annoData1[which(annoData1$end == max(annoData1$end)),]

bed_file4 = read.csv("/home/peak_annotations.txt", header = T, sep = "\t") #2nd
bed_file7 = read.csv("/home/peak_annotations.txt", header = T, sep = "\t") #2nd

bed <- read.csv("/home/genes.bed", header = FALSE, sep = "\t") #2nd


pdf(file="/home/plots/trial.pdf",width=10,height=10)  
par(mar = c(1, 1, 1, 1))
circos.par(gap.degree=2, track.margin = c(0, 0))

circos.genomicInitialize(annoData1)

circos.genomicLabels(bed, labels.column = 4, side = "outside")
#data1 is + strand
circos.genomicDensity1(data=bed_file7, data1 =bed_file4, col = c("#ff0000"), col1 = c("#ff0000"), track.height = 0.2, baseline="top",baseline1="bottom")  # #00000000 is for transparent color. bg.border ="#00000000"
circos.trackText(a$seqnames,10, 0.6, label="+",niceFacing=TRUE, adj = c(0.9, 0), cex=0.5)
circos.trackText(a$seqnames,10, -0.6, label="-",niceFacing=TRUE, adj = c(0.9, 0), cex=0.5)


circos.clear()
dev.off()

Please help me plotting genes around the last circle (one having whole genome length)..
Thank you :)

Additional Unwanted Partial Track

Trying to generate a track containing a heatmap outside of the chord diagram. I am having an issue where after the first sector ("CTCF" sector), all subsequent sectors have an additional large track being generated that shouldn't be there. Circos.info() returns 3 tracks total, corresponding to 2 tracks for annotation and 1 track for the heatmap. The unwanted partial track is a 4th track that is not listed in the info. I do not know how to get rid of this and think it is a possible bug in the circlize code. Any help would be appreciated. Thanks.

Package version: 0.3.10, code and data necessary to redo the figure is below.

Figure

error

Files

file.rda

Code

#Chord diagram
load("file.rda")
circos.clear()
par(pty="s")
circos.par(points.overflow.warning=FALSE)
grid.col = c(CTCF = "sienna2", 
             EHN_ACT = "blueviolet", 
             EHN_POIS = "chartreuse3",
             None = "dodgerblue", 
             PRO_ACT = "darkgreen",
             PRO_POIS = "orange",
             RPS = "palevioletred1")

chordDiagram(circosR, 
             grid.col = grid.col,
             preAllocateTracks = 1)

# Heatmap circle plot
# Define colors for the outside track based on the avg score
col_fun = colorRamp2(c(min(scoretable$Avg.Score),
                       ((min(scoretable$Avg.Score) +
                           max(scoretable$Avg.Score))/2),
                       max(scoretable$Avg.Score)),
                     c("blue", "yellow", "red"))

# Tab1:  Outgoing  chords
# Tab2:  Incoming  chords
tab1 <- heatmap[order(heatmap$mark1,rev(heatmap$mark2)),]
tab2 <- heatmap[order(heatmap$mark2,rev(heatmap$mark1)),]

circos.trackPlotRegion(ylim = c(0, 4),
                       bg.border = NA,
                       track.index = 1,
                       panel.fun = function(x, y) {
                         end <- 0
                         for(sector in as.character(unique(tab1$mark1))) {
                           aux.tab1 <- tab1[tab1$mark1 == sector,]
                           aux.tab2 <- tab2[tab2$mark2 == sector,]
                           col_tab1 = col_fun(aux.tab1$Avg.Score)
                           col_tab2 = col_fun(aux.tab2$Avg.Score)
                           for(i in 1:nrow(aux.tab1)){    
                             start <- end
                             end <- end + aux.tab1[i,"Freq"]
                             circos.rect(start, 1, end, 3, 
                                         border = col_tab1[i], 
                                         col = col_tab1[i],  
                                         sector.index = sector,
                                         track.index = 1)
                           }
                           for(i in 1:nrow(aux.tab2)){    
                             start <- end
                             end <- end + aux.tab2[i,"Freq"]
                             circos.rect(start, 1, end, 3, 
                                         border = col_tab2[i], 
                                         col = col_tab2[i],  
                                         sector.index = sector,
                                         track.index = 1)
                           }
                           end <- 0
                           
                         }
                         
                       })

plot the links using the region colors

Dear author
while I want to use the circlize function circos.genomicLinks() to plot links between two links files ,since the links is too much ,so i want to chose the region color to plot it .but fails.do you  have any example or methods to plot it ?any help will be appreciated.
Thanks
Alex

[FR] Add text to links

Hi,

For some types of chart it would be useful to have text associated with an edge, say the value of the edge. I did not find a way to do this using circlize/ChordDiagram. While this is to some extend visible through the graph, sometimes making it explicit is better (in particular with arrows).

Thanks,
Rasmus

Multiple

I am using the procedure you describe in the the documentation to combine several parts of circular layouts (with the par(new=T) way). However I am having problems adjusting the "track.height" and the canvas.xlim/canvas.ylim settings so that all the tracks appear to have the same width and constant gap that I can control.
I figured out that if I use as canvas.xlim/ylim= c(-1.5^(layout_number),1.5^(layout_number)), and set track.height=0.3 I get layouts that do not overlap but the outer bands are wider than the inner ones.
Is it possible to give me some intuition on that?

highlight.sector(sector.index = sector, col = colour): colour vector of same length as sector

Hi,
I am using currently circlize::highlight.sector(). I was wondering if it's possible to change the function as such as to give to the function highlight.sector a vector colour which has the same length as sector, in order to highlight sectors in different colours?

E.g. I want to highlight the sectors "a", "b", "c" then

highlight.sector(sector.index = c("a", "b", "c"), col =c("blue", "red", "green")) will highlight the sectors in the corresponding colour.

[FR] group of sectors

Hi,

It may be that I have not understood the purpose of circlize, if so just close this bug.

I would like to organize my sectors by "meta sectors". Consider figure 10B in the excellent "Visualize relations by Chord diagram" vignette. I would like to group together E1 to E6. They will be part of a group G_E. I would like visualize this by adding an outer arc going from 0 to 180 degrees wit the label G_E. From the "intro to circlize" it's clearly possible, to have outer circles, but I couldn't understand if it's possible to also to have different "span" for outer circles.

Thanks,
Rasmus

synteny plots

Hi,
Which aligner do you recommend to use for circlize in order to create synteny plots between a reference genome (contains chromosomes and annotation) and a contig based assembly without annotation?

Which alignment format should be produced and are there any code examples which show how to extract the required information from the alignment file and put them in the correct format circlize or Rcircos?

Thank you in advance.

Michal

species='hg38'

Hi!
When I try:
circos.initializeWithIdeogram(species='hg38')
I get:
Error in stop_wrap("Maybe your gap.degree is too large so that there is no space to allocate sectors.") :
Maybe your gap.degree is too large so that there is no
space to allocate sectors.

I'm not entirely sure what the issue is (it sounds like it's grabbing the file from UCSC), but it might be nice if this worked (right out the box that is).
Thank you!
-August

Plotting genomic density upside down using circos.genomicDensity

Hello @jokergoo

Today I was trying to plot genomic density for forward & reverse strands , one should be upright & another one should be upside down.
I tried to change the code for 'circos.genomicDensity' function like this:
circos.genomicDensity1 = function (data, ylim.force = FALSE, window.size = NULL, overlap = TRUE, col = ifelse(area, "grey", "black"), lwd = par("lwd"), lty = par("lty"), type = "l", area = TRUE, area.baseline = NULL, baseline = 0, border = NA, ...) { if (!is.null(area.baseline)) { baseline = area.baseline warning("area.baselineis deprecated, please usebaseline` instead.")
}
data = normalizeToDataFrame(data)
if (!is.dataFrameList(data)) {
data = list(data)
}
if (length(col) == 1) {
col = rep(col, length(data))
}
if (length(lwd) == 1) {
lwd = rep(lwd, length(data))
}
if (length(lty) == 1) {
lty = rep(lty, length(data))
}
if (length(type) == 1) {
type = rep(type, length(data))
}
if (length(area) == 1) {
area = rep(area, length(data))
}

if (length(baseline) == 1) {
    baseline = rep(baseline, length(data))
}
if (length(border) == 1) {
    border = rep(border, length(data))
}
s = sapply(get.all.sector.index(), function(si) get.cell.meta.data("xrange", 
    sector.index = si))

if (is.null(window.size)) {
    window.size = 10^nchar(sum(s))/1000
}
df = vector("list", length = length(data))
for (i in seq_along(data)) {
    all.chr = unique(data[[i]][[1]])
    for (chr in all.chr) {
        region = data[[i]][data[[i]][[1]] == chr, 2:3, drop = FALSE]
        dn = genomicDensity(region, window.size = window.size, 
            overlap = overlap)
        dn = cbind(rep(chr, nrow(dn)), dn)
        df[[i]] = rbind(df[[i]], dn)
    }
}
if (ylim.force) {
    ymax = 1
}
else {
    ymax = max(sapply(df, function(gr) max(gr[[4]])))
}

circos.genomicTrackPlotRegion(df, ylim = c(0, ymax), panel.fun = function(region, 
    value, ...) {
    i = getI(...)

    circos.genomicLines(region, -value, col = col[i], lwd = lwd[i], 
        lty = lty[i], type = type[i], border = border[i], 
        area = area[i], baseline = baseline[i])
}, ...)

}

environment(circos.genomicDensity1) <- asNamespace('circlize')

#to get error line number:

f <- function (data, ylim.force = FALSE, window.size = NULL, overlap = TRUE,
col = ifelse(area, "grey", "black"), lwd = par("lwd"), lty = par("lty"),
type = "l", area = TRUE, area.baseline = NULL, baseline = 0,
border = NA, ...)
{
circos.genomicDensity1(data, ylim.force = FALSE, window.size = NULL, overlap = TRUE,
col = ifelse(area, "grey", "black"), lwd = par("lwd"), lty = par("lty"),
type = "l", area = TRUE, area.baseline = NULL, baseline = 0,
border = NA, ...)
}`

And I ran following commands:

`source("/home/circos_strands1/circos.genomicDensity1.R")
pdf(file="trial_2.pdf",width=10,height=10)
par(mar = c(1, 1, 1, 1))
circos.par(gap.degree=1, track.margin = c(0, 0))

circos.genomicInitialize(annoData1)
circos.genomicDensity(bed_file4, col = c("#008000"), track.height = 0.1, baseline="bottom")
circos.genomicDensity1(bed_file7, col = c("#008000"), track.height = 0.1, baseline="bottom", bg.border ="white", track.margin = c(0, 0.05))

circos.clear()
dev.off()`

This is the image I got:
trial_2

How can I reduce the distance between these 2 tracks? Please help me out.

Thank you

Disable polar coordinate transformation.

Is there a way to disable the coordinate transformation so that you can see the normal rectangular plotting area? I know this is not the purpose for Circlize, but we would like to make some additional zoomed-in figures where we want the plotting areas not to be curved. I can plot part of a circle, but there is always a small curvature left. In addition, it would then also be an excellent tool to plot genomic (or other kinds of) data in a rectangular format.

Thanks,
Ruben

Strange bending lines with circos.genomicTrackPlotRegion

Hi, this is the second question I have posted on this repo.

Yesterday, I tried draw a circos-like figure with this amazing tool, but something strange showed up, and a little help is needed. Part of the figure is as following.
image

Do you see some bending lines in Chr17, 18, and other chromosomes?

  • Species: Zebrafish
  • CytoBand: UCSC FTP
  • Commands used to draw figure:
data <- read.table('/home/sam/*.bed', head=T)
circos.genomicTrackPlotRegion(data, panel.fun=function(region, value, ...) {
    i = getI(...)
    circos.genomicLines(region, value, type='l', col="green")
}, bg.border=NA, track.height=0.1)
  • BED file format (all values are positive, end pos is always >= start pos):
chr start   end value1
chr1    32977   34219   1.611885
chr1    36659   39145   1.428755
chr1    27799   32416   1.425769
chr1    11871   16226   1.232793
chr1    120863  121801  1.610041
chr1    67339   69284   1.269779
chr1    39351   44723   1.423464

Thanks in advance.

circos.genomicLabels, Label position issue

Hello, I am try to plot a simple circos plot with few genes labeled on each chrome. I am trying the circos.genomicLabels(), but the lines are almost overlap and there should be enough space between each label lines.. Could you let me know how to fix this. Here is the method for circos.genomicLabels():

circos.genomicLabels(bed_gene, labels.column = 4, side = "outside",col=bed_gene_col,cex = 0.5)

Thanks so much.
test_fusion.pdf

circos.genomicLink reorders input data

I may be missing something... so please excuse if this is my lack of understanding.

The function circos.genomicLink should add links between two paired regions: region1 and region2. In the process of doing this it reorders region1 and region2 - loosing the linkage and producing a false plot.

circos.genomicLink calls normalizeToDataFrame which does

data = data[order(data[[1]], data[[2]]), , drop = FALSE]

circos.par FUN fail

circlize: 0.1.2
When run within rscript (Rscript foo.r):
Error in FUN("numeric"[[1L]], ...) : could not find function "is"
Calls: circos.par -> sapply -> lapply -> FUN
Execution halted
GUI run OK;

0.1.1 has no such problem in both ways

plot error points

Dear jokergoo:
while I use my data run the circlize to plot the genomic Points track,It appear some Unexpected errors.all the points are gathered into several scaffold and some points out of track.the errors is that:
Note:6822 points are out of plotting region in sector 'scaffold_1', track '3'.

Note:7642 points are out of plotting region in sector 'scaffold_2', track '3'.

Note:7608 points are out of plotting region in sector 'scaffold_3', track '3'.

my bed1 files only have three column which only include chromosome and position and code is that: circos.genomicInitialize(bed1)

circos.genomicTrackPlotRegion(ylim=c(0,1),bg.col=rainbow(nrow(bed1)),track.height=0.1)

circos.genomicTrackPlotRegion(bed2,track.height=0.1,ylim = c(-1,1),panel.fun = function(region, value, ...) {circos.genomicPoints( region, value, pch = 16, cex = 0.1,...)})

Can anyone could how to explain it ?I am a new to plot the circos picture,Any help will be appreciated

Thanks

small sector value should perhaps be the largest value

Hi,

When there are many small sectors, perhaps it would make sense to use the last value of its arc rather than zero. Consider this picture

many zeros

It is clear that it starts from zero (from the context), but it would be nicer to see the total value, as is shown by default on larger arces. So for the larger red arc, it would show something like 110 or whatever is the numerical value.

BTW: Sorry if my terminology is off. I hope it's clear none the less.

Another thing is the overplotting of labels. I guess this is an issue that cannot be solved automatically, as it depends on the "width" of labels.

Thanks,
Rasmus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.