static void Main(string[] args) { if (args.Length < 4) { Console.WriteLine("EvaluateCNV {0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); Console.WriteLine("For more info see: http://confluence.illumina.com/display/BIOINFO/EvaluateCNV"); Console.WriteLine(); Console.WriteLine("Usage info:"); Console.WriteLine("EvaluateCNV $TruthSetPath $CNV.vcf $ExcludedRegionsBed $OutputPath [$RegionOfInterestBed]"); return; } CNVChecker checker = new CNVChecker(); string ROIBed = null; double heterogeneityFraction = 1; if (args.Length > 4) { ROIBed = args[4]; } if (args.Length > 5) { heterogeneityFraction = double.Parse(args[5]); } checker.Evaluate(args[0], args[1], args[2], args[3], ROIBed, heterogeneityFraction); }
private static int MainHelper(string[] args) { EvaluateCnvOptionsParser optionsParser = new EvaluateCnvOptionsParser(); if (args.Length < 4) { ShowHelp(optionsParser, Console.Error); return(1); } var parsingResult = optionsParser.Parse(args.Skip(4)); if (!parsingResult.Success) { Console.Error.WriteLine(parsingResult.ErrorMessage); ShowHelp(optionsParser, Console.Error); return(1); } var options = parsingResult.Result; if (options.Help) { ShowHelp(optionsParser, Console.Out); return(0); } CNVChecker.Evaluate(args[0], args[1], args[2], args[3], options); return(0); }
static void Main(string[] args) { if (args.Length < 4) { Console.WriteLine("EvaluateCNV {0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); Console.WriteLine("For more info see: http://confluence.illumina.com/display/BIOINFO/EvaluateCNV"); Console.WriteLine(); Console.WriteLine("Usage info:"); Console.WriteLine("EvaluateCNV $TruthSetPath $CNV.vcf $ExcludedRegionsBed $OutputPath [$RegionOfInterestBed]"); return; } CNVChecker checker = new CNVChecker(); string ROIBed = null; if (args.Length > 4) ROIBed = args[4]; checker.Evaluate(args[0], args[1], args[2], args[3], ROIBed); }
private const int MaxCn = 5; // Currently the max copynum is 5 #endregion public CnvEvaluator(CNVChecker cnvChecker) { _cnvChecker = cnvChecker; }
public static void Evaluate(string truthSetPath, string cnvCallsPath, string excludedBed, string outputPath, EvaluateCnvOptions options) { double heterogeneityFraction = options.HeterogeneityFraction; var knownCn = LoadKnownCn(truthSetPath, heterogeneityFraction); knownCn = knownCn.SelectValues( truthEntries => truthEntries.Where(truthEntry => truthEntry.Length >= options.MinEntrySize).ToList()); var calls = GetCnvCallsFromVcf(cnvCallsPath, options.DQscoreThreshold); calls = calls.SelectValues( chromosomeCalls => chromosomeCalls.Where(call => call.Length >= options.MinEntrySize).ToList()); // LoadRegionsOfInterest(options.RoiBed?.FullName); var excludeIntervals = new Dictionary <string, List <CNInterval> >(); if (!string.IsNullOrEmpty(excludedBed)) { var excludeIntervalsTmp = LoadIntervalsFromBed(excludedBed, false, 1.0); List <string> keys = excludeIntervalsTmp.Keys.ToList(); foreach (string key in keys) { string chr = key; if (!calls.ContainsKey(chr)) { chr = key.Replace("chr", ""); } if (!calls.ContainsKey(chr)) { chr = "chr" + key; } if (!calls.ContainsKey(chr)) { Console.WriteLine($"Error: Skipping exclude intervals for chromosome {key} with no truth data." + $"Check that chromosome names are spelled correctly for exclude intervals"); continue; } excludeIntervals[chr] = excludeIntervalsTmp[key]; } } Console.WriteLine("TruthSet\t{0}", truthSetPath); Console.WriteLine("CNVCalls\t{0}", cnvCallsPath); bool includePassingOnly = Path.GetFileName(cnvCallsPath).ToLower().Contains("vcf"); var logger = new Logger(new[] { Console.Out }, new[] { Console.Error }); var settings = IsasConfigurationSettings.GetConfigSettings(); var output = new DirectoryLocation(outputPath); var workerDirectory = new DirectoryLocation(Isas.Framework.Utilities.Utilities.GetAssemblyFolder(typeof(CNVChecker))); var commandManager = new CommandManager(new ExecutableProcessor(settings, logger, workerDirectory)); WorkDoerFactory.RunWithWorkDoer(logger, settings, output, workDoer => { var tabixWrapper = TabixWrapperFactory.GetTabixWrapper(logger, workDoer, commandManager); var ploidyCorrector = new PloidyCorrector(logger, workDoer, new PloidyEstimator(logger, workDoer, null, false, commandManager), tabixWrapper, false); var checker = new CNVChecker(options.DQscoreThreshold, excludeIntervals, ploidyCorrector); if (options.PloidyInfo.SexPloidyInfo != null) { Console.WriteLine($">>>Getting reference ploidy from provided ploidy information and PAR bed file '{options.PloidyInfo.ParBed}'"); var ploidy = checker.GetPloidy(options.PloidyInfo, output); var referencePloidy = LoadReferencePloidy(options.PloidyInfo.SexPloidyInfo, options.PloidyInfo.ParBed); knownCn = GetKnownCopyNumberWithReferencePloidy(referencePloidy, knownCn); calls = GetCallsWithRefPloidy(calls, ploidy); } var cnvEvaluator = new CnvEvaluator(checker); if (checker.DQscoreThreshold.HasValue && !Path.GetFileName(cnvCallsPath).ToLower().Contains("vcf")) { throw new ArgumentException("CNV.vcf must be in a vcf format when --dqscore option is used"); } cnvEvaluator.ComputeAccuracy(knownCn, cnvCallsPath, outputPath, includePassingOnly, options, calls); if (includePassingOnly) { cnvEvaluator.ComputeAccuracy(knownCn, cnvCallsPath, outputPath, false, options, calls); } ComputeCallability(logger, calls, options, output); Console.WriteLine(">>>Done - results written to {0}", outputPath); }); }