@@ -38,30 +38,36 @@ def _get_html(self, p):
3838
3939class DrugScreenDashboard (DataDashboard ):
4040
41- def __init__ (self , screen , treated , untreated , t0 = 'T0' , threshold = 3 , ctrl_label = 'negative_control' ,run_name = 'auto' ):
41+ def __init__ (
42+ self , screen , treated , untreated ,
43+ t0 = 'T0' , threshold = 3 , ctrl_label = 'negative_control' ,
44+ run_name = 'auto' ,
45+ score_col = 'score' , pvalue_col = 'pvalue'
46+ ):
4247 self .screen = screen
4348 self .threshold = threshold
4449 self .ctrl_label = ctrl_label
4550 self .run_name = run_name
4651 self .gamma_score_name = f'gamma:{ untreated } _vs_{ t0 } '
4752 self .rho_score_name = f'rho:{ treated } _vs_{ untreated } '
53+ self .df = self ._prep_data (screen , score_col = score_col , pvalue_col = pvalue_col )
4854 self .plots = {}
4955 super ().__init__ ()
5056
5157 def _prep_data (self ,screen , score_col = 'score' , pvalue_col = 'pvalue' ):
5258
5359 gamma = screen .getPhenotypeScores (
60+ phenotype_name = self .gamma_score_name ,
5461 run_name = self .run_name ,
55- score_name = self .gamma_score_name ,
5662 threshold = self .threshold ,
5763 ctrl_label = self .ctrl_label ,
5864 score_col = score_col ,
5965 pvalue_col = pvalue_col
6066 )
6167
6268 rho = screen .getPhenotypeScores (
69+ phenotype_name = self .rho_score_name ,
6370 run_name = self .run_name ,
64- score_name = self .rho_score_name ,
6571 threshold = self .threshold ,
6672 ctrl_label = self .ctrl_label ,
6773 score_col = score_col ,
@@ -71,17 +77,17 @@ def _prep_data(self,screen, score_col='score', pvalue_col='pvalue'):
7177 df = pd .DataFrame ({
7278 'target' : rho ['target' ],
7379 'rho_score' : rho ['score' ],
74- 'rho_pvalue' : rho ['pvalue' ],
80+ 'rho_pvalue' : rho [pvalue_col ],
7581 'rho_label' : rho ['label' ],
76- '-log10(rho_pvalue)' : np .log10 (rho ['pvalue' ]) * - 1 ,
82+ '-log10(rho_pvalue)' : np .log10 (rho [pvalue_col ]) * - 1 ,
7783 'gamma_score' : gamma .loc [rho .index ,'score' ],
78- 'gamma_pvalue' : gamma .loc [rho .index ,'pvalue' ],
84+ 'gamma_pvalue' : gamma .loc [rho .index ,pvalue_col ],
7985 'gamma_label' : gamma .loc [rho .index ,'label' ],
80- '-log10(gamma_pvalue)' : np .log10 (gamma .loc [rho .index ,'pvalue' ]) * - 1 ,
86+ '-log10(gamma_pvalue)' : np .log10 (gamma .loc [rho .index ,pvalue_col ]) * - 1 ,
8187 })
8288
8389 return df
84-
90+
8591 def _plot_scatter (
8692 self ,
8793 x_source ,y_source ,
@@ -93,11 +99,9 @@ def _plot_scatter(
9399 dot_size = 1 ,
94100 width = 500 , height = 400 ,
95101 toolbar_location = 'below' ,
96- legend_loc = "top_left"
102+ legend_loc = "top_left" ,
97103 ):
98-
99- df = self ._prep_data (self .screen )
100-
104+ df = self .df .copy ()
101105 if y_max == 'auto' : y_max = df [y_source ].max () * 1.2
102106 if x_max == 'auto' : x_max = df [x_source ].max () * 1.2
103107 if y_min == 'auto' : y_min = df [y_source ].min () * 1.2
@@ -216,15 +220,13 @@ def RhoVolcanoPlot(
216220 hit_label_col = 'rho_label' ,
217221 x_min = - 2.5 , x_max = 2.5 , y_min = 0 , y_max = 'auto' ,
218222 return_html = True ,
219- ** kwargs
220223 ):
221224 p = self ._plot_scatter (
222225 x_source , y_source ,
223226 xaxis_label , yaxis_label ,
224227 up_hit , down_hit ,
225228 hit_label_col ,
226229 x_min , x_max , y_min , y_max ,
227- ** kwargs
228230 )
229231
230232 if return_html :
@@ -243,15 +245,13 @@ def GammaVolcanoPlot(
243245 hit_label_col = 'gamma_label' ,
244246 x_min = - 2.5 , x_max = 2.5 , y_min = 0 , y_max = 'auto' ,
245247 return_html = True ,
246- ** kwargs
247248 ):
248249 p = self ._plot_scatter (
249250 x_source , y_source ,
250251 xaxis_label , yaxis_label ,
251252 up_hit , down_hit ,
252253 hit_label_col ,
253254 x_min , x_max , y_min , y_max ,
254- ** kwargs
255255 )
256256
257257 if return_html :
@@ -270,15 +270,13 @@ def RhoGammaScatter(
270270 hit_label_col = 'rho_label' ,
271271 return_html = True ,
272272 x_min = - 2.5 , x_max = 2.5 , y_min = - 2.5 , y_max = 2.5 ,
273- ** kwargs
274273 ):
275274 p = self ._plot_scatter (
276275 x_source , y_source ,
277276 xaxis_label , yaxis_label ,
278277 up_hit , down_hit ,
279278 hit_label_col ,
280279 x_min , x_max , y_min , y_max ,
281- ** kwargs
282280 )
283281
284282 if return_html :
0 commit comments