Created
May 20, 2015 11:05
-
-
Save vadimnazarov/73060555c157ecdae9fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pcaGenes <- function(.data, .cast.freq.seg = T, ..., ..do.plot = T){ | |
if (.cast.freq.seg) { .data <- freq.segments(.data)[,-1] } | |
pca.res <- prcomp(t(as.matrix(.data)), ...) | |
if (.do.plot) { | |
pca.res <- data.frame(PC1 = pca.res$x[,1], PC2 = pca.res$x[,2], Subject = names(.data)) | |
ggplot() + geom_point(aes(x = PC1, y = PC2, colour = Subject), size = 3, data = pca.res) + | |
theme_linedraw() + guides(size=F) + ggtitle("VJ-usage: Principal Components Analysis") | |
} else { | |
pca.res | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment