1

I am trying to draw a biplot using the function fviz_pca_biplot. I would like to see how the replicates (I have two/three replicates for every variety) in three different treatments behave.

I have two/three replicates (Rep) for every variety. I would like to know if it is possible to have two level to draw the plot:

  • a first one to define the variety, by shape of the point (every point is a replicate).

  • one level to define the treatment by the color used for fillment of the point.

Here is an example of my data set, my complete data set that I want to use for the biplot has in total 153 observation and 30 variables:

"Treatment" "Variety" "Rep" "ARI" "NDVI_1" 
"Heat"       "5"        5     0.8    0.6
"Heat"       "5"        5     -0.3   0.65
"Drought"    "5"        80    -0.7   0.67 
"Drought"     "5"       80   -0.09  0.79
"Control"    "5"        182   -0.09  0.76
"Control"    "5"        182   0.04  0.97
"Heat"       "7"         7     0.8    0.6
"Heat"       "7"         7    -0.3   0.65
"Drought"    "7"        85   -0.7   0.67 
"Drought"     "7"       85   -0.09  0.79
"Control"    "7"       186  -0.09  0.76
"Control"    "7"       186   0.04  0.97

Looking at previous answers on internet, I tried to proceed with this code to differentiate the treatment, however, I did not get any results.

In addition, I do not have any idea on how to group by variety to get a different symbol for every variety.

all.data_1<-all.data[, -c(1)]# to delete column `Treatment` that is character

res.pca <- prcomp(all.data_1,  scale = TRUE)
fviz_pca_biplot(res.pca, label = "var", habillage=all.data$Treatment,
                                  addEllipses=TRUE, ellipse.level=0.95,
                                  ggtheme = theme_minimal())
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Aria P.
  • 11
  • 2
  • As far as I understand, neither variety nor replicate are random samples of a predictor variable. That would leave ARI and NDVI to extract principle components from - but what's the gain of throwing a prcomp at an already two-dimensional predictor set (instead of plotting your observations right there on the ARI x NDVI plane, preferably facetted by treatment)? Sorry if I understood your question wrong. – I_O Jul 08 '23 at 15:56
  • Thanks for answering, I have 153 observation and 30 variables. This was only only a glimpse of my data set :) – Aria P. Jul 08 '23 at 16:19
  • From the documentation, you could set colour and fill of the individual observations via `col.ind` and `fill.ind` (e. g. `fviz_pca_biplot(..., col.ind = as.factor(all.data$Variety), habillage = 'none', ...`) but the docs don't list an option to set shape. – I_O Jul 08 '23 at 16:36
  • see here for alternatives to `fviz_pca_biplot`: https://stackoverflow.com/questions/6578355/plotting-pca-biplot-with-ggplot2 – I_O Jul 08 '23 at 16:41

0 Answers0