@@ -56,6 +56,7 @@ def main(rep1_ta, rep2_ta, ctl1_ta, ctl2_ta, rep1_xcor, rep2_xcor, rep1_paired_e
56
56
57
57
rep1_ta_file = dxpy .DXFile (rep1_ta )
58
58
rep2_ta_file = dxpy .DXFile (rep2_ta )
59
+ unary_control = ctl1_ta == ctl2_ta
59
60
ctl1_ta_file = dxpy .DXFile (ctl1_ta )
60
61
ctl2_ta_file = dxpy .DXFile (ctl2_ta )
61
62
rep1_xcor_file = dxpy .DXFile (rep1_xcor )
@@ -93,29 +94,39 @@ def main(rep1_ta, rep2_ta, ctl1_ta, ctl2_ta, rep1_xcor, rep2_xcor, rep1_paired_e
93
94
94
95
pool_applet = dxpy .find_one_data_object (
95
96
classname = 'applet' , name = 'pool' , zero_ok = False , more_ok = False , return_handler = True )
96
- pool_controls_subjob = pool_applet .run ({"inputs" : [ctl1_ta , ctl2_ta ]})
97
97
pool_replicates_subjob = pool_applet .run ({"inputs" : [rep1_ta , rep2_ta ]})
98
-
99
- pooled_controls = pool_controls_subjob .get_output_ref ("pooled" )
100
98
pooled_replicates = pool_replicates_subjob .get_output_ref ("pooled" )
101
99
102
- rep1_control = ctl1_ta #default
103
- rep2_control = ctl2_ta #default
104
- ratio_ctl_reads = float (ntags_ctl1 )/ float (ntags_ctl2 )
105
- if ratio_ctl_reads < 1 :
106
- ratio_ctl_reads = 1 / ratio_ctl_reads
107
- ratio_cutoff = 1.2
108
- if ratio_ctl_reads > ratio_cutoff :
109
- print "Number of reads in controls differ by > factor of %f. Using pooled controls." % (ratio_cutoff )
110
- rep1_control = pooled_controls
111
- rep2_control = pooled_controls
100
+ rep1_control = ctl1_ta #default. May be changed later.
101
+ rep2_control = ctl2_ta #default. May be changed later.
102
+
103
+ if unary_control :
104
+ print "Only one control supplied. Using it for both replicate 1 and 2 and for the pool."
105
+ control_for_pool = rep1_control
112
106
else :
113
- if ntags_ctl1 < ntags_rep1 :
114
- print "Fewer reads in control replicate 1 than experiment replicate 1. Using pooled controls for replicate 1."
115
- rep1_control = pooled_controls
116
- if ntags_ctl2 < ntags_rep2 :
117
- print "Fewer reads in control replicate 2 than experiment replicate 2. Using pooled controls for replicate 2."
118
- rep2_control = pooled_controls
107
+ pool_controls_subjob = pool_applet .run ({"inputs" : [ctl1_ta , ctl2_ta ]})
108
+ pooled_controls = pool_controls_subjob .get_output_ref ("pooled" )
109
+ #always use the pooled controls for the pool
110
+ control_for_pool = pooled_controls
111
+
112
+ #use the pooled controls for the reps depending on the ration of rep to control reads
113
+ ratio_ctl_reads = float (ntags_ctl1 )/ float (ntags_ctl2 )
114
+ if ratio_ctl_reads < 1 :
115
+ ratio_ctl_reads = 1 / ratio_ctl_reads
116
+ ratio_cutoff = 1.2
117
+ if ratio_ctl_reads > ratio_cutoff :
118
+ print "Number of reads in controls differ by > factor of %f. Using pooled controls." % (ratio_cutoff )
119
+ rep1_control = pooled_controls
120
+ rep2_control = pooled_controls
121
+ else :
122
+ if ntags_ctl1 < ntags_rep1 :
123
+ print "Fewer reads in control replicate 1 than experiment replicate 1. Using pooled controls for replicate 1."
124
+ rep1_control = pooled_controls
125
+ elif ntags_ctl2 < ntags_rep2 :
126
+ print "Fewer reads in control replicate 2 than experiment replicate 2. Using pooled controls for replicate 2."
127
+ rep2_control = pooled_controls
128
+ else :
129
+ print "Using distinct controls for replicate 1 and 2."
119
130
120
131
pseudoreplicator_applet = dxpy .find_one_data_object (
121
132
classname = 'applet' , name = 'pseudoreplicator' , zero_ok = False , more_ok = False , return_handler = True )
@@ -150,7 +161,7 @@ def main(rep1_ta, rep2_ta, ctl1_ta, ctl2_ta, rep1_xcor, rep2_xcor, rep1_paired_e
150
161
rep2_xcor , ** common_args )
151
162
152
163
pooled_peaks_subjob = macs2 ( pooled_replicates ,
153
- pooled_controls ,
164
+ control_for_pool ,
154
165
pooled_replicates_xcor_subjob .get_output_ref ("CC_scores_file" ), ** common_args )
155
166
156
167
rep1pr1_peaks_subjob = macs2 ( rep1_pr_subjob .get_output_ref ("pseudoreplicate1" ),
@@ -170,11 +181,11 @@ def main(rep1_ta, rep2_ta, ctl1_ta, ctl2_ta, rep1_xcor, rep2_xcor, rep1_paired_e
170
181
rep2_pr2_xcor_subjob .get_output_ref ("CC_scores_file" ), ** common_args )
171
182
172
183
pooledpr1_peaks_subjob = macs2 ( pool_pr1_subjob .get_output_ref ("pooled" ),
173
- pooled_controls ,
184
+ control_for_pool ,
174
185
pool_pr1_xcor_subjob .get_output_ref ("CC_scores_file" ), ** common_args )
175
186
176
187
pooledpr2_peaks_subjob = macs2 ( pool_pr2_subjob .get_output_ref ("pooled" ),
177
- pooled_controls ,
188
+ control_for_pool ,
178
189
pool_pr2_xcor_subjob .get_output_ref ("CC_scores_file" ), ** common_args )
179
190
180
191
output = {
0 commit comments