Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot CNV graphs over an Ideogram #120

Closed
andrisvAria opened this issue Aug 5, 2019 · 2 comments
Closed

Plot CNV graphs over an Ideogram #120

andrisvAria opened this issue Aug 5, 2019 · 2 comments

Comments

@andrisvAria
Copy link

Hello,

I need to create reports that contain two CNV graphs and an Ideogram, for 30 samples.
I have the following code which produces the CNV graph:

one=read.table("$sampleid.chr$chr.$start.signal",sep="\\t")
bmp(filename="$sampleid.chr$chr.$start.$end.CN$cn.bmp",width = 720, height = 720, res=300, pointsize=6)
par(mfrow=c(3,1),las=1,mar=c(4,4.2,1.5,1.3))

a=rep("blue",length(one\$V1))
for(i in 1:length(one\$V1)){
	if(one\$V1[i]>=$start1 & one\$V1[i]<=$end1){
		a[i]="red"
	}
}
plot(one\$V1,one\$V2,pch=20,cex=$cex,ylim=c($lrr_bound,1),ylab="Log R Ratio",xlab="Chr$chr Position ($megabp)",col=a)
title(paste("$sampleid.chr$chr.$start-$end","(CN=$cn)"))
abline(v=c($start1,$end1),col="grey",lty=1,lwd=0.3)
abline(h=0,col="grey",lty=2,lwd=0.3)
plot(one\$V1,one\$V3,pch=20,cex=$cex,ylim=c(0,1),ylab="B Allele Freq",xlab="Chr$chr Position ($megabp)",col=a)
abline(v=c($start1,$end1),col="grey",lty=1,lwd=0.3)

201025100257_R12C02 chr18 73410271 73557030 CN3

I would like to add the Ideogram of the respective chromosome below these two plots. I set the command par(mfrow=c(3,1),las=1,mar=c(4,4.2,1.5,1.3)) for three rows, so that in the last I get the ideogram.

I visualise the ideogram with this print(plotIdeogram(genome = "hg19"))
Rplot
but no matter what I have tried, the ideogram refuses to go under the existing plots, instead it overwrites them. Is it possible to manipulate the Ideogram object to make it follow my layout?

@lawremi
Copy link
Owner

lawremi commented Aug 5, 2019

ggbio produces graphics using the grid package, which is different from base graphics. The gridBase package might help you combine them; but I have no experience with it.

@andrisvAria
Copy link
Author

Thank you @lawremi , this worked great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants