Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Andrew Stirn
commited on
Commit
·
da98162
1
Parent(s):
d99c64e
progress
Browse files
tiger.py
CHANGED
|
@@ -18,6 +18,7 @@ REFERENCE_TRANSCRIPTS = ('gencode.v19.pc_transcripts.fa.gz', 'gencode.v19.lncRNA
|
|
| 18 |
BATCH_SIZE_COMPUTE = 500
|
| 19 |
BATCH_SIZE_SCAN = 20
|
| 20 |
BATCH_SIZE_TRANSCRIPTS = 50
|
|
|
|
| 21 |
|
| 22 |
# configure GPUs
|
| 23 |
for gpu in tf.config.list_physical_devices('GPU'):
|
|
@@ -101,27 +102,37 @@ def process_data(transcript_seq: str):
|
|
| 101 |
|
| 102 |
def prediction_transform(predictions: np.array, **params):
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
linear_regime = (params['a'] <= predictions) & (predictions <= params['c'])
|
| 107 |
-
inactive_saturation = params['c'] < predictions
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
intercept = -params['a'] * slope + params['b']
|
| 112 |
-
predictions[linear_regime] = slope * predictions[linear_regime] + intercept
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
|
| 127 |
def titration_ratio(guide: np.array, parent: np.array):
|
|
|
|
| 18 |
BATCH_SIZE_COMPUTE = 500
|
| 19 |
BATCH_SIZE_SCAN = 20
|
| 20 |
BATCH_SIZE_TRANSCRIPTS = 50
|
| 21 |
+
UNIT_INTERVAL_MAP = 'exp-lin-exp'
|
| 22 |
|
| 23 |
# configure GPUs
|
| 24 |
for gpu in tf.config.list_physical_devices('GPU'):
|
|
|
|
| 102 |
|
| 103 |
def prediction_transform(predictions: np.array, **params):
|
| 104 |
|
| 105 |
+
if UNIT_INTERVAL_MAP == 'sigmoid':
|
| 106 |
+
return 1 - 1 / (1 + np.exp(params['a'] * predictions + params['b']))
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
elif UNIT_INTERVAL_MAP == 'min-max':
|
| 109 |
+
return 1 - (predictions - params['a']) / (params['b'] - params['a'])
|
|
|
|
|
|
|
| 110 |
|
| 111 |
+
elif UNIT_INTERVAL_MAP == 'exp-lin-exp':
|
| 112 |
+
# regime indices
|
| 113 |
+
active_saturation = predictions < params['a']
|
| 114 |
+
linear_regime = (params['a'] <= predictions) & (predictions <= params['c'])
|
| 115 |
+
inactive_saturation = params['c'] < predictions
|
| 116 |
|
| 117 |
+
# linear regime
|
| 118 |
+
slope = (params['d'] - params['b']) / (params['c'] - params['a'])
|
| 119 |
+
intercept = -params['a'] * slope + params['b']
|
| 120 |
+
predictions[linear_regime] = slope * predictions[linear_regime] + intercept
|
| 121 |
|
| 122 |
+
# active saturation regime
|
| 123 |
+
alpha = slope / params['b']
|
| 124 |
+
beta = alpha * params['a'] - np.log(params['b'])
|
| 125 |
+
predictions[active_saturation] = np.exp(alpha * predictions[active_saturation] - beta)
|
| 126 |
+
|
| 127 |
+
# inactive saturation regime
|
| 128 |
+
alpha = slope / (1 - params['d'])
|
| 129 |
+
beta = -alpha * params['c'] - np.log(1 - params['d'])
|
| 130 |
+
predictions[inactive_saturation] = 1 - np.exp(-alpha * predictions[inactive_saturation] - beta)
|
| 131 |
+
|
| 132 |
+
return 1 - predictions
|
| 133 |
+
|
| 134 |
+
else:
|
| 135 |
+
raise NotImplementedError
|
| 136 |
|
| 137 |
|
| 138 |
def titration_ratio(guide: np.array, parent: np.array):
|