This file contains hidden or 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
set.seed(100) | |
d = data.frame(matrix(runif(150), nrow=30, ncol=5)) # 30 x 5 data from uniform distribution | |
colnames(d) = c("co1", "co2", "ca1", "ca2", "ca3") # 2 Controls / 3 Cancers | |
rownames(d) = paste0("g", 1:30) # gene names | |
## Case1: Principal componenets assuming samples (ca / co) as variables; The genes will get plotted on the PC-axes | |
## I've removed the loading levels for a clear picture. | |
head(d) | |
autoplot(prcomp(d), |
This file contains hidden or 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
set.seed(100) | |
d = data.frame(matrix(runif(150), nrow=30, ncol=5)) # 30 x 5 data from uniform distribution | |
colnames(d) = c("co1", "co2", "ca1", "ca2", "ca3") # 2 Controls / 3 Cancers | |
rownames(d) = paste0("g", 1:30) # gene names | |
## Case1: Principal componenets assuming samples (ca / co) as variables; The genes will get plotted on the PC-axes | |
## I've removed the loading levels for a clear picture. | |
head(d) | |
autoplot(prcomp(d), |
This file contains hidden or 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
set.seed(100) | |
d = data.frame(matrix(runif(150), nrow=30, ncol=5)) # 30 x 5 data from uniform distribution | |
colnames(d) = c("co1", "co2", "ca1", "ca2", "ca3") # 2 Controls / 3 Cancers | |
rownames(d) = paste0("g", 1:30) # gene names | |
## Case1: Principal componenets assuming samples (ca / co) as variables; The genes will get plotted on the PC-axes | |
## I've removed the loading levels for a clear picture. | |
head(d) | |
autoplot(prcomp(d), |
This file contains hidden or 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
set.seed(100) | |
d = data.frame(matrix(runif(150), nrow=30, ncol=5)) # 30 x 5 data from uniform distribution | |
colnames(d) = c("co1", "co2", "ca1", "ca2", "ca3") # 2 Controls / 3 Cancers | |
rownames(d) = paste0("g", 1:30) # gene names | |
## Case1: Principal componenets assuming samples (ca / co) as variables; The genes will get plotted on the PC-axes | |
## I've removed the loading levels for a clear picture. | |
head(d) | |
autoplot(prcomp(d), |
This file contains hidden or 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
set.seed(100) | |
d = data.frame(matrix(runif(150), nrow=30, ncol=5)) # 30 x 5 data from uniform distribution | |
colnames(d) = c("co1", "co2", "ca1", "ca2", "ca3") # 2 Controls / 3 Cancers | |
rownames(d) = paste0("g", 1:30) # gene names | |
## Case1: Principal componenets assuming samples (ca / co) as variables; The genes will get plotted on the PC-axes | |
## I've removed the loading levels for a clear picture. | |
head(d) | |
autoplot(prcomp(d), |
This file contains hidden or 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
## Modified plotPCA from DESeq2 package. Shows the Names of the Samples (the first col of SampleTable), and uses ggrepel pkg to plot them conveniently. | |
# @SA 10.02.2017 | |
library(genefilter) | |
library(ggplot2) | |
library(ggrepel) | |
plotPCA.san <- function (object, intgroup = "condition", ntop = 500, returnData = FALSE) | |
{ | |
rv <- rowVars(assay(object)) | |
select <- order(rv, decreasing = TRUE)[seq_len(min(ntop, |