Andrew Stirn commited on
Commit
a2e6f51
·
1 Parent(s): 0b0f412

tiger transform back online

Browse files
Files changed (2) hide show
  1. tiger.py +4 -4
  2. transform_params.pkl +0 -0
tiger.py CHANGED
@@ -130,8 +130,8 @@ def calibrate_predictions(predictions: np.array, num_mismatches: np.array, param
130
  return correction * predictions
131
 
132
 
133
- def prediction_transform(predictions: np.array, **params):
134
- if len(params) == 0:
135
  with open('transform_params.pkl', 'rb') as f:
136
  params = pickle.load(f)
137
 
@@ -179,7 +179,7 @@ def get_on_target_predictions(transcripts: pd.DataFrame, model: tf.keras.Model,
179
 
180
  # get predictions
181
  lfc_estimate = model.predict(model_inputs, batch_size=BATCH_SIZE_COMPUTE, verbose=False)
182
- scores = prediction_transform(tf.squeeze(lfc_estimate).numpy())
183
  predictions = pd.concat([predictions, pd.DataFrame({
184
  ID_COL: [index] * len(scores),
185
  TARGET_COL: target_seq,
@@ -307,7 +307,7 @@ def predict_off_target(off_targets: pd.DataFrame, model: tf.keras.Model):
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] = prediction_transform(tf.squeeze(lfc_estimate).numpy())
311
 
312
  return off_targets.reset_index(drop=True)
313
 
 
130
  return correction * predictions
131
 
132
 
133
+ def transform_predictions(predictions: np.array, params: dict = None):
134
+ if params is None:
135
  with open('transform_params.pkl', 'rb') as f:
136
  params = pickle.load(f)
137
 
 
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,
 
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
 
transform_params.pkl CHANGED
Binary files a/transform_params.pkl and b/transform_params.pkl differ