# Data downloaded from https://archive.ics.uci.edu/dataset/401/gene+expression+cancer+rna+seq
# This chunk takes some time to run, so evaluated off-line
if (!file.exists(here("data", "TCGA-PANCAN-HiSeq-801x20531", "data.csv"))) {
download.file(url = "https://archive.ics.uci.edu/static/public/401/gene+expression+cancer+rna+seq.zip",
destfile = here::here("data", "TCGA-PANCAN-HiSeq-801x20531.zip"), mode = "wb")
unzip(here::here("data", "TCGA-PANCAN-HiSeq-801x20531.zip"),
exdir = here::here("data/TCGA-PANCAN-HiSeq-801x20531/"))
# Untar into folder
untar(here::here("data/TCGA-PANCAN-HiSeq-801x20531/TCGA-PANCAN-HiSeq-801x20531.tar.gz"),
exdir = here("data"))
}
tcga <- tibble(read.csv(here("data", "TCGA-PANCAN-HiSeq-801x20531", "data.csv")))
tcga_t <- t(as.matrix(tcga[,2:20532]))
colnames(tcga_t) <- tcga$X
tcga_t_pc <- prcomp(tcga_t, scale = FALSE)$x
ggally_hexbin <- function (data, mapping, ...) {
p <- ggplot(data = data, mapping = mapping) + geom_hex(binwidth=20, ...)
p
}
ggpairs(tcga_t_pc, columns=c(1:4),
lower = list(continuous = "hexbin")) +
scale_fill_gradient(trans="log",
low="#E24C80", high="#FDF6B5")