This is a test version of Biostars. For the public version, visit https://www.biostars.org.
PCA plot after batch normalization

I have two microarray datasets with same platform. I performed batch normalization using:

norm1=removeBatchEffect(norm, batch=NULL, batch2=NULL, covariates=NULL, design=matrix(1,ncol(norm),1))

and now I want a PCA plot of test and control samples. I tried using the following codes:

 #pca plot
library(ggfortify)
control<- norm1[,c(1:19,35:63)]
test<-norm1[,c(20:34,64:93)]
autoplot(prcomp(control,test))

# OR
library(ggplot)
df<- data.frame(control=norm1[,c(1:19,35:63)], test=norm1[,c(20:34,64:93)])
ggplot(df, aes(control,test)) + geom_point(aes(shape=control,colour= test))

but the plot is not showing groups of test and control. instead, it plots the genes present in samples.

can anyone point out what's wrong here and suggest any other function in limma or affy?

r

1 answer

If the PCA bi-plot is showing genes, then simply transpose your input data [to prcomp] via the t() function.

I have a dedicated package for PCA on Bioconductor, by the way: PCAtools

Kevin

Thank you for help. Can you suggest how to add colour to PCA plot? I tried the following:

 autoplot(prcomp(t(norm1),scale. = TRUE, colour="control"))

and other one:

autoplot(prcomp(t(norm1),scale. = TRUE, colby="control"))

but it is giving error: Warning message: In prcomp.default(t(norm1), colour = "control") : extra argument ‘colour’ will be disregarded

  • what does this mean? how to correct it?

In both examples of code, you are attempting to pass arguments, colour and colby, to prcomp. prcomp does not accept any arguments by these names

Log in to answer this question.