microbiota.abundance
)# Charger les library
library(FactoMineR)
library(factoextra)
# Charger les jeux de données
abonDF = readRDS(file = "../seance_2/data/microbiota.abundance.log.RDS")
metadata = readRDS(file = "../seance_2/data/metadata.RDS")
Réaliser une ACP centrée réduite sur ce jeu de données.
res.pca = PCA(abonDF, graph = FALSE)
fviz_eig(res.pca, addlabels = TRUE, ylim = c(0, 50))
8% de la variance est expliquée dans le premier plan factoriel
fviz_pca_ind(res.pca,
geom.ind = "point",
habillage = metadata$status,
addEllipses = TRUE)
fviz_pca_ind(res.pca,
geom.ind = "point",
habillage = metadata$Enterotype,
addEllipses = TRUE)
# --> Message d'erreur: Error in `[.data.frame`(X$call$X, rownames(ind), grp, drop = FALSE) : undefined columns selected
metadata$Enterotype
## [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1
## [24] 1 1 1 2 1 1 1 1 1 2 2 1 2 2 1 1 1 1 2 1 1 1 1
## [47] 1 1 2 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 1 2 1
## [70] 3 1 1 1 1 1 1 3 1 1 1 2 1 2 3 1 1 3 1 1 1 1 2
## [93] 1 3 1 3 3 1 1 2 1 1 1 2 3 1 1 2 1 1 3 1 1 2 1
## [116] 2 3 1 2 3 2 1 2 1 1 3 3 1 3 1 2 1 3 1 3 1 2 3
## [139] 3 2 1 1 2 1 3 3 1 3 1 2 3 3 3 2 1 2 2 1 3 1 1
## [162] 3 3 1 1 3 2 2 2 1 1 1 1 3 3 1 2 1 1 3 1 NA NA NA
## [185] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [208] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [231] NA NA NA NA NA NA NA
all.equal(rownames(abonDF), rownames(metadata))
## [1] TRUE
na.enterotypes = which(is.na(metadata$Enterotype))
res.pca2 = PCA(abonDF[-na.enterotypes, ], graph = FALSE)
fviz_pca_ind(res.pca2,
geom.ind = "point",
habillage = as.factor(metadata$Enterotype[-na.enterotypes]),
addEllipses = TRUE,
ellipse.level = 0.5,
axes = c(1,2))
# Contribution des variables aux axes
fviz_contrib(res.pca, choice = "var", axes = 1, top = 10)
fviz_contrib(res.pca, choice = "var", axes = 3, top = 10)