Exemplo n.º 1
0
void
NoAssociationSimulator::runSimulation()
{
	if( m_numSamples == 0 )
	{
		m_numSamples = numCombinations( m_order, m_snps.size( ) );
	}

	m_simulatedAuc.resize( m_numSamples, 0.0f );

	std::vector<bool> shuffledPhenotypes( m_phenotypes );
	for(unsigned int sample = 0; sample < m_numSamples; sample++)
	{
		shufflePhenotypes( &shuffledPhenotypes );

		ColumnData<unsigned char> snps;
		for(unsigned int k = 0; k < m_order; k++)
		{
			unsigned int snpIndex = getRandomInteger( m_snps.size( ) - 1 );
			snps.addColumn( m_snps.getColumn( snpIndex ) );
		}

		RocMdrAnalysis mdrAnalyzer( snps, m_phenotypes );
		m_simulatedAuc[ sample ] = mdrAnalyzer.getAuc( );
	}

	sort( m_simulatedAuc.begin( ), m_simulatedAuc.end( ) );
}
Exemplo n.º 2
0
//
// Generates and displays a two-column list of choices for the use
// to choose from. The return value is the string the user has chosen.
//
static  string  getSettingByList( const RaceAnalyzer::StrSet  &data,
                                  const char                  *prompt )
{
  cout  <<  endl;

  //
  // Determine how many rows there will be in the 2-column display
  //
  size_t  numRows  =  ( data.size() / 2 ) + ( data.size() % 2 );

  //
  // Generate the container of row/string data
  //
  ColumnData  columnData  =  buildColumnData(data, numRows);


  //
  // Display the multi-column choice list.
  //
  RaceAnalyzer::StrSet::const_iterator  midIter  =  data.begin();
  advance( midIter, numRows-1 );

  for_each( columnData.begin(), columnData.end(), DisplayChoice(numRows, *midIter) );

  if  (data.size() % 2)
    cout  << endl;


  //
  // Get (and validate) the user's choice
  //
  unsigned  num;

  while(true)
  {
    string  numStr  =  getSetting(prompt);

    if  ( ! numStr.size() )   // blank indicates "all"
      return  numStr;

    num = atoi( numStr.c_str() );

    if  ( num >= 1  &&  num <= data.size() )
      break;

    cout  <<  endl
          <<  "  *** Invalid number. Try Again. ***"
          <<  endl;
  }


  //
  // Return the chosen string from the user's numeric input.
  //
  RaceAnalyzer::StrSet::const_iterator  iter  =  data.begin();

  advance( iter, num-1 );

  return  *iter;
}
Exemplo n.º 3
0
void ColumnDiscretizer::transform(ColumnData<float> &before, ColumnData<unsigned char> *after)
{
    for(unsigned int i = 0; i < before.size( ); i++)
    {
        std::vector<unsigned char> discretizedColumn( before.numberOfRows( ), 0 );
        discretizeColumn( before.getColumn( i ), m_numIntervals, &discretizedColumn );
        after->addColumn( discretizedColumn );
    }
}
Exemplo n.º 4
0
//
// Builds a container made up of rows, each of which has multiple
// columns. This is used for multi-column choice lists.
//
static  ColumnData  buildColumnData( const RaceAnalyzer::StrSet  &data, size_t  numRows )
{
  ColumnData  result;

  transform( data.begin(),
             data.end(),
             inserter(result, result.end()),
             StrToRowPair(numRows) );

  return  result;
}
Exemplo n.º 5
0
Bool_t IsBlacklisted(Int_t index, ColumnData& blacklist)
{
    Double_t val = index;
    return std::binary_search(blacklist.begin(), blacklist.end(), val);
}