kundajelab / bpnet

Toolkit to train base-resolution deep neural networks on functional genomics data and to interpret them
http://bit.ly/bpnet-colab
MIT License
141 stars 33 forks source link

Viewing the hypothetical impscores #38

Open evanseitz opened 2 years ago

evanseitz commented 2 years ago

I'm interested in viewing the hyp_impscores of the BPNet outputs, as seen in line 5, row 2 of this document.

First, I'm able to view the standard contribution scores using the dictionary produced via: viz_dict, seq, imp_scores = interval_predict(bpnet, ds, interval, tasks, smooth_obs_n=0, neg_rev=False, incl_pred=True)

E.g., via viz_dict['Nanog Imp profile'], which I understand to represent the absolute amount of the contribution score for task {task=Nanog} at the motif instance position — i.e., these are the "contribution of each base within the input sequence to the entire predicted ChiP nexus profile of the TF {task=Nanog} output by DeepLIFT"

As I understand, these are derived by taking the dot product of hyp_impscores with the given one-hot encoding. Is it true that imp_scores['Nanog/profile/wn'][0] (for this example) stores the hyp_impscores?

Avsecz commented 2 years ago

In general, you can generate hypothetical contribution scores for a sequence using contrib_scoremethod on SeqModel as done here: https://github.com/kundajelab/bpnet/blob/master/bpnet/cli/contrib.py#L238-L241.

Throughout the codebase, 'imp' or 'contrib' refer to hyp_contrib * dna_sequence, where dna_sequence is one-hot encoded (as you correctly inferred).

For accessing hypothetical contribution scores of patterns produces by TF-MoDISco you can access the hyp_contrib values of the Pattern class https://github.com/kundajelab/bpnet/blob/master/bpnet/modisco/core.py#L42. You can also use pattern.plot(kind='hyp_contrib')method to visualize the hypothetical contributions of a pattern. A list of patterns from a modisco run can be obtained from ModiscoFile class (.patterns()) https://github.com/kundajelab/bpnet/blob/master/bpnet/modisco/files.py#L74.

evanseitz commented 2 years ago

Thank you, this is very helpful information.