Exemple #1
0
        public void TestAlignment(string datasetNameX, string datasetNameY)
        {
            var featureFileX = GetTestPath(datasetNameX + "_isos.csv");
            var rawFileX     = GetTestPath(datasetNameX + ".raw");

            var featureFileY = GetTestPath(datasetNameY + "_isos.csv");
            var rawFileY     = GetTestPath(datasetNameY + ".raw");

            Print("Detecting Features");
            var featuresX = FindFeatures(rawFileX, featureFileX);
            var featuresY = FindFeatures(rawFileY, featureFileY);

            PrintFeatureMsMsData(featuresX);
            PrintFeatureMsMsData(featuresY);

            Print("Aligning Features");
            // Align the features
            var alignmentOptions = new AlignmentOptions();
            var aligner          = new LcmsWarpFeatureAligner(alignmentOptions.LCMSWarpOptions);

            aligner.Align(featuresX, featuresY);

            Print("");
            Print("NET, NETAligned");
            foreach (var feature in featuresY)
            {
                if (feature.HasMsMs())
                {
                    Print(string.Format("{0}", feature.Net - feature.NetAligned));
                }
            }
        }
Exemple #2
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 public AnalysisOptions()
 {
     AlignmentOptions          = new AlignmentOptions();
     DriftTimeAlignmentOptions = new DriftTimeAlignmentOptions();
     ClusterOptions            = new LCMSFeatureClusteringOptions();
     STACOptions          = new StacOptions();
     ConsolidationOptions = new FeatureConsolidatorOptions();
 }
Exemple #3
0
 public static TestObject GetTestObject(BrowserOptions browserOptions, AlignmentOptions alignOptions)//factory call
 {
     try
     {
         return(new TestObject(browserOptions, alignOptions));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #4
0
        private TestObject(BrowserOptions browserOptions, AlignmentOptions alignOptions)
        {
            #region Init
            this.elementCache = new Dictionary <By, IWebElement>();
            this.dataCache    = new Dictionary <int, string>();
            #endregion
            AppDomain domain = AppDomain.CurrentDomain;
            string    path   = domain.BaseDirectory;

            if (browserOptions.Equals(BrowserOptions.Chrome) && alignOptions.Equals(AlignmentOptions.Desktop))
            {
                ChromeOptions options = new ChromeOptions();
                options.PageLoadStrategy = PageLoadStrategy.Normal;
                options.AddArgument("--disable-notifications");
                options.AddArgument("--start-maximized");
                options.AddArgument("--disable-sync");
                options.AddArgument("--disbale-gpu");
                options.AddArguments("--mute-audio");
                options.AddArguments("--no-sandbox");
                //options.AddArgument("--headless");
                this.driver = new ChromeDriver(path, options);
            }
            if (browserOptions.Equals(BrowserOptions.Chrome) && alignOptions.Equals(AlignmentOptions.MobileSite))
            {
                ChromeOptions options = new ChromeOptions();
                options.PageLoadStrategy = PageLoadStrategy.Normal;
                options.EnableMobileEmulation("iPhone 6");
                options.AddArgument("--disable-notifications");
                options.AddArgument("--start-maximized");
                options.AddArgument("--disable-sync");
                options.AddArgument("--disbale-gpu");
                options.AddArguments("--mute-audio");
                options.AddArguments("--no-sandbox");
                //options.AddArgument("--headless");
                this.driver = new ChromeDriver(path, options);
            }
            if (browserOptions.Equals(BrowserOptions.Firefox) && alignOptions.Equals(AlignmentOptions.Desktop))
            {
            }
            if (browserOptions.Equals(BrowserOptions.Firefox) && alignOptions.Equals(AlignmentOptions.MobileSite))
            {
            }

            this.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
            this.driver.Manage().Timeouts().PageLoad     = TimeSpan.FromSeconds(100);
        }
Exemple #5
0
        public void TestSpectralAlignment(string basePath, string baselineName, string aligneeName,
                                          double comparisonCutoff)
        {
            RootDataPath = basePath;


            var featureFileX = GetTestPath(baselineName + "_isos.csv");
            var rawFileX     = GetTestPath(baselineName + ".raw");

            var featureFileY = GetTestPath(aligneeName + "_isos.csv");
            var rawFileY     = GetTestPath(aligneeName + ".raw");

            Print("Detecting Features");
            var baselineFeatures = FindFeatures(rawFileX, featureFileX);
            var aligneeFeatures  = FindFeatures(rawFileY, featureFileY);

            Print("Aligning Features");
            // Align the features
            var alignmentOptions = new AlignmentOptions();
            var aligner          = new LcmsWarpFeatureAligner(alignmentOptions.LCMSWarpOptions);

            aligner.Align(baselineFeatures, aligneeFeatures);

            PrintFeatureMsMsData(baselineFeatures);
            PrintFeatureMsMsData(aligneeFeatures);

            var matches = GetSpectralMatches(
                baselineFeatures, aligneeFeatures, comparisonCutoff);

            Print(string.Format("Found {0} spectral matches", matches.Count));
            Print("Similarity, Pre-Alignment, Post-Alignment");

            var counts = new Dictionary <double, int>();

            counts.Add(.9, 0);
            counts.Add(.8, 0);
            counts.Add(.7, 0);
            counts.Add(.6, 0);
            counts.Add(.5, 0);

            var preDist  = new List <double>();
            var postDist = new List <double>();

            foreach (var match in matches)
            {
                var baselineFeature = match.Baseline.ParentFeature.GetParentFeature();
                var aligneeFeature  = match.Alignee.ParentFeature.GetParentFeature();

                var preAlignment  = baselineFeature.Net - aligneeFeature.Net;
                var postAlignment = baselineFeature.Net - aligneeFeature.NetAligned;

                postDist.Add(postAlignment);
                preDist.Add(preAlignment);

                Print(string.Format("{0},{1},{2}", match.Similarity, preAlignment, postAlignment));

                if (match.Similarity > .9)
                {
                    counts[.9]++;
                }
                else if (match.Similarity > .8)
                {
                    counts[.8]++;
                }
                else if (match.Similarity > .7)
                {
                    counts[.7]++;
                }
                else if (match.Similarity > .6)
                {
                    counts[.6]++;
                }
            }
            Print("");
            Print("Counts");
            Print("");
            foreach (var key in counts.Keys)
            {
                Print(string.Format("{0},{1}", key, counts[key]));
            }

            var test = new MannWhitneyTest();
            var data = test.Test(preDist, postDist);

            Print(string.Format("Two Tail - {0} ", data.TwoTail));
            Print(string.Format("Left Tail - {0} ", data.LeftTail));
            Print(string.Format("Right Tail - {0} ", data.RightTail));
        }
Exemple #6
0
        public void TestClustering(
            string directory,
            string outputPath,
            FeatureAlignmentType alignmentType,
            LcmsFeatureClusteringAlgorithmType clusterType)
        {
            var matchPath = string.Format("{0}.txt", outputPath);
            var errorPath = string.Format("{0}-errors.txt", outputPath);

            // Loads the supported MultiAlign types
            var supportedTypes = DatasetLoader.SupportedFileTypes;
            var extensions     = new List <string>();

            supportedTypes.ForEach(x => extensions.Add("*" + x.Extension));

            // Find our datasets
            var datasetLoader = new DatasetLoader();
            var datasets      = datasetLoader.GetValidDatasets(directory, extensions, SearchOption.TopDirectoryOnly);

            // Setup our alignment options
            var alignmentOptions = new AlignmentOptions();
            var spectralOptions  = new SpectralOptions
            {
                ComparerType      = SpectralComparison.CosineDotProduct,
                Fdr               = .01,
                IdScore           = 1e-09,
                MzBinSize         = .5,
                MzTolerance       = .5,
                NetTolerance      = .1,
                RequiredPeakCount = 32,
                SimilarityCutoff  = .75,
                TopIonPercent     = .8
            };


            // Options setup
            var instrumentOptions = InstrumentPresetFactory.Create(InstrumentPresets.LtqOrbitrap);
            var featureTolerances = new FeatureTolerances
            {
                Mass      = instrumentOptions.Mass + 6,
                Net       = instrumentOptions.NetTolerance,
                DriftTime = instrumentOptions.DriftTimeTolerance
            };
            var featureFindingOptions = new LcmsFeatureFindingOptions(featureTolerances)
            {
                MaximumNetRange  = .002,
                MaximumScanRange = 50
            };

            // Create our algorithms
            var finder  = FeatureFinderFactory.CreateFeatureFinder(FeatureFinderType.TreeBased);
            var aligner = FeatureAlignerFactory.CreateDatasetAligner(alignmentType,
                                                                     alignmentOptions.LCMSWarpOptions,
                                                                     spectralOptions);
            var clusterer = ClusterFactory.Create(clusterType);

            clusterer.Parameters = new FeatureClusterParameters <UMCLight>
            {
                Tolerances = featureTolerances
            };

            RegisterProgressNotifier(aligner);
            RegisterProgressNotifier(finder);
            RegisterProgressNotifier(clusterer);

            var lcmsFilters = new LcmsFeatureFilteringOptions
            {
                FeatureLengthRangeScans = new FilterRange(50, 300)
            };
            var msFilterOptions = new MsFeatureFilteringOptions
            {
                MinimumIntensity           = 5000,
                ChargeRange                = new FilterRange(1, 6),
                ShouldUseChargeFilter      = true,
                ShouldUseDeisotopingFilter = true,
                ShouldUseIntensityFilter   = true
            };

            for (var i = 0; i < 1; i++)
            {
                var aligneeDatasets = datasets.Where((t, j) => j != i).ToList();
                PerformMultiAlignAnalysis(datasets[0],
                                          aligneeDatasets,
                                          featureFindingOptions,
                                          msFilterOptions,
                                          lcmsFilters,
                                          spectralOptions,
                                          finder,
                                          aligner,
                                          clusterer,
                                          matchPath,
                                          errorPath);
            }
        }
Exemple #7
0
        public void GenerateClusterAlignmentStatistics(string relativeDatabasePath,
                                                       string relativeName,
                                                       string name,
                                                       FeatureAlignmentType alignmentType,
                                                       LcmsFeatureClusteringAlgorithmType clusterType)
        {
            var databasePath = GetPath(relativeDatabasePath);
            var outputPath   = GetOutputPath(relativeName);

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            // Connect to the NHibernate database
            var providers = DataAccessFactory.CreateDataAccessProviders(databasePath, false);

            // Setup our alignment options
            var alignmentOptions = new AlignmentOptions();
            var spectralOptions  = new SpectralOptions
            {
                ComparerType      = SpectralComparison.CosineDotProduct,
                Fdr               = .01,
                IdScore           = 1e-09,
                MzBinSize         = .5,
                MzTolerance       = .5,
                NetTolerance      = .1,
                RequiredPeakCount = 32,
                SimilarityCutoff  = .75,
                TopIonPercent     = .8
            };

            // Options setup
            var instrumentOptions = InstrumentPresetFactory.Create(InstrumentPresets.LtqOrbitrap);
            var featureTolerances = new FeatureTolerances
            {
                Mass      = instrumentOptions.Mass + 6,
                Net       = instrumentOptions.NetTolerance,
                DriftTime = instrumentOptions.DriftTimeTolerance
            };

            UpdateStatus("Retrieving all datasets for test.");
            var datasets = providers.DatasetCache.FindAll();

            // Create our algorithms
            var aligner = FeatureAlignerFactory.CreateDatasetAligner(alignmentType,
                                                                     alignmentOptions.LCMSWarpOptions,
                                                                     spectralOptions);
            var clusterer = ClusterFactory.Create(clusterType);

            clusterer.Parameters = new FeatureClusterParameters <UMCLight>
            {
                Tolerances = featureTolerances
            };

            RegisterProgressNotifier(aligner);
            RegisterProgressNotifier(clusterer);

            for (var i = 0; i < datasets.Count - 1; i++)
            {
                var matchPath = string.Format("{0}-{1}-matches.txt", name, i);
                var errorPath = string.Format("{0}-{1}-errors.txt", name, i);

                matchPath = Path.Combine(outputPath, matchPath);
                errorPath = Path.Combine(outputPath, errorPath);



                var aligneeDataset  = datasets[i + 1];
                var baselineDataset = datasets[i];

                // Load the baseline reference set
                using (var rawProviderX = new InformedProteomicsReader())
                {
                    rawProviderX.AddDataFile(baselineDataset.RawFile.Path, 0);
                    // Load the baseline reference set
                    using (var rawProviderY = new InformedProteomicsReader())
                    {
                        rawProviderY.AddDataFile(aligneeDataset.RawFile.Path, 0);

                        var baselineFeatures = RetrieveFeatures(baselineDataset.DatasetId, providers);
                        var aligneeFeatures  = RetrieveFeatures(aligneeDataset.DatasetId, providers);
                        var providerX        = new CachedFeatureSpectraProvider(rawProviderX, baselineFeatures);
                        var providerY        = new CachedFeatureSpectraProvider(rawProviderY, aligneeFeatures);

                        AlignDatasets(baselineFeatures,
                                      aligneeFeatures,
                                      providerX,
                                      providerY,
                                      aligner,
                                      clusterer,
                                      matchPath,
                                      errorPath);
                    }
                }
            }
        }