Andrew Stirn commited on
Commit
699c100
·
1 Parent(s): bbf83b3

calibration active for webtool

Browse files
Files changed (1) hide show
  1. tiger.py +6 -4
tiger.py CHANGED
@@ -178,8 +178,9 @@ def get_on_target_predictions(transcripts: pd.DataFrame, model: tf.keras.Model,
178
  target_seq, guide_seq, model_inputs = process_data(row[SEQ_COL])
179
 
180
  # get predictions
181
- lfc_estimate = model.predict(model_inputs, batch_size=BATCH_SIZE_COMPUTE, verbose=False)
182
- scores = transform_predictions(tf.squeeze(lfc_estimate).numpy())
 
183
  predictions = pd.concat([predictions, pd.DataFrame({
184
  ID_COL: [index] * len(scores),
185
  TARGET_COL: target_seq,
@@ -306,8 +307,9 @@ def predict_off_target(off_targets: pd.DataFrame, model: tf.keras.Model):
306
  tf.reshape(one_hot_encode_sequence(off_targets[TARGET_COL], add_context_padding=False), [len(off_targets), -1]),
307
  tf.reshape(one_hot_encode_sequence(off_targets[GUIDE_COL], add_context_padding=True), [len(off_targets), -1]),
308
  ], axis=-1)
309
- lfc_estimate = model.predict(model_inputs, batch_size=BATCH_SIZE_COMPUTE, verbose=False)
310
- off_targets[SCORE_COL] = transform_predictions(tf.squeeze(lfc_estimate).numpy())
 
311
 
312
  return off_targets.reset_index(drop=True)
313
 
 
178
  target_seq, guide_seq, model_inputs = process_data(row[SEQ_COL])
179
 
180
  # get predictions
181
+ lfc_estimate = np.squeeze(model.predict(model_inputs, batch_size=BATCH_SIZE_COMPUTE, verbose=False))
182
+ lfc_estimate = calibrate_predictions(lfc_estimate, num_mismatches=np.zeros_like(lfc_estimate))
183
+ scores = transform_predictions(lfc_estimate)
184
  predictions = pd.concat([predictions, pd.DataFrame({
185
  ID_COL: [index] * len(scores),
186
  TARGET_COL: target_seq,
 
307
  tf.reshape(one_hot_encode_sequence(off_targets[TARGET_COL], add_context_padding=False), [len(off_targets), -1]),
308
  tf.reshape(one_hot_encode_sequence(off_targets[GUIDE_COL], add_context_padding=True), [len(off_targets), -1]),
309
  ], axis=-1)
310
+ lfc_estimate = np.squeeze(model.predict(model_inputs, batch_size=BATCH_SIZE_COMPUTE, verbose=False))
311
+ lfc_estimate = calibrate_predictions(lfc_estimate, off_targets['Number of Mismatches'].to_numpy())
312
+ off_targets[SCORE_COL] = transform_predictions(lfc_estimate)
313
 
314
  return off_targets.reset_index(drop=True)
315