-
Notifications
You must be signed in to change notification settings - Fork 1
/
todoMISOStepFourRemapToIsoformNames.sh.bak
executable file
·208 lines (147 loc) · 6.54 KB
/
todoMISOStepFourRemapToIsoformNames.sh.bak
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
:<<'COMMENT'
/lab/solexa_jaenisch4/Albert/mRNASeqLibs/ESC_EpiSC/miso-scripts$ colStat.py -r1,2 ../MISOOnPE_splidarEvents/MISOSummary/Alb_mEpiSCLib2/summary/Alb_mEpiSCLib2.miso_summary
[::::: R 1 :::::]
Index Excel Field
----- ----- -----
1 A event_name
2 B miso_posterior_mean
3 C ci_low
4 D ci_high
5 E isoforms x
6 F counts x
7 G assigned_counts x
[::::: R 2 :::::]
Index Excel Field
----- ----- -----
1 A A5SS
2 B 0.28
3 C 0.08
4 D 0.46
5 E 'A5SS.Jak3andInsl3.10101@EXON1_A5SS.Jak3andInsl3.10101@EXON2','A5SS.Jak3andInsl3.10101@EXON3_A5SS.Jak3andInsl3.10101@EXON4'
6 F (1,1):28
7 G 0:0,1:28
/lab/solexa_jaenisch4/Albert/mRNASeqLibs/ESC_EpiSC/miso-scripts$ colStat.py -r1,2 ../MISOOnPE_splidarEvents/MISOComparisons/Alb_mEpiSCLib2-Alb_mESCLib2/Alb_mEpiSCLib2_vs_Alb_mESCLib2/bayes-factors/Alb_mEpiSCLib2_vs_Alb_mESCLib2.miso_bf
[::::: R 1 :::::]
Index Excel Field
----- ----- -----
1 A event_name
2 B sample1_posterior_mean
3 C sample1_ci_low
4 D sample1_ci_high
5 E sample2_posterior_mean
6 F sample2_ci_low
7 G sample2_ci_high
8 H diff
9 I bayes_factor
10 J isoforms
11 K sample1_counts
12 L sample1_assigned_counts
13 M sample2_counts
14 N sample2_assigned_counts
[::::: R 2 :::::]
Index Excel Field
----- ----- -----
1 A A5SS.Jak3andInsl3.10101
2 B 0.28
3 C 0.08
4 D 0.46
5 E 0.29
6 F 0.10
7 G 0.47
8 H -0.01
9 I 0.50
10 J 'A5SS.Jak3andInsl3.10101@EXON1_A5SS.Jak3andInsl3.10101@EXON2','A5SS.Jak3andInsl3.10101@EXON3_A5SS.Jak3andInsl3.10101@EXON4'
11 K (1,1):28
12 L 0:0,1:28
13 M (1,1):21
14 N 0:0,1:21
COMMENT
if [ $# -ne 2 ]; then
echo $0 MISOSettingFile "mode[normal|reduced]"
exit
fi
MISOSettingFile=$1
mode=$2
source ${MISOSettingFile}
if [[ $splidarInfoFile == "" ]]; then
echo splidarInfoFile not set. Abort
exit 1
fi
thisScriptDir=`pwd`
cd ..
rootDir=`pwd`
tophatOutputDir=$rootDir/$bamFileSubRoot
if [[ $mode == "normal" ]]; then
echo remapToIsoformNames in the normal MISO mode
MISOOutputDir=$rootDir/${MISOOutSubRoot}/MISOOutput
MISOSummaryDir=$rootDir/${MISOOutSubRoot}/MISOSummary
MISOComparisonsDir=$rootDir/${MISOOutSubRoot}/MISOComparisons
elif [[ $mode == "reduced" ]]; then
echo summarizing the MISO full-transcript reduced to Splidar mode
MISOOutputDir=$rootDir/${MISOOutSubRoot}/MISOOutput.reduced
MISOSummaryDir=$rootDir/${MISOOutSubRoot}/MISOSummary.reduced
MISOComparisonsDir=$rootDir/${MISOOutSubRoot}/MISOComparisons.reduced
else
echo unknown summary mode $mode
bash $0
exit
fi
for sampleDir in $tophatOutputDir/*; do
sampleName=`basename $sampleDir`
if [ ! -e $sampleDir/${targetBamFileBaseName} ]; then
continue
fi
cd $MISOSummaryDir/$sampleName/summary
echo working on summary for sample $sampleName
#first remove all the quote marks
dequote.sh ${sampleName}.miso_summary > ${sampleName}.miso_summary.dq
#now extract the isform column
cuta.py -f.isoforms ${sampleName}.miso_summary.dq | awk -v FS="\t" -v OFS="\t" '{printf("%d\t%s\n",FNR,$0);}' > ${sampleName}.miso_summary.isoforms
#now dissociate
dissociateColValues.py -i, -s2 ${sampleName}.miso_summary.isoforms > ${sampleName}.miso_summary.isoforms.dissociated
rawGffFileNoExt=${rawGffFile/.gff/}
rawGffFileNoExt=${rawGffFileNoExt/.GFF/}
rawGffFileNoExt=${rawGffFileNoExt/.gff3/}
rawGffFileNoExt=${rawGffFileNoExt/.GFF3/}
#now map
joinu.py -1.isoforms -2.isoforms ${sampleName}.miso_summary.isoforms.dissociated $rawGffFileNoExt.exonStringMap > ${sampleName}.miso_summary.isoforms.dissociated.2transcriptName
#now collapse
stickColValues.py --internalfs "," ${sampleName}.miso_summary.isoforms.dissociated.2transcriptName 1 | cut -f2,3 > ${sampleName}.miso_summary.isoforms.2transcriptName
joinu.py -1.isoforms -2.isoforms ${sampleName}.miso_summary.dq ${sampleName}.miso_summary.isoforms.2transcriptName > ${sampleName}.miso_summary.2transcriptName
rmrie.sh ${sampleName}.miso_summary.splidarEvents.00
python $thisScriptDir/correctMISOForSplidarEvents.py ${sampleName}.miso_summary.2transcriptName > ${sampleName}.miso_summary.splidarEvents.00
joinu.py -1 .eventIDString -2 .eventIDString $splidarInfoFile ${sampleName}.miso_summary.splidarEvents.00 > ${sampleName}.miso_summary.splidarEvents.full
echo "Checking reverse join on splidarInfo. Should have no unmatched lines ${sampleName}.miso_summary.splidarEvents.00 against $splidarInfoFile"
joinu.py -w 2 -1 .eventIDString -2 .eventIDString ${sampleName}.miso_summary.splidarEvents.00 $splidarInfoFile > /dev/null #making sure
echo "End of checking"
#now trim the unwnated fields
cuta.py -f.eventIDString,.eventType,.eventID,.locusName,.chr,.strand,.inc/excBound,.UCSCGenomeBrowser,.miso_posterior_mean,.ci_low,.ci_high ${sampleName}.miso_summary.splidarEvents.full > ${sampleName}.miso_summary.splidarEvents.tab
cd $rootDir
done
if [ -e $MISOComparisonsDir ]; then
for i in $MISOComparisonsDir/*/*/bayes-factors/*.miso_bf; do
echo working on comparison file $i
#these are copied from above but modifying ${sampleName}.miso_summary to ${i}
dequote.sh ${i} > ${i}.dq
cuta.py -f.isoforms ${i}.dq | awk -v FS="\t" -v OFS="\t" '{printf("%d\t%s\n",FNR,$0);}' > ${i}.isoforms
#now dissociate
dissociateColValues.py -i, -s2 ${i}.isoforms > ${i}.isoforms.dissociated
rawGffFileNoExt=${rawGffFile/.gff/}
rawGffFileNoExt=${rawGffFileNoExt/.GFF/}
rawGffFileNoExt=${rawGffFileNoExt/.gff3/}
rawGffFileNoExt=${rawGffFileNoExt/.GFF3/}
#now map
joinu.py -1.isoforms -2.isoforms ${i}.isoforms.dissociated $rawGffFileNoExt.exonStringMap > ${i}.isoforms.dissociated.2transcriptName
#now collapse
stickColValues.py --internalfs "," ${i}.isoforms.dissociated.2transcriptName 1 | cut -f2,3 > ${i}.isoforms.2transcriptName
joinu.py -1.isoforms -2.isoforms ${i}.dq ${i}.isoforms.2transcriptName > ${i}.2transcriptName
python $thisScriptDir/correctMISOForSplidarEvents.py ${i}.2transcriptName > ${i}.splidarEvents.00
tpf=`tempfile`
joinu.py -1 .eventIDString -2 .eventIDString $splidarInfoFile ${i}.splidarEvents.00 | splitlines.py - 1 ${i}.splidarEvents.full,$tpf
colBayesFactor=`colSelect.py ${i}.splidarEvents.full .bayes_factor`
sort -k$colBayesFactor,$colBayesFactor -t$'\t' -g -r $tpf >> ${i}.splidarEvents.full
#now trim the unwnated fields
cuta.py -f.eventIDString,.eventType,.eventID,.locusName,.chr,.strand,.inc/excBound,.UCSCGenomeBrowser,.sample1_posterior_mean,.sample1_ci_low,.sample1_ci_high,.sample2_posterior_mean,.sample2_ci_low,.sample2_ci_high,.diff,.bayes_factor ${i}.splidarEvents.full > ${i}.splidarEvents.tab
done
fi