예제 #1
0
class MultinomialModelRunner(ModelRunner):
    def run(self, args):
        self.reader = MultinomialCountsReader(args.mcnt_file_name)
        self.writer = JointMultiMixWriter(args.jmm_file_name)
        
        ModelRunner.run(self, args)
               
    def _train(self, args):
        if args.subsample_size > 0:
            counts = self._subsample(args.subsample_size)
        else:
            counts = self.reader.get_counts()
                   
        self.priors_parser.load_from_file(args.priors_file)
        self.priors = self.priors_parser.to_dict()
        
        self._write_priors()
        
        data = MultinomialData(counts)
        
        self.parameters = self.model.train(data, self.priors,
                                            args.max_iters, args.convergence_threshold)

    def _classify_chromosome(self, chr_name):
        counts = self.reader.get_counts(chr_name)
        jcnt_rows = self.reader.get_rows(chr_name)
        
        end = self.reader.get_chr_size(chr_name)

        n = int(1e5)
        start = 0
        stop = min(n, end)
        

        while start < end:
            sub_counts = counts[start:stop]
            sub_rows = jcnt_rows[start:stop]
                              
            data = MultinomialData(sub_counts)            
                
            resp = self.model.classify(data, self.parameters)
        
            self.writer.write_data(chr_name, sub_rows, resp)
            
            start = stop
            stop = min(stop + n, end)
예제 #2
0
 def run(self, args):
     self.reader = MultinomialCountsReader(args.mcnt_file_name)
     self.writer = JointMultiMixWriter(args.jmm_file_name)
     
     ModelRunner.run(self, args)