我有一个函数,它将制表符分隔的文件作为输入,并为制表符分隔的文件中的值(每个文件一个散点图)创建散点图。我需要一个可以在一个 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 中..
由于照明文本文件很大..我给出了输入数据的最小信息代码如下
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))'
请帮助我
尝试将每个 PDF 保存到所需的文件夹中。请务必附加一些常用的名称功能,以便稍后进行匹配。函数完成后,使用正则表达式导入这些 PDF,并使用 qpdf 库 将 pdf 合并为一个更大的 PDF。
qpdf::pdf_combine(input = c("f1.pdf", "f2.pdf"),
output = "output.pdf")