R Scripts for Bates Lab