-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analysis-POG.R
75 lines (54 loc) · 1.86 KB
/
Analysis-POG.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
rm(list=ls())
library(ggplot2)
library(heatmaply)
library(corrplot)
library(reshape2)
library(GSVA)
library(GSEABase)
library(msigdbr)
library(data.table)
library(Rtsne)
library(sva)
library(preprocessCore)
library(factoextra)
library(MCPcounter)
library(dplyr)
library(tidyverse)
library(drake)
setwd("C:/Users/aflorescu/Molecular Partners AG/DEV_TP_ExVivo - Ana/Rscripts/Rprojects/Analysis-bulk-cohorts")
#====================================
#Functions to transpose count matrix and join to annotation
transpose.TPM <- function(df.TPM){
rownames(df.TPM) <- df.TPM$Gene
df.TPM <- df.TPM[,-1]
df.t <- data.frame(SAMPLE_ID=colnames(df.TPM),t(df.TPM))
#df.merged<- merge(df.annotation, df.t, by="SAMPLE_ID")
return(df.t)
}
merge.file.annotation <- function(df.t,df.annotation){
#rownames(df.TPM) <- df.TPM$Gene
#df.TPM <- df.TPM[,-1]
#df.t <- data.frame(SAMPLE_ID=colnames(df.TPM),t(df.TPM))
df.merged<- merge(df.annotation, df.t, by="SAMPLE_ID")
return(df.merged)
}
#============================================================================================================
#main workflow
plan <- drake_plan(
df.TPM = fread("C:/data/POG/POG570_TPM_expression_log2-add-1-combat-by-protocol-qnorm.txt", header=TRUE, sep="\t", data.table = FALSE),
df.annotation=read.table("C:/data/JoinedFiles/TCGA-POG-MCP-GSVA-11.11.2020.txt", header = TRUE, sep = "\t"),
df.t =transpose.TPM(df.TPM),
df.joined = merge.file.annotation(df.t, df.annotation),
pca.results = prcomp(df.t[,-1]),
plot1 =fviz_eig(pca.results),
coords.pca = data.frame(SAMPLE_ID=rownames(pca.results$x),pca.results$x[,1:10]),
annotation.pca = merge(df.annotation, coords.pca, by="SAMPLE_ID"),
report = target(
command = {
rmarkdown::render(knitr_in("analysis-report.Rmd"))
file_out("analysis-report.html")
}
)
)
vis_drake_graph(plan)
make(plan)