vqv / ggbiplot Goto Github PK
View Code? Open in Web Editor NEWA biplot based on ggplot2
A biplot based on ggplot2
Hi,
Does anyone know which parameter can be used to change the color of varname?
I'd love to use ggbiplot + #18 inside qmethod for aiorazabala/qmethod#162.
What would be the best way to include your (great) work in a CRAN package (qmethod is on CRAN)?
I am wondering both technically, as well as license- and recognition-wise, and I want to do right by our contributions.
For now, I have added ggbiplot
as a submodule, but, predictably, R CMD check --as-cran
does not much like that.
Hey, I am trying to install ggbiplot on R x64 3.3.1 on windows 7 using the R command:
library(devtools)
install_github("vqv/ggbiplot")
Downloading GitHub repo vqv/ggbiplot@master
from URL https://api.github.com/repos/vqv/ggbiplot/zipball/master
Installing ggbiplot
Installing 1 package: scales
Installing package into ‘C:/Users/admin/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
essai de l'URL 'https://cran.univ-paris1.fr/bin/windows/contrib/3.3/scales_0.4.1.zip'
Content type 'application/zip' length 670692 bytes (654 KB)
downloaded 654 KB
package ‘scales’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘scales’
The downloaded binary packages are in
C:\Users\admin\AppData\Local\Temp\RtmpQXIjyl\downloaded_packages
"C:/PROGRA1/R/R-331.1/bin/x64/R" --no-site-file --no-environ --no-save
--no-restore --quiet CMD INSTALL
"C:/Users/admin/AppData/Local/Temp/RtmpQXIjyl/devtools1b68206338e1/vqv-ggbiplot-7325e88"
--library="C:/Users/admin/Documents/R/win-library/3.3" --install-tests
ERROR: dependency 'scales' is not available for package 'ggbiplot'
I also tried
install_github("ggbiplot","vqv")
Currently ggbiplot
plots all observations. I have a PCA model built on 1M observations, so would like to plot a random sample of them, typically as # not %.
Are there any way to select which feature arrows to draw? Thanks...
Just to let you know: the code of the ggbiplot()
function of this package as developed over 5 years ago, was used by us to create the ggplot_pca()
function for the AMR
package. An update containing this function is now available on CRAN and we maintain it actively. Many thanks for your work, Vince Vu!
Under Source, we tried our best to give proper attribution so there we state:
Source
The
ggplot_pca()
function is based on theggbiplot()
function from theggbiplot
package by Vince Vu, as found on GitHub: https://github.com/vqv/ggbiplot (retrieved: 2 March 2020, their latest commit: 7325e88; 12 February 2015).As per their GPL-2 licence that demands documentation of code changes, the changes made based on the source code were:
- Rewritten code to remove the dependency on packages
plyr
,scales
andgrid
- Parametrised more options, like arrow and ellipse settings
- Hardened all input possibilities by defining the exact type of user input for every argument
- Added total amount of explained variance as a caption in the plot
- Cleaned all syntax based on the
lintr
package, fixed grammatical errors and added integrity checks- Updated documentation
Our source code for the ggplot_pca()
function is available here on GitHub.
This also 'solves' issues #61, #60, #57, #56, #53, #52, #51, #49, #34, #72 and probably more.
Hi, would it be possible to add a parameter to omit drawing datapoints altogether? I have huge datasets with hundreds of thousands of points and I'm interested in displaying only the loading vectors and centroids. I know can use alpha=0, but even in this case, the plot takes ages to draw and the exported PDF still contains all the points, making it a huge file. A parameter that completely switches off plotting of datapoints (either as labels or as points) would be great.
Thanks!
I have passed a dataset to prcomp() to create a fit for PCA.
I use ggbiplot() to plot the figure as follows:
pop_pca <- ggbiplot(fit,obs.scale = 1, var.scale=1,groups=Patients,ellipse=T,circle=T,
varname.size=0, var.axes = FALSE)+
scale_colour_manual(values=colors)+guides(fill=guide_legend(nrow=2,byrow=TRUE))
pop_pca <- pop_pca + theme_bw()
I would like to alter the outline of each point in the plot based on values in a second dataset. The second dataset has values for each point in the first dataset. Is this possible with ggbiplot()?
Downloading GitHub repo vqv/ggbiplot@master
from URL https://api.github.com/repos/vqv/ggbiplot/zipball/master
Installing ggbiplot
"C:/Program Files/R/R-3.2.3/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL
"C:/Users/CJ/AppData/Local/Temp/RtmpETbrix/devtools10e07cfd71c2/vqv-ggbiplot-7325e88"
--library="C:/Users/CJ/Documents/R/win-library/3.2" --install-tests
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed (1)
Hi,
How can I change in the script below the PCA arrows labels (e.g., change MalicAcid to MA and Proline to PR)?
Script:
library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
ggbiplot(wine.pca, obs.scale = 1, var.scale = 1,
groups = wine.class, ellipse = TRUE, circle = TRUE) +
scale_color_discrete(name = '') +
theme(legend.direction = 'horizontal', legend.position = 'top')
Thanks
Can you include an option to plot the arrows on top of the points instead of underneath? I have a lot of points in my plot, and I can't see the arrows because they are plotted under all the points.
I have a problem in installation of ggbiplot and the error is Error: Failed to install 'unknown package' from GitHub:
schannel: next InitializeSecurityContext failed: SEC_E_CERT_EXPIRED (0x80090328) - The received certificate has expired.
please help me for resolving the error
thanks
In R,
library(devtools) ##gives following error
Error in library(devtools) : there is no package called ‘devtools’
How to fix it?
I try to install with the command: devtools::install_github("vqv/ggbiplot", ref = "experimental")
.
I get the error:
** preparing package for lazy loading
Error in eval(expr, envir, enclos) : could not find function "eval"
Error : unable to load R code in package ‘ggbiplot’
ERROR: lazy loading failed for package ‘ggbiplot’
R 3.2.4, ggplot 2.1.0
The warning and fault were attached following:
install_github("vqv/ggbiplot", force = T)
Enter one or more numbers, or an empty line to skip updates:
1
tibble (2.1.3 -> 3.0.0) [CRAN]
Installing 1 packages: tibble
Installing package into ‘\a00519.science.domain/jhg223/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
tibble 2.1.3 3.0.0 TRUE
Binaries will be installed
Error: Failed to install 'ggbiplot' from GitHub:
(converted from warning) package ‘tibble’ is in use and will not be installed
I've tried the experimental or not experimental versions of vqv, richardjtelford and vangalamaheshh github ggbiplot sites without success
qmethod
is a CRAN package that does Q methodology, which is basically a factor analysis with the data table turned sideways, so that there are people-variables and item-cases (weird, I know).
qmethod
essentially wraps psych::principal
(plus some bells and whistles), so it should be possible to extract a pcobj
from it so it can be used as an input to ggbiplot()
(which is great).
This duplicates much, though not all, of #17
Hi,
I have tried to install ggbiplot using :
> library(devtools)
> install_github("vqv/ggbiplot", ref = "experimental")
And I get the following output :
Downloading GitHub repo vqv/ggbiplot@experimental
from URL https://api.github.com/repos/vqv/ggbiplot/zipball/experimental
Installation failed: error in running command
I'm using R version 3.4.1 (2017-06-30) -- "Single Candle"
Any hint ?
Please ask the teachers, it is no problem to start using ggbiplot. Today, Error in plot_label (p = p, data = plot.data, label = label, label.label = label.label,
Unsupported class: prcomp, there has been no solution
I am trying to create a biplot using ggbiplot. I am almost there; howver, I just cannot seem to add the group names to my biplot. I converted the group column to dataframe and got the above error message. However, if I retain the group column as a vector, I get this error message: "Error in names(ell) <- *vtmp*
:
'names' attribute [2] must be the same length as the vector [0]"
Rplot.pdf
g <- ggbiplot(pca_vistra_rms, obs.scale = 1, group=vistra.group, var.scale = 1, ellipse = TRUE, circle = TRUE)+ scale_color_discrete(name = '') + theme(legend.direction = 'horizontal', legend.position = 'top')
print(g)
I got PAT and installed "devtools", after that I entered install_github("vqv/ggbiplot") but error massage was displayed as follows.
Using github PAT from envvar GITHUB_PAT
Error: Failed to install 'unknown package' from GitHub:
HTTP error 401.
Bad credentials
I thought I needed to have more step to verify the PAT and I entered install_github(..., auth_token = "<PAT#>"), but error massage was displayed again.
I would like to use ggbiplot for my research. I appreciate it, If someone could give me the guidance for installation. Thank you.
Trying to make PCA's using ggbiplot, however I cannot change the axis limits so I can make all of the scales the same for easy comparison.
would be nice if more PCA packages would be supported; I'm trying to hack this together myself, but I'm not familiar with SVD, so I'm not sure how to get back to the kind of data that ggbiplot()
expects.
I have been unable to manipulate the code such that I can specify the legend title. Do you have any pointers on how I can achieve this?
This is an excellent package!!
Nick
Could anyone please solve this issue for me? I would be much obliged!
library(devtools)
Loading required package: usethis
Warning messages:
1: package ‘devtools’ was built under R version 3.6.1
2: package ‘usethis’ was built under R version 3.6.1
install_github('vqv/ggbiplot',force =T)
Downloading GitHub repo vqv/ggbiplot@master
√ checking for file 'C:\Users\jada\AppData\Local\Temp\Rtmp8aKj9q\remotes315473d66def\vqv-ggbiplot-7325e88/DESCRIPTION' ...
Installing package into ‘C:/Users/jada/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
Hi!
How should I cite your package in my paper?
Best,
Hannes
Hi! Great package!
I've went trough tutorial in your README.md file in experimental branch and there occured to be an error with geom circle.
Hope you gonna make it! Keep working on it, it;s great!
> library(devtools)
> install_github("vqv/ggbiplot", ref = "experimental")
Downloading github repo vqv/ggbiplot@experimental
Installing ggbiplot
"D:/R-32~1.2/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore CMD INSTALL \
"C:/Users/Marcin/AppData/Local/Temp/RtmpkNV6XV/devtools16d8138e7064/vqv-ggbiplot-81e70b5" \
--library="C:/Users/Marcin/Documents/R/win-library/3.2" --install-tests
* installing *source* package 'ggbiplot' ...
** R
** data
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (ggbiplot)
Reloading installed ggbiplot
> library(ggbiplot)
> data(wine)
> cultivar <- wine.class
> m <- prcomp(wine, scale = TRUE)
> qplot(PC1, PC2, data = fortify(m), color = cultivar)
> qplot(PC1, PC2, data = fortify(m), color = cultivar) +
+ stat_ellipse(aes(group = cultivar))
> df <- fortify(m)
> g <- ggplot(df, aes(x = PC1, PC2)) +
+ geom_point(aes(color = cultivar)) +
+ geom_axis(data = attr(df, "basis"), aes(label = .name))
> print(g)
> df <- fortify(m, scale = 1, equalize = FALSE)
> g <- ggplot(df, aes(x = PC1, PC2)) +
+ geom_point(aes(color = cultivar)) +
+ geom_axis(data = attr(df, "basis"), aes(label = .name)) +
+ annotate("circle", x = 0, y = 0, radius = 1, alpha = 1/4)
Error: No geom called circle
> print(g)
> df <- fortify(m, scale = 1, equalize = FALSE)
> g <- ggplot(df, aes(x = PC1, PC2)) +
+ geom_point(aes(color = cultivar)) +
+ stat_ellipse(aes(group = cultivar, color = cultivar))
> g <- g + scale_color_discrete(name = '')
> g <- g + theme(legend.direction = 'horizontal', legend.position = 'top')
> g <- g + coord_equal()
>
> g1 <- g + geom_axis(data = attr(df, "basis"), aes(label = .name)) +
+ annotate("circle", x = 0, y = 0, radius = 1, alpha = 1/4)
Error: No geom called circle
>
> print(g1)
Error in print(g1) : object 'g1' not found
> g2 <- g + geom_axis(data = subset(attr(df, "basis"), PC1^2 + PC2^2 > 1/3),
+ aes(PC1 * 1.1, PC2 * 1.1, label = .name)) +
+ annotate("circle", x = 0, y = 0, radius = 1.1, alpha = 1/4)
Error: No geom called circle
>
> print(g2)
Error in print(g2) : object 'g2' not found
Dear All, I,ve got the following error, could you please give me some advice on this?
install_github("vqv/ggbiplot")
Downloading GitHub repo vqv/ggbiplot@master
from URL https://api.github.com/repos/vqv/ggbiplot/zipball/master
Error in curl::curl_fetch_memory(url, handle = handle) :
Problem with the SSL CA cert (path? access rights?)
I'm getting the following error message during installation. Any idea to fix this. Thanks
Installing github repo(s) ggbiplot/master from vqv
Installing ggbiplot.zip from https://github.com/vqv/ggbiplot/zipball
Installing ggbiplot
Warning: invalid package 'Yaseen/R/win-library/2.14'
Error: ERROR: cannot cd to directory 'C:/Users/Muhammad'
Error: Command failed (1)
In addition: Warning message:
running command '"C:/PROGRA1/R/R-2141.2/bin/i386/R" CMD INSTALL C:\Users\MUHAMM~1\AppData\Local\Temp\Rtmpsx4n5u/ggbiplot_0.5.tar.gz --library=C:/Users/Muhammad Yaseen/R/win-library/2.14' had status 1
When I try to install I get the following in RStudio:
"package ‘ggbiplot’ is not available (for R version 3.1.2)"
> install_github("ggbiplot", "vqv")
Installing github repo ggbiplot/master from vqv
Downloading master.zip from https://github.com/vqv/ggbiplot/archive/master.zip
Error en function (type, msg, asError = TRUE) : <not set>
I am using the ggbiplot function while writing my thesis. I am having a lot of trouble with the unnecessary whitespace around the plot. sometime it is good, but not always. I tried using plot.margin on theme, but it did not worked. Is there any way, you can put some option on the plot, or can you guide me to remove the whitespace. All the other feature are very fine.
The dependency on plyr
means that ggbiplot
masks functions from dplyr
. This isn't too much of a problem if loading the package using library(ggbiplot)
, as I can just reorder my imports, but ggbiplot
also loads all of plyr
if you use the ggbiplot::ggbiplot()
syntax.
So currently there is no way of preventing ggbiplot
from masking dplyr
functions without ensuring that you explicitly import ggbiplot
first.
Is there some way of changing how ggbiplot
uses the functions from plyr
to prevent it being fully loaded when you use the ggbiplot::ggbiplot()
syntax?
How can I set a minimum number of loading axis in the plot as I don't want to show all axis.
Hi
Is there a way i can get the equation if the ellipse that are formed through the ggbiplot function.
Thank you
When loading ggbiplot (library(ggbiplot)
the following message appears
Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘scales’ 0.4.1 is being loaded, but >= 0.4.1.9002 is required
Error: package ‘ggplot2’ could not be loaded
However, version 0.4.1.9002 of Scales does not seem to exist. It is unavailable through install.packages()
and it is not listed at https://github.com/hadley/scales/releases.
Using ggbiplot version 0.55 on R 3.4.1 on Ubuntu 16.04.
Thanks in advance.
I tried to install the package with my Rstudio (v 1.1.456) and R v3.5 on a Mac.
using:
install.packages("devtools")
library(devtools)
install_github("vqv/ggbiplot")
but it returns the following error:
"Error: (converted from warning) Setting LC_CTYPE failed, using "C"
Execution halted
Error in i.p(...) :
(converted from warning) installation of package '/var/folders/f1/7bhhfp9s5cggkbvgb0tjhwsw0000gn/T//RtmphcjUdD/file93a4170d51ef/ggbiplot_0.55.tar.gz' had non-zero exit status"
Any comments or suggestions are very much welcome
When I mistakenly put the object returned by prcomp() in the labels argument of ggbiplot(), it runs forever. It shows no warning or error, just keeps running. I don't know what's the issue. I had to terminate the R session. I think it should stop running and show an error message instead.
library(devtools)
library(usethis)
install_github("vqv/ggbiplot")
Error in normalizePath(key$InstallPath, mustWork = FALSE, winslash = "/") :
The library allows drawing a normal data ellipse for each group. Is there any way to choose to what group draws an ellipse?
and thanks a lot for this package!
Hello,
I am trying to increase the labels on the tip of the arrows, but so far I was not be able.
"labels.size" is not working...
Any advise?
Thanks,
Marco
I'm trying to make the lines thicker for the arrows and circle. The code I am using for my plot is below:
g <- ggbiplot(PCA, obs.scale = 1, var.scale = 1, ellipse = TRUE, circle = TRUE, varname.size=6)
g <- g + geom_point(aes(size=10)) +
scale_size(guide="none") +
theme_bw() +
theme(legend.key = element_blank()) +
theme(axis.text.y=element_text(size=26, hjust=0)) +
theme(text=element_text(family="Times New Roman",size=26)) +
theme(panel.border = element_rect(linetype = 1, size=2, colour="black"))
Any suggestions? Thanks a lot.
"opts" is not used by ggplot2, could you kindly updated with "theme"?
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.
Hi, The code that I ran to instal ggbilpot is : install_github("vqv/ggbiplot")
Then at first I get the error......
ERROR: failed to lock directory 'C:/Users/ayush/Documents/R/win-library/3.5' for modifying
Try removing 'C:/Users/ayush/Documents/R/win-library/3.5/00LOCK-vqv-ggbiplot-7325e88'
In R CMD INSTALL
Then when I go ahead and remove the file suggested above and re run the same installation code I get the error.....
*** installing source package 'ggbiplot' ...
Warning in file.copy(f, instdir, TRUE) :
problem copying .\NAMESPACE to C:\Users\ayush\Documents\R\win-library\3.5\ggbiplot\NAMESPACE: Permission denied
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/ayush/Documents/R/win-library/3.5/ggbiplot/DESCRIPTION': Permission denied
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'ggbiplot'
Please help. Thanks in advance.
Ayush
Hi is it possible to compute this function with an object of phyl.pca?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.