Repository navigation
Expand file tree
/
Copy pathmake_pathways_plot_HTAN.R
More file actions
executable file
·110 lines (103 loc) · 5.42 KB
/
Copy pathmake_pathways_plot_HTAN.R
File metadata and controls
executable file
·110 lines (103 loc) · 5.42 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
setwd("/home/ubuntu/netZooR/")
roxygen2::roxygenize()
#library("biomaRt")
library("fgsea")
# Read pathways.
pathways = fgsea::gmtPathways("/home/ubuntu/pathways.gmt")
# Initialize directories for each method.
#pathway_dir <- "/home/ubuntu/SCORPION_pathways"
pathway_dir <- "/home/ubuntu/SCENIC_pathways"
if(!file.exists(pathway_dir)){
dir.create(pathway_dir)
}
# Load data.
#networks <- LoadResults(resultDirectory = "/home/ubuntu/HTAN_SCORPION/",
# interpretationOfNegative = "poor")
networks <- LoadResults(resultDirectory = "/home/ubuntu/HTAN_SCENIC_processed/",
interpretationOfNegative = "inhibitory", firstColumnIsRowname = FALSE, isTabDelimited = TRUE)
# Helper function to build comparison objects.
foldCount <- 5
getFileNames <- function(rootName, foldCount, ending){
comparisonList <- unlist(lapply(1:foldCount, function(j){
retVal <- paste0(paste(rootName, 20, j, sep = "_"), ending)
print(paste0(networks@directory, "/", retVal))
if(!file.exists(paste0(networks@directory, "/", retVal))){
retVal <- NULL
}
return(retVal)
}))
return(comparisonList)
}
# Run all comparisons.
sourceFileList <- c(rep("1188_Ru1170gFreeze-sort_IGO_10034_8_dense.csv", 2),
rep("1189_Ru1170gsort-freeze_IGO_10034_10_dense.csv", 6),
rep("1202_Ru1134_Freeze_thaw_IGO_10034_12_dense.csv", 12),
rep("RU661_TUMOR_dense.csv", 2),
rep("RU682_NORMAL_dense.csv", 6),
rep("RU682_TUMOR_dense.csv", 12),
rep("RU684_NORMAL_dense.csv", 2),
rep("Ru1135_dense.csv", 2),
rep("Ru1137_dense.csv", 2))
ingroupName <- c("Endothelial_cells", "Macrophages",
rep("Endothelial_cells", 2),
rep("Macrophages", 2),
rep("NK_cells", 2),
rep("B_cells", 3),
rep("Fibroblasts", 3),
rep("Macrophages", 3),
rep("T_cells", 3),
"Macrophages", "T_cells",
rep("Macrophages", 2),
rep("NK_cells", 2),
rep("T_cells", 2),
rep("Endothelial_cells", 3),
rep("Fibroblasts", 3),
rep("Macrophages", 3),
rep("T_cells", 3),
"Macrophages", "T_cells",
"Fibroblasts", "Macrophages",
"Endothelial_cells", "Macrophages")
outgroupName <- c("Macrophages", "Endothelial_cells",
"Macrophages", "NK_cells",
"Endothelial_cells", "NK_cells",
"Endothelial_cells", "Macrophages",
"Fibroblasts", "Macrophages", "T_cells",
"B_cells", "Macrophages", "T_cells",
"B_cells", "Fibroblasts", "T_cells",
"B_cells", "Fibroblasts", "Macrophages",
"T_cells", "Macrophages",
"NK_cells", "T_cells",
"Macrophages", "T_cells",
"Macrophages", "NK_cells",
"Fibroblasts", "Macrophages", "T_cells",
"Endothelial_cells", "Macrophages", "T_cells",
"Endothelial_cells", "Fibroblasts", "T_cells",
"Endothelial_cells", "Fibroblasts", "Macrophages",
"T_cells", "Macrophages",
"Macrophages", "Fibroblasts",
"Macrophages", "Endothelial_cells")
uniqueSamples <- unique(sourceFileList)
for(i in 1:length(sourceFileList)){
#for(i in 1:2){
# Compute the AUC and plot the curve.
#comparisons <- BuildComparisonObject(sourceNetwork = paste(sourceFileList[i], "logcounts.csv", ingroupName[i], "original.tsv.csv", sep = "_"),
# ingroupToCompare = getFileNames(paste(sourceFileList[i], ingroupName[i], "logcounts.csv", sep = "_"), 5, ".tsv.csv"),
# outgroupToCompare = getFileNames(paste(sourceFileList[i], outgroupName[i], "logcounts.csv", sep = "_"), 5, ".tsv.csv"),
# results = networks)
comparisons <- BuildComparisonObject(sourceNetwork = paste(sourceFileList[i], "logcounts.csv", ingroupName[i], "original.tsv", sep = "_"),
ingroupToCompare = getFileNames(paste(sourceFileList[i], ingroupName[i], "logcounts.csv", sep = "_"), 5, ".tsv"),
outgroupToCompare = getFileNames(paste(sourceFileList[i], outgroupName[i], "logcounts.csv", sep = "_"), 5, ".tsv"),
results = networks)
# Obtain the ingroup and outgroup only and run pathway analysis.
differentialNetwork <- netZooR::GetDifferentialNetworks(results = networks, comparisons = comparisons)
colnames(differentialNetwork)[3] <- "Weight"
str(differentialNetwork)
differentialNetworkMat <- as.matrix(igraph::get.adjacency(igraph::graph.data.frame(differentialNetwork), attr = "Weight"))
str(differentialNetworkMat)
differentialPathways <- netZooR::RunPathwayAnalysis(network = differentialNetworkMat,
pathways = pathways,
geneSymbols = colnames(differentialNetworkMat))
str(differentialPathways)
write.csv(differentialPathways, paste0(pathway_dir, "/", paste(sourceFileList[i],
ingroupName[i], outgroupName[i], sep = "_"), "_pathways.csv"))
}