我目前正在使用库(methylKit)来分析甲基化数据,作为此过程的一部分,我正在执行层次聚类和PCA来可视化我的数据。我想导出两者的图,但是当我尝试使用pdf()保存图时,文件被创建,但文件只有~380字节,并且无法通过Mac中的预览打开。我的代码如下:
对于分层聚类:
clustermap1 <- clusterSamples(meth,dist="correlation",method="ward",plot=TRUE)
pdf(file="ClusterMapCorrWard.pdf")
plot(clustermap1)
dev.off()
对于PCA Screeplot
pdf(file="PPCAScreeplot.pdf")
xx <- barplot(project.pca.proportionvariances,
cex.names = 1,
xlab = paste("Principal component (PC), 1-",length(project.pca$sdev)),
ylab = "Proportion of variation (%)",
main = "Scree plot",
ylim = c(0,20)
)
text(xx, y = project.pca.proportionvariances,
label = round(project.pca.proportionvariances,2),
pos = 3,
cex = 0.8)
dev.off()
对于PCA Pairs Plots
par(cex=1.0, cex.axis=0.8, cex.main=0.8)
pdf(file="PCAPairsplot1-6.pdf")
pairs(project.pca$x[,1:6],
col = "black",
main = "Principal components analysis bi-plot\nPCs 1-6",
pch = 16,
panel = function(x,...) {
text(project.pca$x, labels=minids, cex= 0.5, pos=3)
}
)
dev.off()
对于PCA Biplots
pdf(file="PCABiplotsPC1-2.pdf")
plot(project.pca$x,
type = "n",
main = "Principal components analysis bi-plot",
xlab = paste("PC1, ", round(project.pca.proportionvariances[1], 2), "%"),
ylab = paste("PC2, ", round(project.pca.proportionvariances[2], 2), "%"))
points(project.pca$x, col="black", pch=16, cex=1)
text(project.pca$x, labels=ids, cex= 0.7, pos=3)
dev.off()
我觉得令人困惑的是,此代码以前工作过,并成功输出了相应的图。但是,当我尝试在另一个数据集(相同类型和格式)上使用它时,它停止工作,现在也无法处理原始数据集。使用png()也可以输出图。
那我哪里出错了?
由于