def OnGraphInbreed(self, event): # try: if hasattr(self, '_pedigree'): if not self._pedigree.kw['f_computed']: _ped_inbr = pyp_nrm.inbreeding(self._pedigree) pyp_db.loadPedigreeTable(self._pedigree) _coi_by_year = pyp_reports.meanMetricBy(self._pedigree, metric='fa', byvar='by') del (_coi_by_year[1900]) _graph = pyp_graphics.plot_line_xy( _coi_by_year, gfilename='_coi_by_year', gtitle='Average coefficients of inbreeding', gxlabel='Birth year', gylabel='f') if _graph: # wx.InitAllImageHandlers() # _i = wx.Image('_coi_by_year.png', wx.BITMAP_TYPE_PNG) # _b = wx.BitmapFromImage(_i) # _sb = wx.StaticBitmap(self, -1, _b, (10, 10), (_b.GetWidth(), _b.GetHeight())) dlg = pyp_gui_graphs.PyPedalGraphDialogInbreeding( self, ID_MAIN_TB, 'PyPedal - View inbreeding by birth year') try: dlg.ShowModal() finally: dlg.Destroy()
def OnGraphInbreed(self,event): # try: if hasattr(self,'_pedigree'): if not self._pedigree.kw['f_computed']: _ped_inbr = pyp_nrm.inbreeding(self._pedigree) pyp_db.loadPedigreeTable(self._pedigree) _coi_by_year = pyp_reports.meanMetricBy(self._pedigree,metric='fa',byvar='by') del(_coi_by_year[1900]) _graph = pyp_graphics.plot_line_xy(_coi_by_year,gfilename='_coi_by_year',gtitle='Average coefficients of inbreeding',gxlabel='Birth year',gylabel='f') if _graph: # wx.InitAllImageHandlers() # _i = wx.Image('_coi_by_year.png', wx.BITMAP_TYPE_PNG) # _b = wx.BitmapFromImage(_i) # _sb = wx.StaticBitmap(self, -1, _b, (10, 10), (_b.GetWidth(), _b.GetHeight())) dlg = pyp_gui_graphs.PyPedalGraphDialogInbreeding(self,ID_MAIN_TB,'PyPedal - View inbreeding by birth year') try: dlg.ShowModal() finally: dlg.Destroy()
from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal import pyp_reports from PyPedal.pyp_utils import pyp_nice_time if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='new_graphics.ini') # example_inbreeding = pyp_nrm.inbreeding(example) pyp_graphics.rmuller_spy_matrix_pil(example.nrm.nrm, fname='dog_sparsity.png', cutoff=0.01, do_outline=0, height=example.nrm.nrm.shape[0], width=example.nrm.nrm.shape[0]) pyp_graphics.rmuller_pcolor_matrix_pil(example.nrm.nrm, fname='dog_long_pcolored.png', do_outline=0, height=example.nrm.nrm.shape[0], width=example.nrm.nrm.shape[0]) #pyp_db.loadPedigreeTable(example) pyp_db.deleteTable(example) pyp_db.populatePedigreeTable(example) coi_by_year = pyp_reports.meanMetricBy(example, metric='fa', byvar='by') print 'coi_by_year: ', coi_by_year cby = coi_by_year del(cby[1900]) pyp_graphics.plot_line_xy(coi_by_year, gfilename='dog_coi_by_year', gtitle='', gxlabel='Birth year', gylabel='Coefficient of inbreeding') pyp_graphics.draw_pedigree(example, gfilename='dog_pedigree', gtitle='Dog pedigree',gformat='jpg',gsize='f') pyp_graphics.plot_founders_by_year(example, gfilename='dog_founders_by_year', gtitle='Number of founders within each birthyear') pyp_graphics.plot_founders_pct_by_year(example, gfilename='dog_founder_pct', gtitle='Percentage of founders within each birthyear')
fname='dog_sparsity.png', cutoff=0.01, do_outline=0, height=example.nrm.nrm.shape[0], width=example.nrm.nrm.shape[0]) pyp_graphics.rmuller_pcolor_matrix_pil(example.nrm.nrm, fname='dog_long_pcolored.png', do_outline=0, height=example.nrm.nrm.shape[0], width=example.nrm.nrm.shape[0]) #pyp_db.loadPedigreeTable(example) pyp_db.deleteTable(example) pyp_db.populatePedigreeTable(example) coi_by_year = pyp_reports.meanMetricBy(example, metric='fa', byvar='by') print 'coi_by_year: ', coi_by_year cby = coi_by_year del (cby[1900]) pyp_graphics.plot_line_xy(coi_by_year, gfilename='dog_coi_by_year', gtitle='', gxlabel='Birth year', gylabel='Coefficient of inbreeding') pyp_graphics.draw_pedigree(example, gfilename='dog_pedigree', gtitle='Dog pedigree', gformat='jpg', gsize='f')
options['messages'] = 'verbose' options['pedfile'] = 'hartlandclark.ped' options['pedname'] = 'Pedigree from van Noordwijck and Scharloo (1981)' options['pedformat'] = 'asdb' options['pedigree_is_renumbered'] = 1 options['database_name'] = 'new_db_test' options['dbtable_name'] = 'test' options['database_type'] = 'sqlite' if __name__ == '__main__': example = pyp_newclasses.loadPedigree(options) pyp_nrm.inbreeding(example) print 'Dropping existing table...' pyp_db.deleteTable(example) print 'Checking to see if the table is gone...' pyp_db.doesTableExist(example) print 'Creating the table...' pyp_db.createPedigreeTable(example) print 'Populating the table...' pyp_db.populatePedigreeTable(example) mean_inbreeding = pyp_reports.meanMetricBy(example, metric='fa', byvar='by') print mean_inbreeding pyp_graphics.plot_line_xy(mean_inbreeding, gfilename='great_tit_coi_by_year', \ gtitle='', gxlabel='Birth year', gylabel='Coefficient of inbreeding')
options = {} options['messages'] = 'verbose' options['pedfile'] = 'hartlandclark.ped' options['pedname'] = 'Pedigree from van Noordwijck and Scharloo (1981)' options['pedformat'] = 'asdb' options['pedigree_is_renumbered'] = 1 options['database_name'] = 'new_db_test' options['dbtable_name'] = 'test' options['database_type'] = 'sqlite' if __name__ == '__main__': example = pyp_newclasses.loadPedigree(options) pyp_nrm.inbreeding(example) print 'Dropping existing table...' pyp_db.deleteTable(example) print 'Checking to see if the table is gone...' pyp_db.doesTableExist(example) print 'Creating the table...' pyp_db.createPedigreeTable(example) print 'Populating the table...' pyp_db.populatePedigreeTable(example) mean_inbreeding = pyp_reports.meanMetricBy(example,metric='fa',byvar='by') print mean_inbreeding pyp_graphics.plot_line_xy(mean_inbreeding, gfilename='great_tit_coi_by_year', \ gtitle='', gxlabel='Birth year', gylabel='Coefficient of inbreeding')