code to produce pattuples+trees+plots for gem analysis