Problem on R when creating a PCA plot
1
0
Entering edit mode
24 months ago
José ▴ 10

A very weird thing is happening to me on R, the first time i installed "ggfortify" pacakage to create a PCA plot, the result was an Rplots.pdf file, it worked perfectly. The second time i used it, with the same exact data and commands, the result is an empty Rplots.pdf file and continues to happen every time i try to run R.

Can someone tell me what is the problem?

I used the following commands in R:

library("ggfortify")

q<-read.table("result_file_PCA.rel",head=F)
q2<-read.table("file1.clst",head=T)
autoplot(prcomp(q), data = q2,colour = 'CLUSTER')

Thank you very much for your help.

ggfortify R PCA • 1.1k views
ADD COMMENT
1
Entering edit mode
24 months ago

what's inside result_file_PCA.rel file and how was it generated?

ADD COMMENT
0
Entering edit mode

The file was generated using this command:

plink --file pruned_filter_file --make-rel square --out result_file_PCA

the weirdest thing is that the first time i used R the result was great, a PCA plot just like it was intended. Then, in the following times the result was everytime an empty Rplots.pdf. I checked the result_file_PCA.rel and it's a perfectly normal distance matrix, the file is ok. It's weird.

ADD REPLY
1
Entering edit mode

Can you see the output from autoplot? if so, you can save it as object some thing like this:

p=autoplot(prcomp(q), data = q2,colour = 'CLUSTER')
pdf("output.pdf")
print(p)
dev.off()

Since ggfortify is based on ggplot, you can also use ggsave to save a plot.

ADD REPLY
0
Entering edit mode

I followed your suggestion and it worked. Thank you very much.

ADD REPLY
0
Entering edit mode

I’ve had problems with saving some plots outside of package specific functions (ie ggsave). What I noticed was that it mainly occurred when trying to overwrite a file but not when creating a new file.

ADD REPLY

Login before adding your answer.

Traffic: 1308 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6