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 MetricsEffectiveFounders(self): if hasattr(self,'_pedigree'): self._inbreeding = pyp_nrm.inbreeding(self._pedigree) self.textbox.Clear() print pyp_io.summary_inbreeding(self._inbreeding['metadata']) self.textbox.AppendText(pyp_io.summary_inbreeding(self._inbreeding['metadata'])) else: pyp_gui_graphs.PyPedalShowErrorDialog(self,sedTitle='Calculate effective founder', sedMessage='This calculation cannot be displayed because you have not yet loaded a pedigree!')
def MetricsEffectiveFounders(self): if hasattr(self, '_pedigree'): self._inbreeding = pyp_nrm.inbreeding(self._pedigree) self.textbox.Clear() print pyp_io.summary_inbreeding(self._inbreeding['metadata']) self.textbox.AppendText( pyp_io.summary_inbreeding(self._inbreeding['metadata'])) else: pyp_gui_graphs.PyPedalShowErrorDialog( self, sedTitle='Calculate effective founder', sedMessage= 'This calculation cannot be displayed because you have not yet loaded a pedigree!' )
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_newclasses from PyPedal import pyp_metrics from PyPedal import pyp_nrm from PyPedal import pyp_utils from PyPedal.pyp_utils import pyp_nice_time if __name__=='__main__': print 'Starting pypedal.py at %s' % ( pyp_nice_time() ) example = pyp_newclasses.loadPedigree(optionsfile='new_format.ini') #pyp_utils.assign_offspring(example) #print 'First ID: %s' % ( example.kw['id_first'] ) #print 'Last ID: %s' % ( example.kw['id_last'] ) inbr, reln = inbr, reln = pyp_nrm.inbreeding(example,method='vanraden',rels=1) print 'inbr: ', inbr print 'reln: ', reln example.nrm = pyp_newclasses.NewAMatrix(example.kw) example.nrm.form_a_matrix(example.pedigree) example.nrm.save('Amatrix.txt') inbr2, reln2 = pyp_nrm.inbreeding(example,method='vanraden',rels=1) print 'inbr2: ', inbr2 print 'reln2: ', reln2 example.nrm2 = pyp_newclasses.NewAMatrix(example.kw) example.nrm2.load('Amatrix.txt') #example.nrm2.printme()
#!/usr/bin/python ############################################################################### # NAME: new_graphics.py # VERSION: 2.0.0b5 (19DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal import pyp_nrm if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='new_renumbering.ini') print '-'*80 print 'INFO: Pedigree ID map: %s' % (example.idmap) print '-'*80 print 'INFO: Pedigree ID reverse map: %s' % (example.backmap) print '-'*80 myinbr = pyp_nrm.inbreeding(example) print 'INFO: Coefficients of inbreeding: %s' % (myinbr) pyp_graphics.draw_pedigree(example,gfilename='new_renumbering',gtitle='My Pedigree')
from PyPedal import pyp_jbc from PyPedal import pyp_network from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal import pyp_metrics if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='newfoundland.ini') print example.idmap print example.backmap print example.namemap print example.namebackmap newf_f = pyp_nrm.inbreeding(example) print newf_f['fx'][example.idmap[ example.namemap['Kaptn Kvols von Widdersdorf']]] ## dussel_id = example.idmap[example.namemap['King von der Dussel']] ## print 'dussel_id: ', dussel_id ## ## print 'Empirical proof that ancestor loss coefficients are the same' ## print 'as pedigree completeness.' ## ## pedcomp3 = pyp_metrics.pedigree_completeness(example,gens=3) ## print example.pedigree[dussel_id-1].pedcomp ## pedcomp4 = pyp_metrics.pedigree_completeness(example,gens=4) ## print example.pedigree[dussel_id-1].pedcomp ## pedcomp5 = pyp_metrics.pedigree_completeness(example,gens=5) ## print example.pedigree[dussel_id-1].pedcomp
# # pyp_graphics.draw_pedigree(horse, gfilename='blue_joe', # gtitle='Blue Joe\'s Pedigree', gorient='p', gname=1, gdirec='RL', # gfontsize=12, garrow=0, gtitloc='b') ## print '\nRen ID\tName\n------\t----' ## for _k in horse.backmap.keys(): ## print '%s\t%s' % ( _k, horse.pedigree[int(_k)-1].name ) ## print '-'*80 ## horse_inbreeding = pyp_nrm.inbreeding(horse, method='vanraden', gens=2) ## print '\nHorse 2 gen inbreeding: %s' % ( horse_inbreeding ) ## print '\nHorse mean 2 gen CoI: %s' % ( horse_inbreeding['metadata']['all']['f_avg'] ) horse_inbreeding, horse_rels = pyp_nrm.inbreeding(horse, method='tabular', rels=1) print '\nHorse inbreeding: %s' % ( horse_inbreeding ) print '\nHorses wth non-zero coefficients of inbreeding:' print '-----------------------------------------------' for _h in horse_inbreeding['fx'].keys(): if horse_inbreeding['fx'][_h] > 0.: print '%s\t\t%s' % ( horse.pedigree[int(_h)-1].name, horse_inbreeding['fx'][_h] ) print '\nHorse mean CoI:\t\t%s' % ( horse_inbreeding['metadata']['all']['f_avg'] ) ## print '-'*80 ## ## hg = pyp_network.ped_to_graph(horse) ## _2g = pyp_network.find_ancestors_g(hg, len(horse.idmap), {}, 2) ## _2g[len(horse.idmap)] = 1 ## _names = [] ## for _h in _2g.keys():
options['pedformat'] = 'asd' options['pedname'] = 'My Pedigree' options['matrix_type'] = 'sparse' options['renumber'] = 0 options['pedigree_is_renumbered'] = 1 if __name__ == '__main__': # example = pyp_newclasses.loadPedigree(optionsfile='new_inbreeding.ini') example = pyp_newclasses.loadPedigree(options) print example print '[DEBUG]: matrix_type = ', example.kw['matrix_type'] print 'Started computing inbreeding at %s' % (pyp_nice_time()) example_inbreeding_vr = pyp_nrm.inbreeding(example,method='vanraden') example_inbreeding_ml = pyp_nrm.inbreeding(example,method='meu_luo') example_inbreeding_qu = pyp_nrm.inbreeding(example,method='mod_meu_luo') print 'Finished computing inbreeding at %s' % (pyp_nice_time()) # print example_inbreeding # print example_inbreeding['fx'][28] print '\nVanRaden : ', example_inbreeding_vr['metadata'] print '\nMeuwissen and Luo : ', example_inbreeding_ml['metadata'] print '\nModified Meuwissen and Luo: ', example_inbreeding_qu['metadata'] # example_2 = pyp_newclasses.loadPedigree(optionsfile='new_inbreeding_2.ini') # example_inbreeding_2 = pyp_nrm.inbreeding(example_2) # print example_inbreeding_2 # print 'f_x for 73543: ', example_inbreeding_2['fx'][example_2.idmap[int('73543')]]
from PyPedal import pyp_graphics 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
#!/usr/bin/python ############################################################################### # NAME: new_hartl.py # VERSION: 2.0.0b12 (15MAY2060) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal import pyp_nrm if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='new_hartl.ini') pyp_graphics.draw_pedigree( example, gfilename='hartlandclark', gtitle='Pedigree from van Noordwijck and Scharloo (1981)', gorient='p', gname=0, gdirec='', gfontsize=12, garrow=0) example_inbreeding = pyp_nrm.inbreeding(example) print example_inbreeding
# Here's how to save the A matrix to a binary file. amatrix.save('boichard2_pedigree.bin') # Here's how to load the A matrix from a binary file. amatrix2 = pyp_newclasses.NewAMatrix(example.kw) amatrix2.load('boichard2_pedigree.bin') # Now we're going to calculate coefficients of inbreeding for the individuals # in this pedigree. There are a few different algorithms for doing this in # PyPedal. # VanRaden's method is slow, but it will work (eventually) on just about any # pedigree you give it. It also is the only method that will allow you to # compute summary statistics about coefficients of relationship. print '\tEntering pyp_nrm.inbreeding() at %s' % (pyp_utils.pyp_nice_time()) example_inbreeding = pyp_nrm.inbreeding(example, method='vanraden') print '\tReturning from pyp_nrm.inbreeding() at %s' % ( pyp_utils.pyp_nice_time()) print example_inbreeding['metadata'] # If all you want are fast calculations of inbreeding coefficients, then you # should use the Meuwissen & Luo or modified Meuwissen & Luo methods. print '\tStarted computing inbreeding using Meuwissen and Luo\'s method at %s' % ( pyp_utils.pyp_nice_time()) test_inbreeding_ml = pyp_nrm.inbreeding(example, method='meu_luo') print '\tFinished computing inbreeding using Meuwissen and Luo\'s method at %s' % ( pyp_utils.pyp_nice_time()) print test_inbreeding_ml['metadata'] # All methods should produce the same coefficients of inbreeding. print '\n\tStarted computing inbreeding using Meuwissen and Luo\'s modified method at %s' % (
from PyPedal import pyp_network from PyPedal import pyp_newclasses from PyPedal import pyp_nrm #from PyPedal import pyp_reports from PyPedal import pyp_metrics if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='new_reporting.ini') #example.printoptions() #pyp_reports.pdfPedigreeMetadata(example, titlepage = 1, reporttitle = 'Metadada for My Pedigree', reportauthor = 'John B. Cole, PhD') #pyp_reports.pdfPedigreeMetadata(example, titlepage = 1, reportauthor = 'John B. Cole, PhD', reportfile = 'metadata_report.pdf') ib = pyp_nrm.inbreeding(example) #coi_by_year = pyp_reports.meanMetricBy(example,metric='fa',byvar='by',createpdf=1) #coi_by_year #print ib #for _e in example.pedigree: #print _e.name, _e.fa print example.kw['paper_size'] #print example.backmap ## Use with new_renumbering.ped. #pyp_reports.pdf3GenPed([56,72], example) ## Use with horse.ped. #pyp_reports.pdf3GenPed(["Pie's Joseph","Green's Dingo"], example) #pyp_reports.pdf3GenPed("Green's Dingo", example,reportfile='greens_dingo_pedigree.pdf')
############################################################################### from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal.pyp_utils import pyp_nice_time import numpy import time if __name__ == '__main__': print 'Starting pypedal.py at %s' % (pyp_nice_time()) example = pyp_newclasses.loadPedigree(optionsfile='new_amatrix.ini') amatrix = pyp_newclasses.NewAMatrix(example.kw) amatrix.form_a_matrix(example.pedigree) # Here's how to save a matrix to a binary file. # amatrix.save('boichard2_pedigree.bin') # Here's how to load a matrix from a binary file. # amatrix2 = pyp_newclasses.NewAMatrix(example.kw) # amatrix2.load('boichard2_pedigree.bin') # Calculate coefficients of inbreeding on this pedigree. print '\tEntering pyp_nrm.inbreeding() at %s' % (pyp_nice_time()) example_inbreeding = pyp_nrm.inbreeding(example,method='vanraden') print '\tReturning from pyp_nrm.inbreeding() at %s' % (pyp_nice_time()) print example_inbreeding['metadata']
from PyPedal import pyp_jbc from PyPedal import pyp_network from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal import pyp_metrics if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='newfoundland.ini') print example.idmap print example.backmap print example.namemap print example.namebackmap newf_f = pyp_nrm.inbreeding(example) print newf_f['fx'][example.idmap[example.namemap['Kaptn Kvols von Widdersdorf']]] ## dussel_id = example.idmap[example.namemap['King von der Dussel']] ## print 'dussel_id: ', dussel_id ## ## print 'Empirical proof that ancestor loss coefficients are the same' ## print 'as pedigree completeness.' ## ## pedcomp3 = pyp_metrics.pedigree_completeness(example,gens=3) ## print example.pedigree[dussel_id-1].pedcomp ## pedcomp4 = pyp_metrics.pedigree_completeness(example,gens=4) ## print example.pedigree[dussel_id-1].pedcomp ## pedcomp5 = pyp_metrics.pedigree_completeness(example,gens=5) ## print example.pedigree[dussel_id-1].pedcomp
############################################################################### from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal.pyp_utils import pyp_nice_time import numpy import time if __name__ == '__main__': print 'Starting pypedal.py at %s' % (pyp_nice_time()) example = pyp_newclasses.loadPedigree(optionsfile='new_amatrix.ini') amatrix = pyp_newclasses.NewAMatrix(example.kw) amatrix.form_a_matrix(example.pedigree) # Here's how to save a matrix to a binary file. # amatrix.save('boichard2_pedigree.bin') # Here's how to load a matrix from a binary file. # amatrix2 = pyp_newclasses.NewAMatrix(example.kw) # amatrix2.load('boichard2_pedigree.bin') # Calculate coefficients of inbreeding on this pedigree. print '\tEntering pyp_nrm.inbreeding() at %s' % (pyp_nice_time()) example_inbreeding = pyp_nrm.inbreeding(example, method='vanraden') print '\tReturning from pyp_nrm.inbreeding() at %s' % (pyp_nice_time()) print example_inbreeding['metadata']
#!/usr/bin/python ############################################################################### # NAME: new_hartl.py # VERSION: 2.0.0b12 (15MAY2060) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal import pyp_nrm if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='new_hartl.ini') pyp_graphics.draw_pedigree(example, gfilename='hartlandclark', gtitle='Pedigree from van Noordwijck and Scharloo (1981)', gorient='p', gname=0, gdirec='', gfontsize=12, garrow=0) example_inbreeding = pyp_nrm.inbreeding(example) print example_inbreeding