R中单个Pdf中的多个散点图

时间:2011-09-27 14:20:13

标签: r scatter-plot

我有一个函数,它以制表符分隔文件作为输入,并在制表符分隔文件中为值(每个文件一个散点图)创建散点图。我需要一个可以在一个pdf文件中打印散点图的函数(即每页一个散点图。这是我的函数,它为每个文件打印一个散点图。

scatter.plot=function(file)
  {
  raw.Data=read.delim(file="D:/output/illumina.txt",row.names = 1, dec = ".")
  raw.expression <- raw.Data[,seq(1,dim(raw.Data)[2],2)]
  dim(raw.expression)   
  raw.calls <- raw.Data[,seq(2,dim(raw.Data)[2],2)]
  dim(raw.calls)
  IDs <- colnames(raw.expression)
  for (i in 1:(dim(raw.expression)[2]-1))
  {
  for( j in i:(dim(raw.expression)[2]) )
  {
  if (i != j)
  {          
  pdf(file=paste(directory,"/",IDs[i],"_gegen_",IDs[j],".pdf",sep=""))
  correlation <- round(cor(raw.expression[,i],raw.expression[,j]),2)
  maximum <- max(log2(raw.expression[,i]))
  minimum <- min(log2(raw.expression[,i]))      plot(log2(raw.expression[,i]),log2(raw.expression[,j]),xlab=IDs[i],ylab=IDs[j],pch='.',text(maximum-2,minimum+0.5,labels=paste("R = ",correlation,sep=""),pos=4,offset=0))
  dev.off()
  }         
  }
  }      
  }

上面的函数将illumina文本文件作为输入,并以单个pdf打印每个散点图。我想将它们全部放在一个pdf中。

由于illumina文本文件很大..我给出了输入数据的最小信息代码

input.file=list(ProbeID=c(870131,5310368,1070445,6770328,610373,450431,1050114,770300,3290546),X1692272066AAVGSignal=c(46.1234,48.73746,50.15939,51.36239,53.75028,55.18534,49.32711,49.49868,50.40989),X1692272066ADetectionPval=c(0.5924308,0.4665211,0.3595342,0.213246,0.1390102,0.5443959,0.5291121,0.4461426,0.6914119),X1692272066BAVGSignal=c(49.38838,50.76025,50.41117,50.52384,58.56867,55.49637,48.71999,57.0689,45.99026),X1692272066BDetectionPval=c(0.5851529,0.4556041,0.4905386,0.4818049,0.05604076,0.1441048,0.6375546,0.08515284,0.8377001),X1692272066CAVGSignal=c(52.47962,51.48042,51.93637,50.08885,56.68196,54.18305,52.03677,57.8032,52.71201),X1692272066CDetectionPval=c(0.4708879,0.5553129,0.5145561,0.661572,0.1783115,0.338428,0.5080058,0.1106259,0.4490539))'

请帮帮我

0 个答案:

没有答案