forked from chenxofhit/Loc-PCA-CMI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloc-PCA-CMI_pc_cluster.R
59 lines (44 loc) · 1.7 KB
/
loc-PCA-CMI_pc_cluster.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
library(readr)
library(R.matlab)
library(Matrix)
library(RLowPC)
#options(error=traceback)
#set working direcotory based on your workspace
setwd("/home/cb213/chenx/Loc-PCA-CMI")
args <- commandArgs(trailingOnly = TRUE)
hybrid<-length(args) # switch variable for debug in Rstudio or integrate running in bash
if(!hybrid){
datafile <- "./db/Dream100/Dream100_Yeast.csv" #10,10,100, modify here
goldenfile <- "./db/Dream100/Dream100_Yeast_golden.txt"
clusterfile<- paste(getwd(),"/result_loc_pcacmi/Dream100_Yeast_cluster.mat",sep = "")
}else{
datafile <- args[1]
goldenfile <- args[2]
clusterfile <- args[3]
}
cat("parameters:\n")
cat("datafile: ",datafile," \n")
cat("goldenfile: ",goldenfile," \n")
cat("clusterfile: ",clusterfile," \n")
cat("-----------\n")
dream3 <- read_csv(datafile, col_names = FALSE)
dream3_golden <- read_delim(goldenfile,"\t", escape_double = FALSE, col_names = FALSE,
trim_ws = TRUE)
data.exp <- dream3
genes <- colnames(data.exp)
inf.zeroPC <- zeroPC(data.exp = data.exp, method = "pearson")
# cutoff <- 0.1
# cutat='pval'
# inf.edge <- inf.zeroPC[inf.zeroPC[, cutat] < cutoff, ]
#rownames(inf.edge) <- NULL
topN <- ceiling(0.2*(length(genes)*(length(genes)-1)/2))
#topn.edges<-na.omit(adjmatrix2edgelist(adjmatrix = inf.pcor,directed = F,order = T)[1:topN,])
inf.edge <- inf.zeroPC[1:topN, 1:3]
inf.zeropc.adj<-edgelist2adjmatrix(inf.edge,genes = genes,directed = F)
for( i in 1:dim(inf.zeropc.adj)[1]){
idx <- which(inf.zeropc.adj[i,] > 0)
library(gtools)
mixOrderCluster <- mixedsort(colnames(inf.zeropc.adj)[c(i,idx)])
cat(paste(i,"th/#",length(mixOrderCluster),sep = ""),":[",mixOrderCluster,"]\n")
}
writeMat(clusterfile, adj=inf.zeropc.adj)