There is a repartition tool that you can use in TWRP to restore the partitions to their stock size. I have used it many of times to restore a Nexus 5.

Download hh_clamour_repartition zip from here.

Flash TWRP for the Nexus 5 and copy the zip file to the root of the phone storage, usually called SDcard. Follow the instructions on the XDA-developers link and set the partitions back to stock.

Flash a stock ROM to the Nexus 5.

Then install Ubuntu Touch to the phone.

I use WugFresh Development tool for nexus to flash the stock ROM as it id easy to use and generally works.