Skip to content

Commit

Permalink
using custom objectscope to open the savemodel in shap_score.py; chan…
Browse files Browse the repository at this point in the history
…ge end to stop in peaks_df in shap_scores to prevent it from being overwritten
  • Loading branch information
viramalingam committed Mar 29, 2023
1 parent 86f27f4 commit 7f1574b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bpnet/cli/shap_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from bpnet.generators.sequtils import one_hot_encode
from bpnet.utils.misc import gaussian1D_smoothing
from tensorflow.keras.models import load_model
import tensorflow as tf
from tensorflow.keras.utils import CustomObjectScope

from bpnet.model.custommodel \
import CustomModel

import hdf5plugin

Expand Down Expand Up @@ -91,7 +96,7 @@ def shap_scores(args, shap_dir):

# read all the peaks into a pandas dataframe
peaks_df = pd.read_csv(args.bed_file, sep='\t', header=None,
names=['chrom', 'st', 'end', 'name', 'score',
names=['chrom', 'st', 'stop', 'name', 'score',
'strand', 'signalValue', 'p', 'q', 'summit'])

if args.chroms is not None:
Expand Down Expand Up @@ -412,7 +417,9 @@ def shap_scores_main():

# shap
logging.info("Loading {}".format(args.model))
shap_scores(args, shap_scores_dir)
with CustomObjectScope({'tf': tf,
'CustomModel': CustomModel}):
shap_scores(args, shap_scores_dir)

if __name__ == '__main__':
shap_scores_main()

0 comments on commit 7f1574b

Please sign in to comment.