Hello folks,
I am very new to mixOmics but found it very useful to run PLSDA. I have run the code for my data and try to customize the plot using ggplot, however, I found it difficult to customize the plotIndiv() and plotVar() . Here is my code and data. The data were grouped into two subgroups, cluster1, and cluster2. The variables are the elements. The dataset was uploaded in the google drive, here is the link for the data:
data used for plsda
My goal is to generate figures like these plots in the literature, does anyone can help me modify my code to have something like this? Thank you.
The red labels in the plot are the labeled groups, how can I add my clusters into my variable plot?
Simon
library(mixOmics)
library(ggplot2)
library(ggrepel)
plsda_data<-read.csv("plsda_data.csv",header = TRUE, sep = ",", stringsAsFactors = FALSE)
#set up the data as X expression matrix and Y as factor
X<-plsda_data[1:252, 2:26]
Y<-plsda_data$Cluster
summary(Y)
dim(X)
#PLSDA analysis
data.plsda <- plsda(X, Y, ncomp = 25)
plotIndiv(data.plsda ,
comp = c(1,2),
group = plsda_data$Cluster,
ind.names = FALSE,
ellipse = FALSE,
legend = TRUE,
title = 'PLSDA results',
X.label = 'PLS-DA 1',
Y.label = 'PLS-DA 2')
#output the variables
plotVar(data.plsda,
comp=c(1,2),
var.names =TRUE,
legend = FALSE,
plot=TRUE,
overlap = TRUE,
style='ggplot2',
rad.in = 0,
cutoff = 0,
cex = 8,
font = 2,
col = 4,
pch = 21,
title = "PLS-DA results for variable correlations")