create S-plots with ropls package
1
0
Entering edit mode
andreia ▴ 10
@andreia-23745
Last seen 2.6 years ago
Portugal

Hi there,

I am stuck here creating S-plots after generating a OPLS-DA plot.

I apply this code:

library(ropls)
oplsda <- opls(t(assay(vsd3)), as.factor(data$group), predI = 1, orthoI = NA)
png("figure4-OPLS-da.png", width = 500, height = 500, res = 72)
plot(oplsda, typeVc = "x-score", parPaletteVc = c("#57b993", "#c94a3d"))
dev.off()

I dont know how can generate S-plots from here, can you help me with that?

Thanks in advance.

s-plot ropls opls-da rna-seq • 3.2k views
ADD COMMENT
1
Entering edit mode
Nathalie ▴ 10
@c527f698
Last seen 3.2 years ago

Hello,

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)
ADD COMMENT

Login before adding your answer.

Traffic: 583 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6