-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwTO_complete.R
93 lines (52 loc) · 1.98 KB
/
wTO_complete.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env Rscript
# wTO_complete.R
rm(list = ls())
args = commandArgs(trailingOnly=TRUE)
options(stringsAsFactors = FALSE)
# paralellize
require(parallel)
require(doParallel)
cores <- makeCluster(detectCores()-2, type='PSOCK')
print(cores)
registerDoParallel(cores)
Sys.setenv("MC_CORES" = length(cores))
options("mc.cores"=length(cores))
stopCluster(cores)
# ==============
## Checking and Load packages ----
# ==============
.cran_packages <- c("wTO", "CoDiNA") # "tidyverse"
.inst <- .cran_packages %in% installed.packages()
if(any(!.inst)) {
install.packages(.cran_packages[!.inst], dep=TRUE, repos='http://cran.us.r-project.org')
}
# Load packages into session, and print package version
sapply(c(.cran_packages), require, character.only = TRUE)
degsf <- args[1]
cuttof <- 0.05 # args[2]
fileOut <- basename(degsf)
fileOut <- sapply(strsplit(fileOut, "[.]"), `[`, 1)
# load count data ----
path <- getwd()
pattern <- "counts_table_length_ajus_gen_level-aproach2-filtered.txt"
countf <- list.files(path = path, pattern = pattern, full.names = T)
dim(count <- read.delim(countf, sep = "\t"))
# load overlaps ----
peptideGenes <- readLines(paste0(path, "/peptideGenes.list"))
# load up/down regulated overlaps (lists) ----
readGenes <- function(file) {
df <- read.delim(file, sep = "\t")
return(df)
}
df <- readGenes(degsf)
df <- subset(df, FDR < cuttof)
degs <- unique(df$ID)
cat("\nnumber of overlaps in the data: ", sum(degs %in% peptideGenes))
Overlap <- degs[degs %in% peptideGenes]
cat("\nNumber of genes to input into the network: ", sum(rownames(count) %in% degs))
# subset count-matrix based on significance and prevalence
dim(Data <- count[rownames(count) %in% degs,])
Data <- log2(Data+1)
network <- wTO::wTO.Complete(n = 100, k = 24, Data = Data, method_resampling = 'Bootstrap', Overlap = Overlap, method = 's', pvalmethod = "bonferroni", plot = F, savecor = T)
saveRDS(network, file = paste0(path, "/", fileOut, "_network.rds"))
quit(save = "no")