-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_2_poe_haps_rep.sh
136 lines (85 loc) · 2.57 KB
/
3_2_poe_haps_rep.sh
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
#$ -cwd -V
#$ -j y
#$ -P drong.prjc -q short.qc
#$ -t 454
#$ -N HM_POE
echo "************************************************************"
echo "SGE job ID: "$JOB_ID
echo "SGE task ID: "$SGE_TASK_ID
echo "Run on host: "`hostname`
echo "Operating system: "`uname -s`
echo "Username: "`whoami`
echo "Started at: "`date`
echo "************************************************************"
## for running the script on a head node, provide index as first argument
if [ -z "$SGE_TASK_ID" ]; then SGE_TASK_ID=$1; fi
module load R
source 0_config.sh
R --vanilla <<EOF
require(foreach)
i=$SGE_TASK_ID
require(data.table)
haps <- fread("${INPUT}.haps",data.table=F)
load("$EXP")
expression <- mirna
sample <- fread("${INPUT}.sample", data.table=F)
sample <- sample[-1,]
colnames(haps) <- sample[,2]
rownames(sample) <- sample[,2]
colnames(haps)[6:ncol(haps)] <- paste(rep(sample[,2],each=2),c("MT","FT"),sep="_")
children <- sample[sample[,4]!=0,2]
colnames(expression)
children
sample[children,4]
sum(children%in% colnames(expression))
sum(sample[children,4]%in% colnames(expression))
sum(sample[children,5]%in% colnames(expression))
#children <- children[sample[children,4]%in% colnames(expression) & sample[children,5]%in% colnames(expression)]
children
colnames(haps)
children
sample
head(rownames(haps))
colnames(expression)
chd.exp <- expression[,children]
colnames(haps)
pat <- haps[,paste(children,"_FT",sep="")]
mat <- haps[,paste(children,"_MT",sep="")]
require(foreach)
probes <- rownames(chd.exp)
snps<- rownames(mat)
dim(chd.exp)
dim(mat)
summary(lm(unlist(chd.exp[1,]) ~ unlist(mat[1,])))
mat.lm <- foreach(j=1:nrow(mat),.combine=rbind) %do% {
if(j%%1000==0) {print(j)}
out <- try(coefficients(summary(lm(unlist(chd.exp[i,]) ~ unlist(mat[j,]))))[2,])
if(!inherits(out,"try-error")){
out
} else {
rep(NA,4)
}
}
save(mat.lm,snps,probes,file=paste("${OUTPUT}/mat_",i,".R.RData",sep=""))
pat.lm <- foreach(j=1:nrow(pat),.combine=rbind) %do% {
if(j%%100==0) {print(j)}
out <-try(coefficients(summary(lm(unlist(chd.exp[i,]) ~ unlist(pat[j,]))))[2,])
if(!inherits(out,"try-error")){
out
} else {
rep(NA,4)
}
}
save(pat.lm,snps,probes,file=paste("${OUTPUT}/pat_",i,".R.RData",sep=""))
add.lm <- foreach(j=1:nrow(pat),.combine=rbind) %do% {
if(j%%100==0) {print(j)}
out<-try(coefficients(summary(lm(unlist(chd.exp[i,]) ~ (unlist(pat[j,]) + unlist(mat[j,])))))[2,])
if(!inherits(out,"try-error")){
out
} else {
rep(NA,4)
}
}
save(add.lm,snps,probes,file=paste("${OUTPUT}/add_",i,".R.RData",sep=""))
EOF