def single_locus_net_informativeness(locus_table, net_pi_table, locus): qry = '''"SELECT {0}.locus, time, pi FROM {0}, {1} WHERE {0}.id = {1}.id AND locus = '{2}'"'''.format(locus_table, net_pi_table, locus) frame = robjects.r('''dbGetQuery(con, {})'''.format(qry)) gg_frame = ggplot2.ggplot(frame) plot = gg_frame + ggplot2.aes_string(x = 'time', y='pi') + \ ggplot2.geom_point(size = 3, alpha = 0.4) + \ ggplot2.scale_x_reverse('years ago') + \ ggplot2.scale_y_continuous('phylogenetic informativeness') + \ ggplot2.opts(title = locus) return plot
def multiple_locus_net_informativeness_scatterplot(locus_table, net_pi_table, loci): if loci[0].lower() != 'all': qry = '''"SELECT {0}.locus, time, pi FROM {0}, {1} WHERE {0}.id = {1}.id and locus in {2}"'''.format(locus_table, net_pi_table, tuple(loci)) else: qry = '''"SELECT {0}.locus, time, pi FROM {0}, {1} WHERE {0}.id = {1}.id"'''.format(locus_table, net_pi_table) frame = robjects.r('''dbGetQuery(con, {})'''.format(qry)) gg_frame = ggplot2.ggplot(frame) plot = gg_frame + ggplot2.aes_string(x = 'time', y = 'pi') + \ ggplot2.geom_point(ggplot2.aes_string(colour = 'locus'), \ size = 3, alpha = 0.4) + ggplot2.scale_x_reverse('years ago') + \ ggplot2.scale_y_continuous('phylogenetic informativeness') return plot