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
142 stars 35 forks source link

export-bw when training a model without negs errors out. #22

Closed snystrom closed 3 years ago

snystrom commented 3 years ago

I trained a model on some unstranded data but got the following error during bw export:

line 408, in export_bw    add_entry(bws[task]['preds.neg'], preds[:, 1],IndexError: index 1 is out of bounds for axis 1 with size 1

Looking at the line it's:

https://github.com/kundajelab/bpnet/blob/8d639405ea3974d8c097a5ca4508a0d56ca3efe0/bpnet/BPNet.py#L408

which exports the negative preds. Since my data don't have negative preds, my guess is that axis is empty. To test whether this was the issue, I commented out Line 408 and Line 335:

https://github.com/kundajelab/bpnet/blob/8d639405ea3974d8c097a5ca4508a0d56ca3efe0/bpnet/BPNet.py#L335

I replaced 335 with an array lacking the preds.neg entry. Rebuilt & that works fine.

So it seems there needs to be a check somewhere to determine whether the model has negs or not.

Avsecz commented 3 years ago

Thanks! Could you send a pull-request for that patch or a generalization of it? Happy to merge it. I've only been working with double-stranded data so many of the tools, especially the downstream interpretation ipython notebooks will only work with double-stranded data.

snystrom commented 3 years ago

Sure. Although I'm not sure the best way to detect whether there are any negative predictions. I haven't spent a ton of time digging into your API, so not sure the best way to make this work for both use cases.

Avsecz commented 3 years ago

Added the fix here: https://github.com/kundajelab/bpnet/commit/b9ec3e977ad3159ef4cab9c0d1e8474ffaa6c733. LMK if that doesn't solve the issue.