コード例 #1
0
ファイル: dengue_titers.py プロジェクト: zachcp/augur
    def titer_model(self, **kwargs):
        '''
        estimate a titer tree and substitution model using titers in titer_fname.
        '''
        from base.titer_model import tree_model, substitution_model
        ## TREE MODEL
        self.titer_tree = tree_model(self.tree.tree, titer_fname = self.titer_fname, **kwargs)
        self.titer_tree.prepare(**kwargs) # make training set, find subtree with titer measurements, and make_treegraph
        self.titer_tree.train(**kwargs) # pick longest branch on path between each (test, ref) pair, assign titer drops to this branch
                                 # then calculate a cumulative antigenic evolution score for each node
        # add tree attributes to the list of attributes that are saved in intermediate files
        for n in self.tree.tree.find_clades():
            n.attr['cTiter'] = n.cTiter
            n.attr['dTiter'] = n.dTiter

        # SUBSTITUTION MODEL
        self.titer_subs = substitution_model(self.tree.tree, titer_fname = self.titer_fname,**kwargs)
        self.titer_subs.prepare(**kwargs)
        self.titer_subs.train(**kwargs)

        if kwargs['training_fraction'] != 1.0:
            self.titer_tree.validate() #(plot=True, fname='treeModel_%s.png'%lineage)
            self.titer_subs.validate() #(plot=True, fname='subModel_%s.png'%lineage)
            logfile = open('params_log.tsv', 'a')
            logfile.write('\t'.join(['substitution_model', lineage, '%.3f'%kwargs['lam_pot'], '%.3f'%kwargs['lam_avi'], '%.3f'%kwargs['lam_drop'], '%.3f'%self.titer_subs.abs_error, '%.3f'%self.titer_subs.rms_error, '%.3f'%self.titer_subs.r2])+'\n')
            logfile.write('\t'.join(['tree_model', lineage, '%.3f'%kwargs['lam_pot'], '%.3f'%kwargs['lam_avi'], '%.3f'%kwargs['lam_drop'], '%.3f'%self.titer_tree.abs_error, '%.3f'%self.titer_tree.rms_error, '%.3f'%self.titer_tree.r2])+'\n')
            logfile.close()
コード例 #2
0
ファイル: flu_titers.py プロジェクト: zachcp/augur
def HI_model(self):
    '''
    estimate a tree and substitution model using titers titer_fname.
    '''
    from base.titer_model import tree_model, substitution_model
    ## define the filenames here
    fname = str(self.config["titers"]["fname"].replace("<LINEAGE>",
                                                       self.info["lineage"]))

    ## define the kwargs explicitly
    kwargs = {}
    if "criterium" in self.config["titers"]:
        kwargs["criterium"] = self.config["titers"]["criterium"]

    ## TREE MODEL
    self.HI_tree = tree_model(self.tree.tree, titer_fname=fname, **kwargs)
    self.HI_tree.prepare(**kwargs)
    self.HI_tree.train(**kwargs)
    # add tree attributes to the list of attributes that are saved in intermediate files
    for n in self.tree.tree.find_clades():
        n.attr['cTiter'] = n.cTiter
        n.attr['dTiter'] = n.dTiter
        # print("cumulative: {} delta: {}".format(n.cTiter, n.dTiter))
    self.config["auspice"]["color_options"]["cTiter"] = {
        "menuItem": "antigenic advance",
        "type": "continuous",
        "legendTitle": "Antigenic Advance",
        "key": "cTiter"
    }
コード例 #3
0
ファイル: H3N2.py プロジェクト: TMCjp/nextstrain-augur
    def HI_model(self, titer_fname, **kwargs):
        '''
        estimate a tree and substitution model using titers titer_fname.
        '''
        from base.titer_model import tree_model, substitution_model
        ## TREE MODEL
        self.HI_tree = tree_model(self.tree.tree, titer_fname = titer_fname, **kwargs)
        self.HI_tree.prepare(**kwargs)
        self.HI_tree.train(**kwargs)
        # add tree attributes to the list of attributes that are saved in intermediate files
        self.tree.dump_attr.extend(['cTiter', 'dTiter'])

        # SUBSTITION MODEL
        self.HI_subs = substitution_model(self.tree.tree, titer_fname = titer_fname,**kwargs)
        self.HI_subs.prepare(**kwargs)
        self.HI_subs.train(**kwargs)
コード例 #4
0
ファイル: seasonal_flu.py プロジェクト: ktheyss/augur
    def HI_model(self, **kwargs):
        '''
        estimate a tree and substitution model using titers titer_fname.
        '''
        from base.titer_model import tree_model, substitution_model
        ## TREE MODEL
        self.HI_tree = tree_model(self.tree.tree, titer_fname = self.HI_titer_fname, **kwargs)
        self.HI_tree.prepare(**kwargs)
        self.HI_tree.train(**kwargs)
        # add tree attributes to the list of attributes that are saved in intermediate files
        for n in self.tree.tree.find_clades():
            n.attr['cTiter'] = n.cTiter
            n.attr['dTiter'] = n.dTiter

        # SUBSTITUTION MODEL
        self.HI_subs = substitution_model(self.tree.tree, titer_fname = self.HI_titer_fname,**kwargs)
        self.HI_subs.prepare(**kwargs)
        self.HI_subs.train(**kwargs)