I am facing the same issue. I'm not confortable with the OPLS-DA modelisation but here is the solution I found, I hope it can help. It is based on the S-plot description made by Wiklund et al. (2008) (doi:10.1021/ac0713510) and a script found here.
This function return a dataframe of the covariance (Cov) and correlation (Corr) loading profiles from the predictive component of an OPLS-DA model. The arguments datamatrix is the matrix used to perform the OPLS-DA and opls is the S4 object resulting of the ropls::opls() function. Up to you to create and customize the S-plot as you wich.
DataSplot <- function(datamatrix, opls) {
s <- datamatrix
T <- as.matrix(opls@scoreMN)
p1 <- c()
for (i in 1:ncol(s)) {
scov <- cov(s[,i], T)
p1 <- matrix(c(p1, scov), ncol=1)
}
pcorr1 <- c()
for (i in 1:nrow(p1)) {
den <- apply(T, 2, sd)*sd(s[,i])
corr1 <- p1[i,]/den
pcorr1 <- matrix(c(pcorr1, corr1), ncol=1)
}
datasplot <- data.frame(Cov = p1, Corr = pcorr1)
rownames(datasplot) <- colnames(datamatrix)
return(datasplot)
}
df <- DataSplot(t(assay(vsd3)), oplsda)
plot(df$Cov, df$Corr)