vr-scientist commited on
Commit
faca97a
·
verified ·
1 Parent(s): 72cc888

Update model card (ENCODE BPNet Atlas template)

Browse files
Files changed (1) hide show
  1. README.md +107 -24
README.md CHANGED
@@ -6,49 +6,132 @@ tags:
6
  - dna
7
  - genomics
8
  - transcription-factor-binding
 
9
  - encode
10
- - ChIP-seq
11
  - hg38
12
  - qc-unvalidated
13
  - RFX5
14
  ---
15
 
16
- # ENCODE BPNet -- RFX5 ChIP-seq in A549 (ENCSR064LJN)
17
 
18
- Trained BPNet model (ChIP-seq) from the ENCODE project.
 
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  - Experiment: [ENCSR064LJN](https://www.encodeproject.org/experiments/ENCSR064LJN/)
21
  - Model annotation: [ENCSR378PTO](https://www.encodeproject.org/annotations/ENCSR378PTO/)
22
- - Assembly: hg38 · Target: RFX5 · Biosample: A549
 
 
 
 
 
23
 
24
  ## QC
25
- - Status: **unvalidated**
 
26
  - Notes: Found direct motif (counts, profile); Low model performance (<0.5);
27
 
28
- ## Files
29
- 5-fold cross-validation. Each `fold_*/` holds the trained model in two forms:
30
- - `model.h5` — Keras weights (needs the `bpnet` custom layer to load)
31
- - `saved_model/` — TensorFlow SavedModel (portable; loads with no extra deps)
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- ## Load
34
  ```python
35
- from huggingface_hub import snapshot_download
36
  import tensorflow as tf
37
- d = snapshot_download("kundajelab/encode-bpnet-RFX5-ChIP-seq-A549-ENCSR064LJN-ENCSR378PTO")
38
- model = tf.saved_model.load(f"{d}/fold_0/saved_model") # portable
39
- # Keras .h5 (needs the bpnet package):
40
- # from bpnet.model.custommodel import CustomModel
41
- # m = tf.keras.models.load_model(f"{d}/fold_0/model.h5",
42
- # custom_objects={'CustomModel': CustomModel})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  ```
44
 
45
- ## Inference inputs
46
- The `serving_default` signature takes **three** inputs (not sequence alone):
47
- - `sequence` — one-hot DNA, shape `(N, 2114, 4)`
48
- - `profile_bias_input_0` — control (bias) profile track, shape `(N, 1000, 2)`
49
- - `counts_bias_input_0` — control log-count(s), shape `(N, 2)`
50
 
51
- The bias inputs are the experiment's matched control signal (the model file's `derived_from` control bigWigs on the ENCODE portal). Outputs: `profile_predictions` `(N, 1000, 2)` and `logcounts_predictions` `(N, 1)`. Reverse-complement averaging is the production default.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  ## License & citation
54
- Released under CC-BY-4.0, matching the [ENCODE data-use policy](https://www.encodeproject.org/about/data-use-policy/). Please cite the ENCODE Project Consortium and the model software: [BPNet](https://github.com/kundajelab/bpnet) (Avsec et al., Nat Genet 2021).
 
 
 
 
 
 
6
  - dna
7
  - genomics
8
  - transcription-factor-binding
9
+ - chip-seq
10
  - encode
11
+ - encode-bpnet-atlas
12
  - hg38
13
  - qc-unvalidated
14
  - RFX5
15
  ---
16
 
17
+ # ENCODE BPNet Atlas
18
 
19
+ As part of the ENCODE 4 Project, we trained BPNet models on 2,339 ENCODE
20
+ transcription factor ChIP-seq experiments spanning 788 targets across
21
+ 175 biosamples. Here, we provide all models for open-source use.
22
 
23
+ For more information about the models, see:
24
+
25
+ - Main ENCODE 4 Paper
26
+ - A unified lexicon of predictive DNA sequence motifs from ENCODE transcription
27
+ factor binding and chromatin accessibility assays (Deshpande et al., Zenodo 2025)
28
+ - Base-resolution models of transcription-factor binding reveal soft motif syntax
29
+ (Avsec et al., Nat Genet 2021)
30
+
31
+ ## BPNet model: RFX5 ChIP-seq in A549 (ENCSR064LJN)
32
+
33
+ - Model: BPNet
34
+ - Assay: TF ChIP-seq
35
+ - Target: RFX5
36
  - Experiment: [ENCSR064LJN](https://www.encodeproject.org/experiments/ENCSR064LJN/)
37
  - Model annotation: [ENCSR378PTO](https://www.encodeproject.org/annotations/ENCSR378PTO/)
38
+ - Biosample: A549 (Full name: Homo sapiens A549)
39
+ - Cell slim(s): cancer cell
40
+ - Organ slim(s): lung
41
+ - Developmental slim(s): endoderm
42
+ - System slim(s): respiratory system
43
+ - Assembly: hg38
44
 
45
  ## QC
46
+
47
+ - Status: unvalidated
48
  - Notes: Found direct motif (counts, profile); Low model performance (<0.5);
49
 
50
+ ## Directory structure
51
+
52
+ 5-fold cross-validation. Each `fold_*/` contains the trained BPNet model in two formats:
53
+
54
+ - `fold_0/model.h5` — BPNet model in .h5 (Keras) format
55
+ - `fold_0/saved_model/` — BPNet model in TensorFlow SavedModel format (a directory; load directly)
56
+ - `config.json` — training / architecture parameters
57
+
58
+ ## Instructions
59
+
60
+ BPNet takes a one-hot DNA sequence plus control (bias) inputs and predicts
61
+ stranded profile logits and total logcounts. The control inputs come from the
62
+ matched WCE/Input DNA control and **can be passed as zeros**.
63
+
64
+ ### 1. Loading the SavedModel and making predictions
65
 
 
66
  ```python
67
+ import numpy as np
68
  import tensorflow as tf
69
+ from scipy.special import logsumexp
70
+
71
+ model = tf.saved_model.load("fold_0/saved_model")
72
+ # sequence: (N, 2114, 4) one-hot [A,C,G,T]
73
+ # profile_bias_input: (N, 1000, 2) per-base profile bias from WCE/Input control, or zeros
74
+ # counts_bias_input: (N, 2) log2 total counts from WCE/Input control, or zeros
75
+ predictions = model.signatures["serving_default"](**{
76
+ "sequence": sequence.astype("float32"),
77
+ "profile_bias_input_0": profile_bias_input.astype("float32"),
78
+ "counts_bias_input_0": counts_bias_input.astype("float32")})
79
+ # predictions["profile_predictions"]: (N, 1000, 2) logits (strands NOT independent)
80
+ # predictions["logcounts_predictions"]: (N, 1) total logcount
81
+
82
+ output_len = 1000
83
+ def vectorized_prediction_to_profile(predictions):
84
+ logits_arr = predictions["profile_predictions"]
85
+ counts_arr = predictions["logcounts_predictions"]
86
+ pred_profile_logits = np.reshape(logits_arr, [-1, 1, output_len * 2])
87
+ probVals_array = np.exp(pred_profile_logits - logsumexp(
88
+ pred_profile_logits, axis=2).reshape([len(logits_arr), 1, 1]))
89
+ profile_predictions = np.multiply(
90
+ np.exp(counts_arr).reshape([len(counts_arr), 1, 1]), probVals_array)
91
+ plus = np.reshape(profile_predictions, [len(counts_arr), output_len, 2])[:, :, 0]
92
+ minus = np.reshape(profile_predictions, [len(counts_arr), output_len, 2])[:, :, 1]
93
+ return plus, minus, counts_arr
94
+
95
+ plus, minus, logcounts = vectorized_prediction_to_profile(predictions)
96
  ```
97
 
98
+ ### 2. Loading the .h5 (Keras) and making predictions
 
 
 
 
99
 
100
+ ```python
101
+ import numpy as np
102
+ import tensorflow as tf
103
+ import tensorflow.keras.backend as kb
104
+ from tensorflow.keras.models import load_model
105
+ from tensorflow.keras.utils import CustomObjectScope
106
+ from bpnet.model.custommodel import CustomModel
107
+
108
+ def get_model(model_path):
109
+ with CustomObjectScope({"kb": kb, "tf": tf, "CustomModel": CustomModel}):
110
+ return load_model(model_path)
111
+
112
+ model = get_model("fold_0/model.h5")
113
+ N = sequence.shape[0]
114
+ predictions = model.predict([
115
+ sequence, # (N, 2114, 4)
116
+ np.zeros((N, 1000, 2)), # profile_bias_input (or real WCE/Input control values)
117
+ np.zeros((N, 2))]) # counts_bias_input (or real control log2 counts)
118
+ # predictions[0]: (N, 1000, 2) logits; predictions[1]: (N, 1) logcounts
119
+ # convert with the same vectorized_prediction_to_profile() (predictions[0], predictions[1])
120
+ ```
121
+
122
+ ## Docker image to load and use the models
123
+
124
+ `kundajelab/bpnet-atlas` (placeholder — image forthcoming).
125
+
126
+ ## Code
127
+
128
+ - Code: https://github.com/kundajelab/bpnet/
129
+ - Toolbox & downstream analysis: https://github.com/kundajelab/bpnet/wiki
130
 
131
  ## License & citation
132
+
133
+ External data users may freely download, analyze and publish results based on any
134
+ ENCODE data without restrictions.
135
+
136
+ Released under the ENCODE data-use policy. Please cite the ENCODE Project
137
+ Consortium and the model software: BPNet (Avsec et al., Nat Genet 2021).