Andrew Stirn commited on
Commit
6e3a126
·
1 Parent(s): 42a3866

common code to finalize tables

Browse files
Files changed (1) hide show
  1. tiger.py +5 -7
tiger.py CHANGED
@@ -302,9 +302,6 @@ def predict_off_target(off_targets: pd.DataFrame, model: tf.keras.Model):
302
  lfc_estimate = model.predict(model_inputs, batch_size=BATCH_SIZE_COMPUTE, verbose=False)
303
  off_targets[SCORE_COL] = prediction_transform(tf.squeeze(lfc_estimate).numpy())
304
 
305
- # trim context sequence
306
- off_targets[TARGET_COL] = off_targets[TARGET_COL].apply(lambda seq: seq[CONTEXT_5P:len(seq) - CONTEXT_3P])
307
-
308
  return off_targets.reset_index(drop=True)
309
 
310
 
@@ -345,10 +342,11 @@ def tiger_exhibit(transcripts: pd.DataFrame, mode: str, check_off_targets: bool,
345
  off_target_predictions = predict_off_target(off_target_candidates, model=tiger)
346
  off_target_predictions = off_target_predictions.sort_values(SCORE_COL, ascending=False)
347
 
348
- # reverse guide sequences
349
- on_target_predictions[GUIDE_COL] = on_target_predictions[GUIDE_COL].apply(lambda s: s[::-1])
350
- if check_off_targets and len(off_target_predictions) > 0:
351
- off_target_predictions[GUIDE_COL] = off_target_predictions[GUIDE_COL].apply(lambda s: s[::-1])
 
352
 
353
  return on_target_predictions, titration_predictions, off_target_predictions
354
 
 
302
  lfc_estimate = model.predict(model_inputs, batch_size=BATCH_SIZE_COMPUTE, verbose=False)
303
  off_targets[SCORE_COL] = prediction_transform(tf.squeeze(lfc_estimate).numpy())
304
 
 
 
 
305
  return off_targets.reset_index(drop=True)
306
 
307
 
 
342
  off_target_predictions = predict_off_target(off_target_candidates, model=tiger)
343
  off_target_predictions = off_target_predictions.sort_values(SCORE_COL, ascending=False)
344
 
345
+ # finalize tables
346
+ for df in [on_target_predictions, titration_predictions, off_target_predictions]:
347
+ if df is not None:
348
+ df[GUIDE_COL] = df[GUIDE_COL].apply(lambda s: s[::-1]) # reverse guide sequences
349
+ df[TARGET_COL] = df[TARGET_COL].apply(lambda seq: seq[CONTEXT_5P:len(seq) - CONTEXT_3P]) # remove context
350
 
351
  return on_target_predictions, titration_predictions, off_target_predictions
352