ggbiplot

ggbiplot - change the group color and marker

微笑、不失礼 提交于 2020-01-11 02:58:06
问题 In the example ggbiplot script plot there are 3 groups, how can I change the marker colors and shapes? library(ggbiplot) data(wine) wine.pca <- prcomp(wine, scale. = TRUE) ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class, varname.size = 3, labels.size=3, ellipse = TRUE, circle = TRUE) + scale_color_discrete(name = '') + geom_point(aes(colour=wine.class), size = 3) + theme(legend.direction ='horizontal', legend.position = 'top') 回答1: The following works for me. ggbiplot(wine

ggbiplot - how not to use the feature vectors in the plot

血红的双手。 提交于 2020-01-01 06:33:06
问题 I have a dataset data$cell_line.sva , which has dim of 313 11875. cc.pca <- prcomp(data$cell_line.sva, center = TRUE, scale. = TRUE, retx = TRUE) g <- ggbiplot(cc.pca, obs.scale = 1, var.scale = 1, groups = as.factor(cgpResponse), ellipse = TRUE, circle = FALSE) How can I get rid of the feature names? (the red text) 回答1: I cannot quite figure out how this would yield a useful result, but here goes anyway. The names are not something that the function lets you suppress via parameter settings,

Adding ellipses to a principal component analysis (PCA) plot

纵饮孤独 提交于 2019-12-28 05:21:23
问题 I am having trouble adding grouping variable ellipses on top of an individual site PCA factor plot which also includes PCA variable factor arrows. My code: prin_comp<-rda(data[,2:9], scale=TRUE) pca_scores<-scores(prin_comp) #sites=individual site PC1 & PC2 scores, Waterbody=Row Grouping Variable. #site scores in the PCA plot are stratified by Waterbody type. plot(pca_scores$sites[,1], pca_scores$sites[,2], pch=21, bg=point_colors[data$Waterbody], xlim=c(-2,2), ylim=c(-2,2), xlab=x_axis_text,

change point colors and shapes in ggbiplot in r

大憨熊 提交于 2019-12-25 03:43:13
问题 I am using ggbiplot() and would like to manipulate the colors and shapes of the datapoints to make them more printer friendly. Currently I get the default rainbow of colors from ggbiplot(). I have tried using the arguments "+ scale_colour_discrete" and "+ scale_shape_manual" but the "groups=" argument ggbiplot seems to override these. If I eliminate the "groups=" argument then ellipses can't be drawn. The "+ theme" argument works just fine. My code is below. I know I could manipulate the

How to adjust ellipses overlap calculation in overlap{siar} to match normal probability ellipsoids in ggbiplot?

余生颓废 提交于 2019-12-11 00:12:03
问题 Going back to this thread, I was calculating the intersection between two ellipses e.g. the volume of the intersection between versicolor and virginca: using the following mwe: data(iris) log.ir <- log(iris[, 1:4]) ir.species <- iris[, 5] ir.pca <- prcomp(log.ir, center = TRUE, scale. = TRUE) library(ggbiplot) g <- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, groups = ir.species, ellipse = TRUE, circle = TRUE) g <- g + scale_color_discrete(name = '') g <- g + theme(legend.direction =

ggbiplot - change the point size

不打扰是莪最后的温柔 提交于 2019-12-07 12:21:01
问题 Does someone have an idea how to change the point size and still maintain the group colors in the code below? Just adding the geom_point(size = 8) changes the colors of all the points to black. Code: library(ggbiplot) data(wine) wine.pca <- prcomp(wine, scale. = TRUE) g <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, varname.size = 8, labels.size=10 , ellipse = TRUE, circle = TRUE) g <- g + scale_color_discrete(name = '') #+ geom_point(size = 8) g <- g + opts(legend

ggbiplot - how not to use the feature vectors in the plot

拟墨画扇 提交于 2019-12-03 17:17:34
I have a dataset data$cell_line.sva , which has dim of 313 11875. cc.pca <- prcomp(data$cell_line.sva, center = TRUE, scale. = TRUE, retx = TRUE) g <- ggbiplot(cc.pca, obs.scale = 1, var.scale = 1, groups = as.factor(cgpResponse), ellipse = TRUE, circle = FALSE) How can I get rid of the feature names? (the red text) I cannot quite figure out how this would yield a useful result, but here goes anyway. The names are not something that the function lets you suppress via parameter settings, at least to my reading of the code and help page. So looking at the code it looks as though the labels for

R: plotting posterior classification probabilities of a linear discriminant analysis in ggplot2

做~自己de王妃 提交于 2019-12-03 05:47:23
问题 Using ggord one can make nice linear discriminant analysis ggplot2 biplots (cf chapter 11, Fig 11.5 in "Biplots in practice" by M. Greenacre), as in library(MASS) install.packages("devtools") library(devtools) install_github("fawda123/ggord") library(ggord) data(iris) ord <- lda(Species ~ ., iris, prior = rep(1, 3)/3) ggord(ord, iris$Species) I would also like to add the classification regions (shown as solid regions of the same colour as their respective group with say alpha=0.5) or the

PCA Scaling with ggbiplot

烈酒焚心 提交于 2019-11-28 07:03:06
I'm trying to plot a principal component analysis using prcomp and ggbiplot . I'm getting data values outside of the unit circle, and haven't been able to rescale the data prior to calling prcomp in such a way that I can constrain the data to the unit circle. data(wine) require(ggbiplot) wine.pca=prcomp(wine[,1:3],scale.=TRUE) ggbiplot(wine.pca,obs.scale = 1, var.scale=1,groups=wine.class,ellipse=TRUE,circle=TRUE) I tried scaling by subtracting mean and dividing by standard deviation before calling prcomp : wine2=wine[,1:3] mean=apply(wine2,2,mean) sd=apply(wine2,2,mean) for(i in 1:ncol(wine2)

Adding ellipses to a principal component analysis (PCA) plot

你。 提交于 2019-11-27 19:25:14
I am having trouble adding grouping variable ellipses on top of an individual site PCA factor plot which also includes PCA variable factor arrows. My code: prin_comp<-rda(data[,2:9], scale=TRUE) pca_scores<-scores(prin_comp) #sites=individual site PC1 & PC2 scores, Waterbody=Row Grouping Variable. #site scores in the PCA plot are stratified by Waterbody type. plot(pca_scores$sites[,1], pca_scores$sites[,2], pch=21, bg=point_colors[data$Waterbody], xlim=c(-2,2), ylim=c(-2,2), xlab=x_axis_text, ylab=y_axis_text) #species=column PCA1 & PCA2 Response variables arrows(0,0,pca_scores$species[,1],pca