Beispiel #1
0
        public int Run(CanvasNormalizeParameters parameters)
        {
            _referenceGenerator.Run(parameters.weightedAverageNormalBedFile);
            var ratios = _ratioCalculator.Run(parameters.tumorBedFile, parameters.weightedAverageNormalBedFile);

            CanvasNormalizeUtilities.RatiosToCounts(ratios, parameters.ploidyBedFile, parameters.outBedFile);
            CanvasNormalizeUtilities.WriteCndFile(parameters.tumorBedFile, parameters.weightedAverageNormalBedFile,
                                                  ratios, new FileLocation(parameters.outBedFile.FullName + CndFileSuffix));

            return(0);
        }
Beispiel #2
0
        static int Main(string[] args)
        {
            CanvasCommon.Utilities.LogCommandLine(args);
            CanvasNormalizeParameters parameters = CanvasNormalizeParameters.ParseCommandLine(args);

            if (parameters == null)
            {
                return(1);
            }
            return(CanvasNormalize.Run(parameters));
        }
Beispiel #3
0
        static int Main(string[] args)
        {
            CanvasCommon.Utilities.LogCommandLine(args);
            CanvasNormalizeParameters parameters = CanvasNormalizeParameters.ParseCommandLine(args);

            if (parameters == null)
            {
                return(1);
            }

            CanvasNormalizeFactory factory = new CanvasNormalizeFactory(parameters);

            return(new CanvasNormalize(factory.GetReferenceGenerator(), factory.GetRatioCalculator())
                   .Run(parameters));
        }
Beispiel #4
0
        public static int Run(CanvasNormalizeParameters parameters) 
        {
            NexteraManifest manifest = string.IsNullOrEmpty(parameters.manifestPath) ? null : new NexteraManifest(parameters.manifestPath, null, Console.WriteLine);

            switch (parameters.normalizationMode)
            {
                case CanvasNormalizeMode.BestLR2:
                    GetBestLR2BinCount(parameters.tumorBedPath, parameters.normalBedPaths, parameters.weightedAverageNormalBedPath,
                        manifest: manifest);
                    break;
                case CanvasNormalizeMode.WeightedAverage:
                    GetWeightedAverageBinCount(parameters.normalBedPaths, parameters.weightedAverageNormalBedPath, manifest: manifest);
                    break;
                default:
                    throw new Exception(string.Format("Invalid CanvasNormalize mode '{0}'", parameters.normalizationMode));
            }
            
            GetBinRatio(parameters.tumorBedPath, parameters.weightedAverageNormalBedPath, parameters.outBedPath, parameters.ploidyBedPath);

            return 0;
        }
Beispiel #5
0
        public static int Run(CanvasNormalizeParameters parameters)
        {
            NexteraManifest manifest = string.IsNullOrEmpty(parameters.manifestPath) ? null : new NexteraManifest(parameters.manifestPath, null, Console.WriteLine);

            switch (parameters.normalizationMode)
            {
            case CanvasNormalizeMode.BestLR2:
                GetBestLR2BinCount(parameters.tumorBedPath, parameters.normalBedPaths, parameters.weightedAverageNormalBedPath,
                                   manifest: manifest);
                break;

            case CanvasNormalizeMode.WeightedAverage:
                GetWeightedAverageBinCount(parameters.normalBedPaths, parameters.weightedAverageNormalBedPath, manifest: manifest);
                break;

            default:
                throw new Exception(string.Format("Invalid CanvasNormalize mode '{0}'", parameters.normalizationMode));
            }

            GetBinRatio(parameters.tumorBedPath, parameters.weightedAverageNormalBedPath, parameters.outBedPath,
                        parameters.ploidyBedPath, manifest: manifest);

            return(0);
        }
Beispiel #6
0
        public static CanvasNormalizeParameters ParseCommandLine(string[] args)
        {
            CanvasNormalizeParameters parameters = new CanvasNormalizeParameters();

            parameters.normalizationMode = CanvasCommon.CanvasNormalizeMode.WeightedAverage;
            // Should I display a help message?
            bool needHelp = false;

            OptionSet p = new OptionSet()
            {
                { "t|tumor=", "bed file containing bin counts for the tumor sample", v => parameters.tumorBedFile = new FileLocation(v) },
                { "n|normal=", "bed file containing bin counts for a normal sample. Pass this option multiple times, once for each normal sample.\nIn PCA mode, model file containing the mean vector and the axes for projection. Pass this option only once.", v => parameters.normalBedFiles.Add(new FileLocation(v)) },
                { "o|out=", "bed file to output containing normalized bin counts", v => parameters.outBedFile = new FileLocation(v) },
                { "w|weightedAverageNormal=", "bed file to output containing reference bin counts", v => parameters.weightedAverageNormalBedFile = new FileLocation(v) },
                { "f|manifest=", "Nextera manifest file", v => parameters.manifestFile = new FileLocation(v) },
                { "p|ploidyBedFile=", "bed file specifying reference ploidy (e.g. for sex chromosomes) (optional)", v => parameters.ploidyBedFile = new FileLocation(v) },
                { "r|referenceBinCountRange=", "reference bin count range for the PCA mode. Default: (1, infinity). Pass this option twice to specify the min and the max (optional)", v => parameters.referenceBinCountRange.Add(double.Parse(v)) },
                { "h|help", "show this message and exit", v => needHelp = v != null },
                { "m|mode=", "normalization mode (WeightedAverage/BestLR2/PCA). Default: " + parameters.normalizationMode, v => parameters.normalizationMode = CanvasCommon.Utilities.ParseCanvasNormalizeMode(v) },
            };

            Console.WriteLine("CanvasNormalize {0}", System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());

            List <string> extraArgs = p.Parse(args);

            // Check for required arguments. Display the help message if any of them are missing.
            if (parameters.tumorBedFile == null)
            {
                Console.Error.WriteLine("Please specify the tumor bed file.");
                needHelp = true;
            }
            else if (!parameters.normalBedFiles.Any())
            {
                if (parameters.normalizationMode == CanvasNormalizeMode.PCA)
                {
                    Console.Error.WriteLine("Please specify a model file.");
                }
                else
                {
                    Console.Error.WriteLine("Please specify at least one normal bed file.");
                }
                needHelp = true;
            }
            else if (parameters.outBedFile == null)
            {
                Console.Error.WriteLine("Please specify an output file name.");
                needHelp = true;
            }

            if (!parameters.referenceBinCountRange.Any()) // default to 1 and infinity
            {
                parameters.referenceBinCountRange = new List <double>()
                {
                    1, double.PositiveInfinity
                };
            }
            else if (parameters.referenceBinCountRange.Count != 2)
            {
                Console.Error.WriteLine("Please specify -r exactly twice.");
                needHelp = true;
            }

            if (needHelp)
            {
                ShowHelp(p);
                return(null);
            }

            // Does the tumor bed file exist?
            if (!parameters.tumorBedFile.Exists)
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.tumorBedFile);
                return(null);
            }

            // Does each of the normal bed files exist?
            foreach (var normalBedFile in parameters.normalBedFiles)
            {
                if (!normalBedFile.Exists)
                {
                    Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", normalBedFile.FullName);
                    return(null);
                }
            }

            // Does the manifest file exist?
            if (parameters.manifestFile != null && !parameters.manifestFile.Exists)
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.manifestFile.FullName);
                return(null);
            }

            // Does the ploidy bed file exist?
            if (parameters.ploidyBedFile != null && !parameters.ploidyBedFile.Exists)
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.ploidyBedFile.FullName);
                return(null);
            }

            // Do we have only one model file in the PCA mode?
            if (parameters.normalizationMode == CanvasNormalizeMode.PCA && parameters.normalBedFiles.Count > 1)
            {
                Console.WriteLine("CanvasNormalize.exe: Please specify only one model file.");
                return(null);
            }

            return(parameters);
        }
Beispiel #7
0
        public static CanvasNormalizeParameters ParseCommandLine(string[] args)
        {
            CanvasNormalizeParameters parameters = new CanvasNormalizeParameters();
            // Should I display a help message?
            bool needHelp = false;

            OptionSet p = new OptionSet()
                {
                    { "t|tumor=",         "bed file containing bin counts for the tumor sample", v => parameters.tumorBedPath = v },
                    { "n|normal=",        "bed file containing bin counts for a normal sample. Pass this option multiple times, once for each normal sample.", v => parameters.normalBedPaths.Add(v) },
                    { "o|out=",           "bed file to output containing normalized bin counts",     v => parameters.outBedPath = v },
                    { "w|weightedAverageNormal=",           "bed file to output containing normalized bin counts",     v => parameters.weightedAverageNormalBedPath = v },
                    { "f|manifest=",      "Nextera manifest file",                       v => parameters.manifestPath = v },
                    { "p|ploidyBedFile=", "bed file specifying reference ploidy (e.g. for sex chromosomes) (optional)", v => parameters.ploidyBedPath = v},
                    { "h|help",           "show this message and exit",                       v => needHelp = v != null },
                    { "m|mode=",          "normalization mode",                               v => parameters.normalizationMode = CanvasCommon.Utilities.ParseCanvasNormalizeMode(v) },
                };

            Console.WriteLine("CanvasNormalize {0}", System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());

            List<string> extraArgs = p.Parse(args);

            // Check for required arguments. Display the help message if any of them are missing.
            if (string.IsNullOrEmpty(parameters.tumorBedPath))
            {
                Console.Error.WriteLine("Please specify the tumor bed file.");
                needHelp = true;
            }
            else if (!parameters.normalBedPaths.Any()) 
            {
                Console.Error.WriteLine("Please specify at least one normal bed file.");
                needHelp = true;
            }
            else if (string.IsNullOrEmpty(parameters.outBedPath))
            {
                Console.Error.WriteLine("Please specify an output file name.");
                needHelp = true;
            }

            if (needHelp)
            {
                ShowHelp(p);
                return null;
            }

            // Does the tumor bed file exist?
            if (!File.Exists(parameters.tumorBedPath))
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.tumorBedPath);
                return null;
            }

            // Does each of the normal bed files exist?
            foreach (string normalBedPath in parameters.normalBedPaths) 
            {
                if (!File.Exists(normalBedPath)) 
                {
                    Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", normalBedPath);
                    return null;
                }
            }

            // Does the manifest file exist?
            if (!string.IsNullOrEmpty(parameters.manifestPath) && !File.Exists(parameters.manifestPath))
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.manifestPath);
                return null;
            }
            
            // Does the ploidy bed file exist?
            if (!string.IsNullOrEmpty(parameters.ploidyBedPath) && !File.Exists(parameters.ploidyBedPath)) 
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.ploidyBedPath);
                return null;
            }

            return parameters;
        }
Beispiel #8
0
 public CanvasNormalizeFactory(CanvasNormalizeParameters parameters)
 {
     _parameters = parameters;
     _manifest   = _parameters.manifestFile == null ? null
         : new NexteraManifest(_parameters.manifestFile.FullName, null, Console.WriteLine);
 }
Beispiel #9
0
        public static CanvasNormalizeParameters ParseCommandLine(string[] args)
        {
            CanvasNormalizeParameters parameters = new CanvasNormalizeParameters();
            // Should I display a help message?
            bool needHelp = false;

            OptionSet p = new OptionSet()
            {
                { "t|tumor=", "bed file containing bin counts for the tumor sample", v => parameters.tumorBedPath = v },
                { "n|normal=", "bed file containing bin counts for a normal sample. Pass this option multiple times, once for each normal sample.", v => parameters.normalBedPaths.Add(v) },
                { "o|out=", "bed file to output containing normalized bin counts", v => parameters.outBedPath = v },
                { "w|weightedAverageNormal=", "bed file to output containing normalized bin counts", v => parameters.weightedAverageNormalBedPath = v },
                { "f|manifest=", "Nextera manifest file", v => parameters.manifestPath = v },
                { "p|ploidyBedFile=", "bed file specifying reference ploidy (e.g. for sex chromosomes) (optional)", v => parameters.ploidyBedPath = v },
                { "h|help", "show this message and exit", v => needHelp = v != null },
                { "m|mode=", "normalization mode", v => parameters.normalizationMode = CanvasCommon.Utilities.ParseCanvasNormalizeMode(v) },
            };

            Console.WriteLine("CanvasNormalize {0}", System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());

            List <string> extraArgs = p.Parse(args);

            // Check for required arguments. Display the help message if any of them are missing.
            if (string.IsNullOrEmpty(parameters.tumorBedPath))
            {
                Console.Error.WriteLine("Please specify the tumor bed file.");
                needHelp = true;
            }
            else if (!parameters.normalBedPaths.Any())
            {
                Console.Error.WriteLine("Please specify at least one normal bed file.");
                needHelp = true;
            }
            else if (string.IsNullOrEmpty(parameters.outBedPath))
            {
                Console.Error.WriteLine("Please specify an output file name.");
                needHelp = true;
            }

            if (needHelp)
            {
                ShowHelp(p);
                return(null);
            }

            // Does the tumor bed file exist?
            if (!File.Exists(parameters.tumorBedPath))
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.tumorBedPath);
                return(null);
            }

            // Does each of the normal bed files exist?
            foreach (string normalBedPath in parameters.normalBedPaths)
            {
                if (!File.Exists(normalBedPath))
                {
                    Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", normalBedPath);
                    return(null);
                }
            }

            // Does the manifest file exist?
            if (!string.IsNullOrEmpty(parameters.manifestPath) && !File.Exists(parameters.manifestPath))
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.manifestPath);
                return(null);
            }

            // Does the ploidy bed file exist?
            if (!string.IsNullOrEmpty(parameters.ploidyBedPath) && !File.Exists(parameters.ploidyBedPath))
            {
                Console.WriteLine("CanvasNormalize.exe: File {0} does not exist! Exiting.", parameters.ploidyBedPath);
                return(null);
            }

            return(parameters);
        }