private static RecalibrationResult GetModelFromType(CalledAllele allele, RecalibrationResults results) { var variantType = VariantReader.GetVariantType(allele); RecalibrationResult resultForVariant; if (variantType == VariantType.NoVariant || variantType == VariantType.Snv) { resultForVariant = results.SnvResults; } else if (variantType == VariantType.Indel) { resultForVariant = results.IndelResults; } else { throw new ArgumentException("Variant type unrecognized."); } return(resultForVariant); }
public void Recalibrate() { // Read in VCF Logger.WriteToLog("Reading in vcf for variant frequencies."); List <RecalibratedVariantsCollection> variants = VariantReader.GetVariantFrequencies(_options.VcfPath); // Fit new models or load models from file List <MixtureModel> models; if (_options.ModelFile == null) { models = GetNewModels(_options.VcfPath, _options.OutputDirectory, variants); } else { models = ApplyModels(_options.VcfPath, _options.ModelFile, variants); } RecalibrationResults recalibrationResults = SummarizeModels(models, variants); AdaptiveGtWriter.RewriteVcf(_options.VcfPath, _options.OutputDirectory, _options, recalibrationResults); }
public void AddLocus(CalledAllele variant) { ReferenceName.Add(variant.Chromosome); ReferencePosition.Add(variant.ReferencePosition); ChrIndexer.Add(variant.Chromosome + ":" + variant.ReferencePosition.ToString(), Count); NumIndexer.Add(Count, variant.Chromosome + ":" + variant.ReferencePosition.ToString()); int dp = variant.TotalCoverage; if (dp < AdaptiveGenotyperCalculator.MaxEffectiveDepth) { Dp.Add(dp); Ad.Add(VariantReader.GetAlternateAlleleSupport(variant)); } else { var(ad, depth) = AdaptiveGenotyperCalculator.DownsampleVariant( VariantReader.GetAlternateAlleleSupport(variant), dp); Dp.Add(depth); Ad.Add(ad); } Count++; }
private static CalledAllele UpdateGenotype(CalledAllele allele, SimplifiedDiploidGenotype category) { if (category == SimplifiedDiploidGenotype.HomozygousRef) { allele.Genotype = Genotype.HomozygousRef; } else if (category == SimplifiedDiploidGenotype.HeterozygousAltRef) { if (allele.IsRefType) { allele.Genotype = Genotype.HomozygousRef; } else if (VariantReader.GetVariantType(allele) == VariantType.Snv) { allele.Genotype = Genotype.HeterozygousAltRef; } else if (VariantReader.GetVariantType(allele) == VariantType.Indel) { allele.Genotype = Genotype.HeterozygousAltRef; } } else if (category == SimplifiedDiploidGenotype.HomozygousAlt) { if (allele.IsRefType) { allele.Genotype = Genotype.HomozygousRef; } else if (VariantReader.GetVariantType(allele) == VariantType.Snv) { allele.Genotype = Genotype.HomozygousAlt; } else if (VariantReader.GetVariantType(allele) == VariantType.Indel) { allele.Genotype = Genotype.HomozygousAlt; } } return(allele); }