vqv / ggbiplot

A biplot based on ggplot2
302 stars 159 forks source link

Error in choices when trying to choose PC1 vs PC3, but had no problem with PC2 vs 3. #46

Closed MeganS92 closed 5 years ago

MeganS92 commented 5 years ago

Hi,

I have just started using ggbiplot today. I have a very large matrix (16540 rows vs 1798 columns).

I ran my PCA using prcomp, such as:

pcaRes<- prcomp(t(log(TPM2+1)), center = T, scale. = T)

Interestingly, when I plot my PCA using a code like this:

ggbiplot(pcaRes, choices= 1:2, scale=1, pc.biplot= TRUE, ellipse= FALSE, circle= FALSE, groups=TP, varname.size = FALSE, var.axes= FALSE)

everything was fine.

However, when I chose other PCs, such as PC1 vs PC3, it returns me this error:

ggbiplot(pcaRes, choices= 1:3, ellipse= FALSE, circle= FALSE, groups=TP, varname.size = FALSE, var.axes= FALSE) They return me with this error: Error in ggbiplot(pcaRes, choices = 1:3, scale = 1, pc.biplot = TRUE, : length(choices) == 2 is not TRUE

However, when I repeated this for PC2 vs PC3, everything is fine.

Can someone help me out here please? Thanks so much!

Kind regards, Megan.

darekbienkowski commented 5 years ago

Hello,

A problem is documentation to function - choices = 1:3 is wrong. Choices = 1:3 is a sequence and it will create a vector c(1,2,3) and for PC1 vs PC7 1:7 c(1,2,3,4,5,6,7) instead of that use a vector c(1,3) should work PC1 vs PC7 => c(1,7) Also - maybe better to change a documentation for parameters - will be much easier for user to understand c(1,2) then 1:2

MeganS92 commented 5 years ago

Hi Bienias!

Wow! Thanks so much for this! Such a simple error, sorry I am very new in R- and obviously still could not fully grasp basic computing skills. And agreed with editing the documentation, but I'll it to the builder of the package.

Thanks so much for your help!

Kind regards, Megan.