@@ -95,15 +95,22 @@ def get_data(token):
95
95
96
96
##renormalize values to max
97
97
##IMPORTANT: this is how we normalize without DMSO. We need to consider how we're doing this for EACH ORGANOID
98
- ##currently we take the max value of each orgnaoid/replicate.
99
- rtab ["MaxRep" ] = rtab .groupby (['Drug' ,'Organoid' ,'Rep' ]).Response .transform ('max' )
100
- rtab ['PercResponse' ] = (rtab .Response / rtab .MaxRep )* 100.00
98
+ ##currently we take the max value of each orgnaoid/replicate.
99
+ ##UPDATE: see belo
100
+ # rtab["MaxRep"] = rtab.groupby(['Drug','Organoid','Rep']).Response.transform('max')
101
+ # rtab['PercResponse'] = (rtab.Response/rtab.MaxRep)*100.00
101
102
102
103
103
104
##dosenum isa dummy value to use for merging since we need to repeat the concentrations over and over
104
105
dosenum = [a for a in range (15 )]
105
106
rtab ['Dosenum' ]= dosenum * int (rtab .shape [0 ]/ 15 )
106
107
108
+ ##The last dose (dosenum ==14) is the control value per Herve. we now must normalize to that
109
+
110
+ dmso_vals = rtab [rtab .Dosenum == 14 ][['Organoid' ,'Drug' ,'Rep' ,'Response' ]].rename ({'Response' :'DMSO' },axis = 1 )
111
+ full_res = rtab .merge (dmso_vals ,on = ['Organoid' ,'Drug' ,'Rep' ])
112
+ full_res ['PercResponse' ] = 100 * (full_res .Response / full_res .DMSO )
113
+
107
114
#print(set(rtab.Drug))
108
115
##merge the concentrations
109
116
concs = concs .dropna ().melt (value_vars = concs .columns ,var_name = 'Drug' ,value_name = 'Dose' )
@@ -114,7 +121,7 @@ def get_data(token):
114
121
concs ['Dosenum' ] = dosenum * int (concs .shape [0 ]/ 15 )##creating dosenum here to merge
115
122
#print(set(concs.Drug))
116
123
117
- return rtab .merge (concs )
124
+ return full_res .merge (concs )
118
125
119
126
if __name__ == '__main__' :
120
127
main ()
0 commit comments