Esempio n. 1
0
    def run_experiment(self, params, experiment, plink_path, power_file, with_cov):
        postfix = "with_cov"
        if not with_cov:
            postfix = "without_cov"

        for model_id, model in enumerate( experiment[ 'models' ] ): 
            covariates = model[ 'covariates' ]
            if not with_cov:
                covariates = None


            params = updated_params( params, model )
            self.method_handler.start_experiment( experiment[ 'name' ], model_id, postfix )
            for i in range( params.num_pairs ):
                plinkdata.generate_sufficient_cov_data( params,
                                             model[ 'params' ],
                                             covariates,
                                             plink_path )

                program.run_methods( params, plink_path, self.method_handler, with_cov )
            
            xvalue = model.get( 'xvalue', None )
            if not xvalue:
                xvalue = model_id

            self.method_handler.reset_files( )
            method_power = program.calculate_power( params, self.method_handler )
            for method_name, power_data in method_power.iteritems( ):
                power, lower, upper = power_data
                line = "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\n".format( method_name, xvalue, power, lower, upper, int( with_cov ) )
                power_file.write( line )
Esempio n. 2
0
    def calculate_power(self, params, experiment, plink_path, power_file):
        ld = experiment.get( "ld", 0.0 )
        for model_id, model in enumerate( experiment[ 'models' ] ):
            params = updated_params( params, model )

            plinkdata.generate_data( params,
                                     model[ 'params' ],
                                     ld, plink_path )

            self.method_handler.start_experiment( experiment[ 'name' ], model_id )
            program.run_methods( params, plink_path, self.method_handler )
            self.method_handler.reset_files( )

            xvalue = model.get( 'xvalue', None )
            if not xvalue:
                xvalue = model_id

            method_power = program.calculate_power( params, self.method_handler )
            for method_name, power_data in method_power.iteritems( ):
                power, lower, upper = power_data
                line = "{0}\t{1}\t{2}\t{3}\t{4}\n".format( method_name, xvalue, power, lower, upper )
                power_file.write( line )