private static Genotype CalculateDiploidGenotype(IEnumerable <CalledAllele> alleles, int minDepthToGenotype, DiploidThresholdingParameters snvThresholdingParameters, DiploidThresholdingParameters indelThresholdingParameters, out List <CalledAllele> allelesToPrune) { allelesToPrune = new List <CalledAllele>(); var orderedVariants = GenotypeCalculatorUtilities.FilterAndOrderAllelesByFrequency(alleles, allelesToPrune, snvThresholdingParameters.MinorVF); var referenceFrequency = GenotypeCalculatorUtilities.GetReferenceFrequency(alleles, snvThresholdingParameters.MinorVF); var refExists = (referenceFrequency >= snvThresholdingParameters.MinorVF); var depthIssue = GenotypeCalculatorUtilities.CheckForDepthIssue(alleles, minDepthToGenotype); var parameters = snvThresholdingParameters; bool refCall = orderedVariants.Count == 0 || (orderedVariants[0].Frequency < snvThresholdingParameters.MinorVF); //do we apply SNP threshholds or indel thresholds? parameters = SelectParameters(indelThresholdingParameters, orderedVariants, parameters, refCall); var preliminaryGenotype = GetPreliminaryGenotype(orderedVariants, parameters, refCall); var finalGTForLoci = GenotypeCalculatorUtilities.ConvertSimpleGenotypeToComplexGenotype(alleles, orderedVariants, referenceFrequency, refExists, depthIssue, refCall, parameters.MinorVF, parameters.SumVFforMultiAllelicSite, preliminaryGenotype); allelesToPrune = GenotypeCalculatorUtilities.GetAllelesToPruneBasedOnGTCall(finalGTForLoci, orderedVariants, allelesToPrune); return(finalGTForLoci); }
public void ChrYMaleTests() { var diploidPars = new DiploidThresholdingParameters(new float[] { 0.2f, 0.7f, 0.8f }); var genotypeCaculator = GenotypeCreator.CreateGenotypeCalculator(PloidyModel.Diploid, 0.05f, 30, diploidPars, diploidPars, 0, 100, 0.05f, 0.02f, "chrY", true); Assert.True(genotypeCaculator is HaploidGenotyeCalculator); }
public static IGenotypeCalculator CreateGenotypeCalculator(PloidyModel ploidyModel, float minimumFrequencyFilter, int minEmitDepth, DiploidThresholdingParameters snvParameters, DiploidThresholdingParameters indelParameters, AdaptiveGenotypingParameters adaptiveGenotypingParameters, int minGQscore, int maxGQscore, float targetLODVariantFrequency, float minimumEmitFrequency = 0, string refName = null, bool?isMale = null) { var ploidyModelForThisChr = GetPloidyForThisChr(ploidyModel, isMale, refName); switch (ploidyModelForThisChr) { case PloidyModel.Haploid: return(new HaploidGenotyper(minEmitDepth, minGQscore, maxGQscore, snvParameters.MinorVF, snvParameters.MajorVF)); case PloidyModel.DiploidByAdaptiveGT: return(new DiploidAdaptiveGenotyper(minEmitDepth, minGQscore, maxGQscore, adaptiveGenotypingParameters)); case PloidyModel.DiploidByThresholding: return(new DiploidThresholdingGenotyper(snvParameters, snvParameters, minEmitDepth, minGQscore, maxGQscore)); case PloidyModel.Somatic: default: return(new SomaticGenotyper(minimumFrequencyFilter, minEmitDepth, minGQscore, maxGQscore, minimumEmitFrequency, targetLODVariantFrequency)); } }
public void ChrYUnknownGenderTests_thresholding() { var diploidPars = new DiploidThresholdingParameters(new float[] { 0.2f, 0.7f, 0.8f }); var genotypeCaculator = GenotypeCreator.CreateGenotypeCalculator(PloidyModel.DiploidByThresholding, 0.05f, 30, diploidPars, diploidPars, null, 0, 100, 0.05f, 0.02f, "chrY"); Assert.True(genotypeCaculator is DiploidThresholdingGenotyper); Assert.Equal(PloidyModel.DiploidByThresholding, GenotypeCreator.GetPloidyForThisChr(PloidyModel.DiploidByThresholding, null, "chrY")); }
public DiploidThresholdingGenotyper(DiploidThresholdingParameters snvParameters, DiploidThresholdingParameters indelParameters, int minCalledVariantDepth, int minGQscore, int maxGQscore) { _diploidSnvThresholdingParameters = snvParameters; _diploidIndelThresholdingParameters = indelParameters; MinGQScore = minGQscore; MaxGQScore = maxGQscore; MinDepthToGenotype = minCalledVariantDepth; MinVarFrequency = _diploidSnvThresholdingParameters.MinorVF; }
public void ChrMMaleTests_adaptive() { var adaptiveGTparams = new AdaptiveGenotypingParameters(); var diploidPars = new DiploidThresholdingParameters(new float[] { 0.2f, 0.7f, 0.8f }); var genotypeCaculator = GenotypeCreator.CreateGenotypeCalculator(PloidyModel.DiploidByAdaptiveGT, 0.05f, 30, diploidPars, diploidPars, adaptiveGTparams, 0, 100, 0.05f, 0.02f, "chrM", true); Assert.True(genotypeCaculator is SomaticGenotyper); Assert.Equal(PloidyModel.Somatic, GenotypeCreator.GetPloidyForThisChr(PloidyModel.DiploidByAdaptiveGT, true, "chrM")); }
public DiploidThresholdingGenotyper() { var defaultParams = new VariantCallingParameters(); _diploidSnvThresholdingParameters = defaultParams.DiploidSNVThresholdingParameters; _diploidIndelThresholdingParameters = defaultParams.DiploidINDELThresholdingParameters; MinGQScore = defaultParams.MinimumGenotypeQScore; MaxGQScore = defaultParams.MaximumGenotypeQScore; MinDepthToGenotype = defaultParams.MinimumCoverage; MinVarFrequency = _diploidSnvThresholdingParameters.MinorVF; }
private static DiploidThresholdingParameters ConvertToDiploidThresholding(string value) { var parameters = OptionHelpers.ParseStringToFloat(value.Split(OptionHelpers.Delimiter)); if (parameters.Length != 3) { throw new ArgumentException(string.Format("DiploidGenotypeParameters argument requires exactly three values.")); } var diploidThresholdingParameters = new DiploidThresholdingParameters(parameters); return(diploidThresholdingParameters); }
public void ChrXMaleGenotypeCalculatorTests() { var diploidPars = new DiploidThresholdingParameters(new float[] { 0.2f, 0.7f, 0.8f }); var genotypeCaculator = GenotypeCreator.CreateGenotypeCalculator(PloidyModel.DiploidByThresholding, 0.05f, 30, diploidPars, diploidPars, null, 0, 100, 0.05f, 0.02f, "chrX", true); Assert.True(genotypeCaculator is HaploidGenotyper); Assert.Equal(0.2f, genotypeCaculator.MinVarFrequency); genotypeCaculator.SetMinFreqFilter(0.05f); Assert.Equal(0.2f, genotypeCaculator.MinVarFrequencyFilter); genotypeCaculator.SetMinFreqFilter(0.3f); Assert.Equal(0.3f, genotypeCaculator.MinVarFrequencyFilter); }
public static DiploidThresholdingParameters SelectParameters(DiploidThresholdingParameters indelThresholdingParameters, List <CalledAllele> orderedVariants, DiploidThresholdingParameters snpThresholdingParameters, bool refCall) { if (refCall) { return(snpThresholdingParameters); } else { var dominantVariant = orderedVariants.First(); if (dominantVariant.Type != AlleleCategory.Snv) { return(indelThresholdingParameters); } else { return(snpThresholdingParameters); } } }
public ApplicationOptions UpdateOptions(string[] arguments) { string lastArgumentField = string.Empty; try { int argumentIndex = 0; while (argumentIndex < arguments.Length) { if (string.IsNullOrEmpty(arguments[argumentIndex])) { argumentIndex++; continue; } string value = null; if (argumentIndex < arguments.Length - 1) { value = arguments[argumentIndex + 1].Trim(); } lastArgumentField = arguments[argumentIndex].ToLower(); switch (lastArgumentField) { case "-v": case "-ver": PrintVersionToConsole(); return(null); //case "-a": depracated case "-minvq": case "-minvariantqscore": MinimumVariantQScore = int.Parse(value); break; //case "-b": depracated case "-minbq": case "-minbasecallquality": MinimumBaseCallQuality = int.Parse(value); break; case "-b": case "-bam": BAMPaths = value.Split(_delimiter); break; case "-c": case "-mindp": case "-mindepth": case "-mincoverage": //last release this is available. trying to be nice for backwards compatibility with Isas. MinimumDepth = int.Parse(value); break; case "-d": case "-debug": DebugMode = bool.Parse(value); break; case "-minvf": //used to be "f" case "-minimumvariantfrequency": case "-minimumfrequency": MinimumFrequency = float.Parse(value); break; case "-vqfilter": //used to be "F" case "-variantqualityfilter": FilteredVariantQScore = int.Parse(value); break; case "-vffilter": //used to be "v" case "-minvariantfrequencyfilter": FilteredVariantFrequency = float.Parse(value); break; case "-gqfilter": case "-genotypequalityfilter": LowGenotypeQualityFilter = int.Parse(value); break; case "-repeatfilter": IndelRepeatFilter = int.Parse(value); break; case "-mindpfilter": case "-mindepthfilter": LowDepthFilter = int.Parse(value); break; case "-ssfilter": //used to be "fo" case "-enablesinglestrandfilter": FilterOutVariantsPresentOnlyOneStrand = bool.Parse(value); break; case "-g": case "-genomepaths": GenomePaths = value.Split(_delimiter); break; case "-nl": case "-noiselevelforqmodel": AppliedNoiseLevel = int.Parse(value); break; case "-gvcf": OutputgVCFFiles = bool.Parse(value); break; case "-callmnvs": //case "-phasesnps": obsolete CallMNVs = bool.Parse(value); break; case "-maxmnvlength": //case "-MaxPhaseSNPLength": obsolete //case "-MaxPhasedSNPLength": obsolete MaxSizeMNV = int.Parse(value); break; case "-maxgapbetweenmnv": case "-maxrefgapinmnv": //case "-MaxGapPhasedSNP":: obsolete MaxGapBetweenMNV = int.Parse(value); break; case "-i": case "-intervalpaths": IntervalPaths = value.Split(_delimiter); break; case "-minmq": //used to be "m" case "-minmapquality": MinimumMapQuality = int.Parse(value); break; case "-ploidy": if (value.ToLower().Contains("somatic")) { PloidyModel = PloidyModel.Somatic; } else if (value.ToLower().Contains("diploid")) { PloidyModel = PloidyModel.Diploid; } else { throw new ArgumentException(string.Format("Unknown ploidy model '{0}'", value)); } break; case "-diploidgenotypeparameters": var parameters = ParseStringToFloat(value.Split(_delimiter)); if (parameters.Length != 3) { throw new ArgumentException(string.Format("DiploidGenotypeParamteers argument requires exactly three values.")); } DiploidThresholdingParameters = new DiploidThresholdingParameters(parameters); break; case "-crushvcf": bool crushedallelestyle = bool.Parse(value); AllowMultipleVcfLinesPerLoci = !(crushedallelestyle); break; case "-sbmodel": if (value.ToLower().Contains("poisson")) { StrandBiasModel = StrandBiasModel.Poisson; } else if (value.ToLower().Contains("extended")) { StrandBiasModel = StrandBiasModel.Extended; } else { throw new ArgumentException(string.Format("Unknown strand bias model '{0}'", value)); } break; case "-outputsbfiles": OutputBiasFiles = bool.Parse(value); break; case "-pp": case "-onlyuseproperpairs": OnlyUseProperPairs = bool.Parse(value); break; case "-maxvq": case "-maxvariantqscore": MaximumVariantQScore = int.Parse(value); break; case "-maxgq": case "-maxgenotypeqscore": MaximumGenotypeQScore = int.Parse(value); break; case "-mingq": case "-minqenotypeqscore": MinimumGenotypeQScore = int.Parse(value); break; case "-sbfilter": case "-maxacceptablestrandbiasfilter": StrandBiasAcceptanceCriteria = float.Parse(value); break; case "-stitchpairedreads": throw new ArgumentException("StitchPairedReads option is obsolete."); case "-t": MaxNumThreads = int.Parse(value); break; case "-threadbychr": ThreadByChr = bool.Parse(value); break; case "-reportnocalls": ReportNoCalls = bool.Parse(value); break; case "-xcstitcher": throw new ArgumentException("XCStitcher option is obsolete."); case "-collapse": Collapse = bool.Parse(value); break; case "-collapsefreqthreshold": CollapseFreqThreshold = float.Parse(value); break; case "-collapsefreqratiothreshold": CollapseFreqRatioThreshold = float.Parse(value); break; case "-priorspath": PriorsPath = value; break; case "-trimmnvpriors": TrimMnvPriors = bool.Parse(value); break; case "-nifydisagreements": throw new ArgumentException("NifyDisagreements option is no longer valid: stitching within Pisces is obsolete."); case "-coverageMethod": if (value.ToLower() == "approximate") { CoverageMethod = CoverageMethod.Approximate; } else if (value.ToLower() == "exact") { CoverageMethod = CoverageMethod.Exact; } else { throw new ArgumentException(string.Format("Unknown coverage method '{0}'", value)); } break; case "-reportrccounts": ReportRcCounts = bool.Parse(value); break; case "-mono": MonoPath = value; break; case "-rmxnfilter": bool turnOn = true; bool worked = (bool.TryParse(value, out turnOn)); if (worked) { if (turnOn) { // stick with defaults } else { //turn off RMxNFilterMaxLengthRepeat = null; RMxNFilterMinRepetitions = null; } break; } //else, it wasnt a bool... var rmxnThresholds = ParseStringToFloat(value.Split(_delimiter)); if ((rmxnThresholds.Length < 2) || (rmxnThresholds.Length > 3)) { throw new ArgumentException(string.Format("RMxNFilter argument requires two or three values.")); } RMxNFilterMaxLengthRepeat = (int)rmxnThresholds[0]; RMxNFilterMinRepetitions = (int)rmxnThresholds[1]; if (rmxnThresholds.Length > 2) { RMxNFilterFrequencyLimit = (float)rmxnThresholds[2]; } break; case "-noisemodel": NoiseModel = value.ToLower() == "window" ? NoiseModel.Window : NoiseModel.Flat; break; case "-skipnonintervalalignments": throw new Exception(string.Format("'SkipNonIntervalAlignments' option has been depracated until further notice. ", arguments[argumentIndex])); //(it has bugs, speed issues, and no plan to fix it) default: if (!base.UpdateOptions(lastArgumentField, value)) { throw new Exception(string.Format("Unknown argument '{0}'", arguments[argumentIndex])); } break; } argumentIndex += 2; } CommandLineArguments = arguments; return(this); } catch (Exception ex) { throw new Exception(string.Format("Unable to parse argument {0}: {1}", lastArgumentField, ex.Message)); } }
private static SimplifiedDiploidGenotype GetPreliminaryGenotype(List <CalledAllele> orderedVariants, DiploidThresholdingParameters parameters, bool refCall) { //obvious reference call if (refCall) { return(SimplifiedDiploidGenotype.HomozygousRef); }//else, types of alt calls... else if ((orderedVariants[0].Frequency >= parameters.MinorVF) && (orderedVariants[0].Frequency <= parameters.MajorVF)) { return(SimplifiedDiploidGenotype.HeterozygousAltRef); } else if (orderedVariants[0].Frequency > parameters.MajorVF) { return(SimplifiedDiploidGenotype.HomozygousAlt); } else { return(SimplifiedDiploidGenotype.HomozygousRef); } }