Hi everyone,
I have a couple of questions concerning the plotPCA function in the DESeq package. I'm relatively new to R, so maybe they are relatively easy to answer.
1. Is it possible to extract the calculated coordinates from the PCA? I'm talking about the x-axis and y-axis values for the different samples.
2. How can I change the colors in the PCA? I can see from the function code
that it uses the "Paired" color palette from the RColorBrewer package. When I try to replicate the function with a different palette, I get an error that it can't find the "rowVars" function. I cannot find this function in R or in the DESeq manual. The default plotPCA is working fine though. I tried attaching my new function to DESeq namespace but I couldn't. I attached it to the package environment but it still didn't work. It seems to me that my problem is a fairly stupid one but even with the excellent manual and some intensive internet recherches I can't figure it out.
3. Is it possible to change the default colored circles to different shapes for different groups?
Thanks in advance for any help you can offer.
Kind Regards
Benedikt
I have a couple of questions concerning the plotPCA function in the DESeq package. I'm relatively new to R, so maybe they are relatively easy to answer.
1. Is it possible to extract the calculated coordinates from the PCA? I'm talking about the x-axis and y-axis values for the different samples.
2. How can I change the colors in the PCA? I can see from the function code
Code:
function (x, intgroup = "condition", ntop = 500) { rv = rowVars(exprs(x)) select = order(rv, decreasing = TRUE)[seq_len(ntop)] pca = prcomp(t(exprs(x)[select, ])) fac = factor(apply(pData(x)[, intgroup, drop = FALSE], 1, paste, collapse = " : ")) if (length(fac) >= 3) colours = brewer.pal(nlevels(fac), "Paired") else colours = c("green", "blue") xyplot(PC2 ~ PC1, groups = fac, data = as.data.frame(pca$x), pch = 16, cex = 2, aspect = "iso", col = colours, main = draw.key(key = list(rect = list(col = colours), text = list(levels(fac)), rep = FALSE))) } <environment: namespace:DESeq>
3. Is it possible to change the default colored circles to different shapes for different groups?
Thanks in advance for any help you can offer.
Kind Regards
Benedikt
Comment