an error in ggbio: "Breaks and labels are different lengths"
0
0
Entering edit mode
Bogdan ▴ 670
@bogdan-2367
Last seen 14 months ago
Palo Alto, CA, USA

Dear all, I am using ggbio in order to display the arcs (interactions) between genes; however, at some point in the code, i am getting the error : "Error in f(..., self = self) : Breaks and labels are different lengths".

Any suggestions please on how to fix it ? A piece of R code (running on R3.3.3 is below) :


i <- read.delim("file1",header=TRUE) 
interactions_granges <-GRanges (seqnames=i$chr, IRanges(i$start,i$end), strand="*", intensity=i$intensity, experiment=i$experiment)

er <-  rtracklayer::import("er", format = "bed")
enh <- rtracklayer::import("enhancers", format = "bed")

g <- read.delim("regions",header=TRUE, stringsAsFactors=FALSE)

for (j in 1:nrow(g)) 
{

 chr <- g[j,]$chr  
start <- g[j,]$start  
end <- g[j,]$end 
gene <- g[j,]$gene 
region <- GRanges(chr, IRanges(start,end))  
   
   
gene_region <- autoplot(Homo.sapiens, which = region, color = "blue", fill = "blue",                             names.expr="SYMBOL") 

interactions_chr <- keepSeqlevels(interactions_granges,chr) ## 


hits <- findOverlaps(interactions_chr, region, type = 'within')
 
interactions_chr <- interactions_chr[queryHits(hits)] 

interactions_region <- autoplot(interactions_chr,geom="arch", aes(col=experiment, height=intensity, alpha = abs(intensity))) + xlim(region)

er_chr <- keepSeqlevels(er,chr) 
er_chr_plots <- autoplot(er_chr, geom="rect", fill ="red", col = "red" ) + scale_x_sequnit() + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + xlim(region)

enh_chr <- keepSeqlevels(enh,chr)
enh_chr_plots <- autoplot(enh_chr, geom="rect", fill = "purple", color="purple") + scale_x_sequnit() + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + xlim(region)

   

itracks <- tracks( "interactions" = interactions_region, "ER" = er_chr_plots, "ENH" = enh_chr_plots,

                            "genes" = gene_region, heights=c(4, 0.2, 0.2,  1) + 

                             xlim(region)  + theme(panel.background = element_rect(fill='transparent'))


   png(paste0("gene_", gene, "-" , chr, "-", start, "-", end, ".png" ), width=2000, height=1200)
   print(itracks) 
   dev.off()

 }

 

ggbio ggplot2 • 3.5k views
ADD COMMENT
0
Entering edit mode

Ayyy, nevermind, I think it was a mistake in my R script regarding the calculation of distances ;)

ADD REPLY

Login before adding your answer.

Traffic: 469 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6