Exemplo n.º 1
0
std::vector<Location> Caller::callPoissonDist( double poissonLambda, int minQScore)
{
	std::vector<Location> newCandidateLocations;
	std::unordered_map<std::string, Location>::iterator iter;
	std::string altBase;
	for( iter = locationTable.begin(); iter != locationTable.end(); ++iter)
	{
		Location newLocation = iter->second;

		// Clear the Sample list of the copy of the location
		newLocation.clearSamples();
		bool keepLocation = false;

		std::vector<Sample> sampleList = ( iter->second).getSamples();
		for( int i = 0; i < sampleList.size(); i++)
		{
			ReadcountEntry readcountEntry = sampleList[i].getReadcountEntry();
			Allele mostFreqVariantAllele = readcountEntry.getMostFreqVariantAllele();

			int mostFreqNonRefCount = mostFreqVariantAllele.getCount();
			double lambda = readcountEntry.getReadDepth() * poissonLambda;

			// call illuminaPoissonFilter
			double pValue = Filter::illuminaPoissonFilter( mostFreqNonRefCount, lambda);
			double qScore = -10 * std::log10( pValue);

			// if at least one Sample passes through the filter, keep the location
			if( qScore > minQScore)
			{
				//mostFreqVariantAllele.setPValue( pValue);
				//mostFreqVariantAllele.setQScore( qScore);

				// Add only the called Samples to the emptied list
				newLocation.addSample( sampleList[i]);
				keepLocation = true;
			}
		}

		std::vector<Sample> newSamples = newLocation.getSamples();
		double highestVAP = -1;
		for( int i = 0; i < newSamples.size(); i++)
		{
			ReadcountEntry readcountEntry = newSamples[i].getReadcountEntry();
			Allele variantAllele = readcountEntry.getMostFreqVariantAllele();

			if( variantAllele.getPercentage() > highestVAP)
			{
				highestVAP = variantAllele.getPercentage();
				altBase = variantAllele.getBase();
			}
		}

		( iter->second).setMutatedBase( altBase);
		if( keepLocation)
		{
			newCandidateLocations.push_back( newLocation);
		}
	}
	return newCandidateLocations;
}
Exemplo n.º 2
0
std::vector<Location> Caller::callAverageFilter( std::vector<Location> unfilteredCalls)
{
	std::vector<Location> newCandidateLocations;
	for( int i = 0; i < unfilteredCalls.size(); i++)
	{
		bool keepLocation = false;

		// Make a copy of the Location for the new list of candidate locations
		Location newLocation = unfilteredCalls[i];

		// Clear the Sample list of the copy of the location
		newLocation.clearSamples();

		std::vector<Sample> sampleList = unfilteredCalls[i].getSamples();
		int numSamples = sampleList.size();
		for( int j = 0; j < numSamples; j++)
		{
			// Get the mean of the current location
			double mean = unfilteredCalls[i].getMeanVAP();

			double currentSamplePercentage = sampleList[j].getReadcountEntry().getMostFreqVariantAllele().getPercentage();

			// If the current Sample's non reference percentage is  5 times or more greater than the new average, pass
			if( currentSamplePercentage >= 3 * mean)
			{
				// If at least one Sample passes through the filter, keep the location
				// Add only the called Samples to the emptied list
				newLocation.addSample( sampleList[j]);
				keepLocation = true;
			}
		}

		if( keepLocation)
		{
			newCandidateLocations.push_back( newLocation);
		}
	}
	return newCandidateLocations;
}
Exemplo n.º 3
0
std::vector<Location> Caller::callStrandBiasFilter( std::vector<Location> unfilteredCalls, double strandBiasLeft, double strandBiasRight)
{
	std::vector<Location> newCandidateLocations;
	for( int i = 0; i < unfilteredCalls.size(); i++)
	{
		bool keepLocation = false;

		// Make a copy of the Location for the new list of candidate locations
		Location newLocation = unfilteredCalls[i];

		// Clear the Sample list of the copy of the location
		newLocation.clearSamples();

		std::vector<Sample> sampleList = unfilteredCalls[i].getSamples();
		int numSamples = sampleList.size();
		for( int j = 0; j < numSamples; j++)
		{
			// Calculate the strand-bias
			int numReadsForward = sampleList[j].getReadcountEntry().getMostFreqVariantAllele().getNumPlusStrand();
			int numReadsReverse = sampleList[j].getReadcountEntry().getMostFreqVariantAllele().getNumMinusStrand();
			double strandBias = ( double) numReadsForward / ( double) ( numReadsForward + numReadsReverse);

			if( strandBias >= strandBiasLeft && strandBias <= strandBiasRight)
			{
				// If at least one Sample passes through the filter, keep the location
				// Add only the called Samples to the emptied list
				newLocation.addSample( sampleList[j]);
				keepLocation = true;
			}
		}

		if( keepLocation)
		{
			newCandidateLocations.push_back( newLocation);
		}
	}
	return newCandidateLocations;
}
Exemplo n.º 4
0
std::vector<Location> Caller::callAmpliconEndFilter( std::vector<Location> unfilteredCalls, double readEndFraction)
{
	std::vector<Location> newCandidateLocations;
	for( int i = 0; i < unfilteredCalls.size(); i++)
	{
		bool keepLocation = false;

		// Make a copy of the Location for the new list of candidate locations
		Location newLocation = unfilteredCalls[i];

		// Clear the Sample list of the copy of the location
		newLocation.clearSamples();

		std::vector<Sample> sampleList = unfilteredCalls[i].getSamples();
		int numSamples = sampleList.size();
		for( int j = 0; j < numSamples; j++)
		{
			// Get average position on the reads as a fraction
			double avgPosAsFraction = sampleList[j].getReadcountEntry().getMostFreqVariantAllele().getAvgPosAsFraction();

			if( avgPosAsFraction >= readEndFraction)
			{
				// If at least one Sample passes through the filter, keep the location
				// Add only the called Samples to the emptied list
				newLocation.addSample( sampleList[j]);
				keepLocation = true;
			}
		}

		if( keepLocation)
		{
			newCandidateLocations.push_back( newLocation);
		}
	}
	return newCandidateLocations;
}
Exemplo n.º 5
0
std::vector<Location> Caller::callDepthFilter( std::vector<Location> unfilteredCalls, int minDepth)
{
	std::vector<Location> newCandidateLocations;
	for( int i = 0; i < unfilteredCalls.size(); i++)
	{
		bool keepLocation = false;

		// Make a copy of the Location for the new list of candidate locations
		Location newLocation = unfilteredCalls[i];

		// Clear the Sample list of the copy of the location
		newLocation.clearSamples();

		std::vector<Sample> sampleList = unfilteredCalls[i].getSamples();
		int numSamples = sampleList.size();
		for( int j = 0; j < numSamples; j++)
		{
			// Get the read depth
			int readDepth = sampleList[j].getReadcountEntry().getReadDepth();

			if( readDepth >=  minDepth)
			{
				// If at least one Sample passes through the filter, keep the location
				// Add only the called Samples to the emptied list
				newLocation.addSample( sampleList[j]);
				keepLocation = true;
			}
		}

		if( keepLocation)
		{
			newCandidateLocations.push_back( newLocation);
		}
	}
	return newCandidateLocations;
}