Re: [Bioc-devel] Error: invalid graphics state in creating vignettes

2019-05-02 Thread Shin, Sunyoung
   arrow=arrow(length = unit(0.1, "inches"), angle = 15, ends = 
"last"))
  grid.text("3'", x=unit(1, "npc") - unit(1, "lines"), gp=gpar(col="blue", 
cex=1), y=unit(1, "lines"))
  grid.text("5'", x=unit(2, "lines"), gp=gpar(col="blue", cex=1), y=unit(1, 
"lines"))
} else {
  grid.lines(x=c(convertUnit(unit(3, "lines"), "npc", valueOnly = TRUE), 1 - 
convertUnit(unit(1, "lines"), "npc", valueOnly = TRUE)),
 y=unit(1.5, "lines"), gp=gpar(col = "blue", lwd = 1.5, xpd=NA),
 arrow=arrow(length = unit(0.1, "inches"), angle = 15, ends = 
"first"))
  grid.text("5'", x=unit(1, "npc") - unit(1, "lines"), gp=gpar(col="blue", 
cex=1), y=unit(1, "lines"))
  grid.text("3'", x=unit(2, "lines"), gp=gpar(col="blue", cex=1), y=unit(1, 
"lines"))
}
popViewport()
popViewport()
  grid.text(label = paste(motif.match$motif, " Motif Scan for ", 
motif.match$snpid, sep=""),
y=unit(1, "npc") - unit(1.5, "lines"),
gp=gpar(cex.main=cex.main, fontface="bold"))

You may want to double check if I understand your parameters correctly. And add 
grid as a Import package.

Jianhong.

From: "Shin, Sunyoung" 
mailto:sunyoung.s...@utdallas.edu>>
Date: Sunday, April 28, 2019 at 3:55 PM
To: "Jianhong Ou, Ph.D." mailto:jianhong...@duke.edu>>, 
"bioc-devel@r-project.org<mailto:bioc-devel@r-project.org>" 
mailto:bioc-devel@r-project.org>>
Subject: Re: [Bioc-devel] Error: invalid graphics state in creating vignettes

Hello Jianhong,

Thank you very much for the quick response. I dropped all par commands, and 
used layout() instead of par(mfrow=c(4,1)). But, I still get the same error 
message. I put the updated code below. Do you have some suggestions on 
debugging?

* creating vignettes ... ERROR

--- re-building ‘atsnp-vignette.rmd’ using rmarkdown

Quitting from lines 292-294 (atsnp-vignette.rmd)

Error: processing vignette 'atsnp-vignette.rmd' failed with diagnostics:

invalid graphics state

--- failed re-building ‘atsnp-vignette.rmd’

plot.new()
  layout(matrix(c(1,2,3,4), 4, 1, byrow = TRUE))
  plotMotifLogo(pcm2pfm(ref_aug_pwm), "Best match to the reference genome", 
yaxis=FALSE, xaxis=FALSE, xlab="", ylab="PWM", ...)
if(motif.match$ref_strand=='+') {
arrows((min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, 
max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
} else {
arrows(max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, 
(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
}
plotMotifLogo(pcm2pfm(ref_aug_match_pwm), font="mono,Courier", yaxis=FALSE, 
xlab="", ylab=paste("(", motif.match$ref_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 0, col="blue", lty=3, lwd=2)
  if(motif.match$ref_strand=="+")   {
  mtext("5'", 1,  adj=0, padj=1, col="blue", cex=1)
  mtext("3'", 1,  adj=1, padj=1, col="blue", cex=1)
} else {
  mtext("3'", 1, adj=0, padj=1, col="blue", cex=1)
  mtext("5'", 1, adj=1, padj=1, col="blue", cex=1)
  }
plotMotifLogo(pcm2pfm(snp_aug_match_pwm), "Best match to the SNP genome", 
font="mono,Courier", yaxis=FALSE, xlab="", ylab=paste("(", 
motif.match$snp_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segment

Re: [Bioc-devel] Error: invalid graphics state in creating vignettes

2019-04-29 Thread Jianhong Ou, Ph.D.
 unit(1, "lines"), gp=gpar(col="blue", 
cex=1), y=unit(1, "lines"))
  grid.text("5'", x=unit(2, "lines"), gp=gpar(col="blue", cex=1), y=unit(1, 
"lines"))
} else {
  grid.lines(x=c(convertUnit(unit(3, "lines"), "npc", valueOnly = TRUE), 1 - 
convertUnit(unit(1, "lines"), "npc", valueOnly = TRUE)),
 y=unit(1.5, "lines"), gp=gpar(col = "blue", lwd = 1.5, xpd=NA),
 arrow=arrow(length = unit(0.1, "inches"), angle = 15, ends = 
"first"))
  grid.text("5'", x=unit(1, "npc") - unit(1, "lines"), gp=gpar(col="blue", 
cex=1), y=unit(1, "lines"))
  grid.text("3'", x=unit(2, "lines"), gp=gpar(col="blue", cex=1), y=unit(1, 
"lines"))
}
popViewport()
popViewport()
  grid.text(label = paste(motif.match$motif, " Motif Scan for ", 
motif.match$snpid, sep=""),
y=unit(1, "npc") - unit(1.5, "lines"),
gp=gpar(cex.main=cex.main, fontface="bold"))

You may want to double check if I understand your parameters correctly. And add 
grid as a Import package.

Jianhong.

From: "Shin, Sunyoung" 
Date: Sunday, April 28, 2019 at 3:55 PM
To: "Jianhong Ou, Ph.D." , "bioc-devel@r-project.org" 

Subject: Re: [Bioc-devel] Error: invalid graphics state in creating vignettes

Hello Jianhong,

Thank you very much for the quick response. I dropped all par commands, and 
used layout() instead of par(mfrow=c(4,1)). But, I still get the same error 
message. I put the updated code below. Do you have some suggestions on 
debugging?

* creating vignettes ... ERROR

--- re-building ‘atsnp-vignette.rmd’ using rmarkdown

Quitting from lines 292-294 (atsnp-vignette.rmd)

Error: processing vignette 'atsnp-vignette.rmd' failed with diagnostics:

invalid graphics state

--- failed re-building ‘atsnp-vignette.rmd’
plot.new()
  layout(matrix(c(1,2,3,4), 4, 1, byrow = TRUE))
  plotMotifLogo(pcm2pfm(ref_aug_pwm), "Best match to the reference genome", 
yaxis=FALSE, xaxis=FALSE, xlab="", ylab="PWM", ...)
if(motif.match$ref_strand=='+') {
arrows((min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, 
max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
} else {
arrows(max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, 
(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
}
plotMotifLogo(pcm2pfm(ref_aug_match_pwm), font="mono,Courier", yaxis=FALSE, 
xlab="", ylab=paste("(", motif.match$ref_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 0, col="blue", lty=3, lwd=2)
  if(motif.match$ref_strand=="+")   {
  mtext("5'", 1,  adj=0, padj=1, col="blue", cex=1)
  mtext("3'", 1,  adj=1, padj=1, col="blue", cex=1)
} else {
  mtext("3'", 1, adj=0, padj=1, col="blue", cex=1)
  mtext("5'", 1, adj=1, padj=1, col="blue", cex=1)
  }
plotMotifLogo(pcm2pfm(snp_aug_match_pwm), "Best match to the SNP genome", 
font="mono,Courier", yaxis=FALSE, xlab="", ylab=paste("(", 
motif.match$snp_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif

Re: [Bioc-devel] Error: invalid graphics state in creating vignettes

2019-04-28 Thread Shin, Sunyoung
Hello Jianhong,

Thank you very much for the quick response. I dropped all par commands, and 
used layout() instead of par(mfrow=c(4,1)). But, I still get the same error 
message. I put the updated code below. Do you have some suggestions on 
debugging?

* creating vignettes ... ERROR
--- re-building ‘atsnp-vignette.rmd’ using rmarkdown
Quitting from lines 292-294 (atsnp-vignette.rmd)
Error: processing vignette 'atsnp-vignette.rmd' failed with diagnostics:
invalid graphics state
--- failed re-building ‘atsnp-vignette.rmd’

plot.new()
  layout(matrix(c(1,2,3,4), 4, 1, byrow = TRUE))
  plotMotifLogo(pcm2pfm(ref_aug_pwm), "Best match to the reference genome", 
yaxis=FALSE, xaxis=FALSE, xlab="", ylab="PWM", ...)
if(motif.match$ref_strand=='+') {
arrows((min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, 
max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
} else {
arrows(max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, 
(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
}
plotMotifLogo(pcm2pfm(ref_aug_match_pwm), font="mono,Courier", yaxis=FALSE, 
xlab="", ylab=paste("(", motif.match$ref_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 0, col="blue", lty=3, lwd=2)
  if(motif.match$ref_strand=="+")   {
  mtext("5'", 1,  adj=0, padj=1, col="blue", cex=1)
  mtext("3'", 1,  adj=1, padj=1, col="blue", cex=1)
} else {
  mtext("3'", 1, adj=0, padj=1, col="blue", cex=1)
  mtext("5'", 1, adj=1, padj=1, col="blue", cex=1)
  }
plotMotifLogo(pcm2pfm(snp_aug_match_pwm), "Best match to the SNP genome", 
font="mono,Courier", yaxis=FALSE, xlab="", ylab=paste("(", 
motif.match$snp_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 0, col="blue", lty=3, lwd=2)
  if(motif.match$snp_strand=="+")   {
  mtext("5'", 1,  adj=0, padj=1, col="blue", cex=1)
  mtext("3'", 1,  adj=1, padj=1, col="blue", cex=1)
} else {
  mtext("3'", 1, adj=0, padj=1, col="blue", cex=1)
  mtext("5'", 1, adj=1, padj=1, col="blue", cex=1)
  }
plotMotifLogo(pcm2pfm(snp_aug_pwm), yaxis=FALSE, xaxis=FALSE, xlab="", 
ylab="PWM", ...)
if(motif.match$snp_strand=='+') {
arrows((min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), -0.17, 
max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=(min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), 
padj=1, col="blue", cex=1)
} else {
arrows(max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), -0.17, 
(min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=(min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), 
padj=1, col="blue", cex=1)
}
title(main=paste(motif.match$motif, " Motif Scan for ", motif.match$snpid, 
sep=""), outer=TRUE, line=-2, cex.main=cex.main)
}


Best,
Sunyoung

On Apr 23, 2019, at 7:57 AM, Jianhong Ou, Ph.D. 
mailto:jianhong...@duke.edu>> wrote:

Hi Sunyong,

plotMotifLogo does not compatible with par now. Please use grid to plot the 
multiple panels in one canvas. I am working on this but it takes time.

Jianhong.

On 4/23/19, 12:47 AM, "Bioc-devel on behalf of Shin, Sunyoung" 
mailto:bioc-devel-boun...@r-project.org> on 
behalf of sunyoung.s...@utdallas.edu> wrote:

   Dear all,

   I got an error message: invalid 

Re: [Bioc-devel] Error: invalid graphics state in creating vignettes

2019-04-23 Thread Jianhong Ou, Ph.D.
Hi Sunyong,

plotMotifLogo does not compatible with par now. Please use grid to plot the 
multiple panels in one canvas. I am working on this but it takes time.

Jianhong.

On 4/23/19, 12:47 AM, "Bioc-devel on behalf of Shin, Sunyoung" 
 
wrote:

Dear all,

I got an error message: invalid graphics state as below from BUILD report 
for atSNP 0.99.23 
(https://urldefense.proofpoint.com/v2/url?u=https-3A__master.bioconductor.org_packages_3.9_bioc_html_atSNP.html=DwIGaQ=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=PXg851DHXyo-Gs3eMIfeo49gUXVh-JSZu_MZDDxGun8=PbqNdXfVMLxlePSjrHOEN8-tkQLva8Pg6UAfB4VOTUw=lESpOegy3zU7jKZUfxiUhG5mSg7qotzhof_KHZmVEB8=).
 This occurs on every platform: malbec2, tokay2, and celaya2. Running  
devtools::check()  on my local computer does not produce the error. I would 
appreciate it if anyone can help debugging.

* creating vignettes ... ERROR

--- re-building ‘atsnp-vignette.rmd’ using rmarkdown
Quitting from lines 292-294 (atsnp-vignette.rmd)
Error: processing vignette 'atsnp-vignette.rmd' failed with diagnostics:
invalid graphics state
--- failed re-building ‘atsnp-vignette.rmd’

SUMMARY: processing the following file failed:
  ‘atsnp-vignette.rmd’

Error: Vignette re-building failed.
Execution halted

The graphing function which makes the error is plotMotifMatch(match.seq,  
motif.lib = motif_library). Below is the part of the code that is needed  to be 
fixed, I think.

{
  par(mfrow=c(4,1), oma=c(1,1,4,1))
  plot.new()
  par(mar=c(1.5, 3, 4, 2))
  plotMotifLogo(pcm2pfm(ref_aug_pwm), "Best match to the reference genome", 
yaxis=FALSE, xaxis=FALSE, xlab="", ylab="PWM", ...)
if(motif.match$ref_strand=='+') {
arrows((min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, 
max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, 
adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), padj=1, 
col="blue", cex=1)
  mtext("3'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
} else {
arrows(max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, 
(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, 
adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), padj=1, 
col="blue", cex=1)
}
  par(mar = c(4, 3, 1.5, 2))
plotMotifLogo(pcm2pfm(ref_aug_match_pwm), font="mono,Courier", yaxis=FALSE, 
xlab="", ylab=paste("(", motif.match$ref_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 0, col="blue", lty=3, lwd=2)
  if(motif.match$ref_strand=="+")   {
  mtext("5'", 1,  adj=0, padj=1, col="blue", cex=1)
  mtext("3'", 1,  adj=1, padj=1, col="blue", cex=1)
} else {
  mtext("3'", 1, adj=0, padj=1, col="blue", cex=1)
  mtext("5'", 1, adj=1, padj=1, col="blue", cex=1)
  }
par(mar=c(1.5, 3, 4, 2))
plotMotifLogo(pcm2pfm(snp_aug_match_pwm), "Best match to the SNP genome", 
font="mono,Courier", yaxis=FALSE, xlab="", ylab=paste("(", 
motif.match$snp_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 0, col="blue", lty=3, lwd=2)
  if(motif.match$snp_strand=="+")   {
  mtext("5'", 1,  adj=0, padj=1, col="blue", cex=1)
  mtext("3'", 1,  adj=1, padj=1, col="blue", cex=1)
} else {
  mtext("3'", 1, adj=0, padj=1, col="blue", cex=1)
  mtext("5'", 1, adj=1, padj=1, col="blue", cex=1)
  }
par(mar=c(4, 3, 1.5, 2))
plotMotifLogo(pcm2pfm(snp_aug_pwm), yaxis=FALSE, xaxis=FALSE, xlab="", 
ylab="PWM", ...)
if(motif.match$snp_strand=='+') {
arrows((min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), -0.17, 
max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, 

[Bioc-devel] Error: invalid graphics state in creating vignettes

2019-04-22 Thread Shin, Sunyoung
Dear all,

I got an error message: invalid graphics state as below from BUILD report for 
atSNP 0.99.23 
(https://master.bioconductor.org/packages/3.9/bioc/html/atSNP.html). This 
occurs on every platform: malbec2, tokay2, and celaya2. Running  
devtools::check()  on my local computer does not produce the error. I would 
appreciate it if anyone can help debugging.

* creating vignettes ... ERROR

--- re-building ‘atsnp-vignette.rmd’ using rmarkdown
Quitting from lines 292-294 (atsnp-vignette.rmd)
Error: processing vignette 'atsnp-vignette.rmd' failed with diagnostics:
invalid graphics state
--- failed re-building ‘atsnp-vignette.rmd’

SUMMARY: processing the following file failed:
  ‘atsnp-vignette.rmd’

Error: Vignette re-building failed.
Execution halted

The graphing function which makes the error is plotMotifMatch(match.seq,  
motif.lib = motif_library). Below is the part of the code that is needed  to be 
fixed, I think.

{
  par(mfrow=c(4,1), oma=c(1,1,4,1))
  plot.new()
  par(mar=c(1.5, 3, 4, 2))
  plotMotifLogo(pcm2pfm(ref_aug_pwm), "Best match to the reference genome", 
yaxis=FALSE, xaxis=FALSE, xlab="", ylab="PWM", ...)
if(motif.match$ref_strand=='+') {
arrows((min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, 
max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
} else {
arrows(max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), -0.17, 
(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=max(which(colSums(ref_aug_pwm)!=0))/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=(min(which(colSums(ref_aug_pwm)!=0))-1)/ncol(ref_aug_pwm), 
padj=1, col="blue", cex=1)
}
  par(mar = c(4, 3, 1.5, 2))
plotMotifLogo(pcm2pfm(ref_aug_match_pwm), font="mono,Courier", yaxis=FALSE, 
xlab="", ylab=paste("(", motif.match$ref_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 0, col="blue", lty=3, lwd=2)
  if(motif.match$ref_strand=="+")   {
  mtext("5'", 1,  adj=0, padj=1, col="blue", cex=1)
  mtext("3'", 1,  adj=1, padj=1, col="blue", cex=1)
} else {
  mtext("3'", 1, adj=0, padj=1, col="blue", cex=1)
  mtext("5'", 1, adj=1, padj=1, col="blue", cex=1)
  }
par(mar=c(1.5, 3, 4, 2))
plotMotifLogo(pcm2pfm(snp_aug_match_pwm), "Best match to the SNP genome", 
font="mono,Courier", yaxis=FALSE, xlab="", ylab=paste("(", 
motif.match$snp_strand, ")", sep=""), ...)
segments(snp_loc/motif.match$snp_ref_length, 0, 
snp_loc/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 1, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments((snp_loc+1)/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 1, col="blue", lty=3, lwd=2)
segments(snp_loc/motif.match$snp_ref_length, 0, 
(snp_loc+1)/motif.match$snp_ref_length, 0, col="blue", lty=3, lwd=2)
  if(motif.match$snp_strand=="+")   {
  mtext("5'", 1,  adj=0, padj=1, col="blue", cex=1)
  mtext("3'", 1,  adj=1, padj=1, col="blue", cex=1)
} else {
  mtext("3'", 1, adj=0, padj=1, col="blue", cex=1)
  mtext("5'", 1, adj=1, padj=1, col="blue", cex=1)
  }
par(mar=c(4, 3, 1.5, 2))
plotMotifLogo(pcm2pfm(snp_aug_pwm), yaxis=FALSE, xaxis=FALSE, xlab="", 
ylab="PWM", ...)
if(motif.match$snp_strand=='+') {
arrows((min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), -0.17, 
max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=(min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), 
padj=1, col="blue", cex=1)
} else {
arrows(max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), -0.17, 
(min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), -0.17, length = 0.1, 
angle = 15, code = 2, col = "blue", lwd = 1.5, xpd=NA)
  mtext("5'", 1, adj=max(which(colSums(snp_aug_pwm)!=0))/ncol(snp_aug_pwm), 
padj=1, col="blue", cex=1)
  mtext("3'", 1, adj=(min(which(colSums(snp_aug_pwm)!=0))-1)/ncol(snp_aug_pwm), 
padj=1, col="blue", cex=1)
}
title(main=paste(motif.match$motif, " Motif Scan for ", motif.match$snpid, 
sep=""), outer=TRUE, cex.main=cex.main)
}

Just in case, I