This is a slight modification of Supplemental File 2 of our G3 paper "Direct Testing for Allele-Specific Expression Differences Between Conditions"
Save all the files in a folder (let's say MYFOLDER), cd to the folder itself and run the file RUNME.sh
cd MYFOLDER
./RUNME.sh
Details on the models are found in the paper.