internal Processor(IPeakConstructor <I> peakConstructor, bool trackSupportingRegions) { _samples = new Dictionary <uint, Bed <I> >(); _peakConstructor = peakConstructor; _trackSupportingRegions = trackSupportingRegions; DegreeOfParallelism = Environment.ProcessorCount; }
public Mspc(IPeakConstructor <I> peakConstructor) { _processor = new Processor <I>(peakConstructor); _processor.OnProgressUpdate += _processorOnProgressUpdate; _backgroundProcessor = new BackgroundWorker(); _backgroundProcessor.DoWork += _doWork; _backgroundProcessor.RunWorkerCompleted += _runWorkerCompleted; _backgroundProcessor.WorkerSupportsCancellation = true; Done = new AutoResetEvent(false); Canceled = new AutoResetEvent(false); }
/// <summary> /// Parse standard Browser Extensible Data (BED) format. /// </summary> /// <param name="sourceFilePath">Full path of source file name.</param> public BedParser(BedColumns columns, IPeakConstructor <I> constructor) : base(columns) { _constructor = constructor; _nameColumn = columns.Name; _valueColumn = columns.Value; _summitColumn = columns.Summit; _mostStringentPeak = _constructor.Construct(0, 2, 1); _mostPermissivePeak = _constructor.Construct(0, 2, 0); DefaultValue = 1E-8; DropPeakIfInvalidValue = true; ValidatePValue = true; PValueFormat = PValueFormats.SameAsInput; }
public Dictionary <string, List <ProcessedPeak <I> > > Compute( Dictionary <uint, Result <I> > analysisResults, IPeakConstructor <I> peakConstructor, int degreeOfParallelisim, float alpha) { // Initialize data structures. _consensusPeaks = new Dictionary <string, SortedDictionary <Interval, Interval> >(); foreach (var result in analysisResults) { foreach (var chr in result.Value.Chromosomes) { if (!_consensusPeaks.ContainsKey(chr.Key)) { _consensusPeaks.Add(chr.Key, new SortedDictionary <Interval, Interval>()); } } } // Determin consensus peaks; stored in mutable and light-weight types. foreach (var result in analysisResults) { Parallel.ForEach( result.Value.Chromosomes, new ParallelOptions { MaxDegreeOfParallelism = degreeOfParallelisim }, chr => { DetermineConsensusPeaks(chr.Key, chr.Value.Get(Attributes.Confirmed)); }); } // Convert the type of determined consensus peaks. var processedPeaks = ConvertToListOfProcessedPeaks(peakConstructor, degreeOfParallelisim); var fdr = new FalseDiscoveryRate <I>(); fdr.PerformMultipleTestingCorrection(processedPeaks, alpha); return(processedPeaks); }
private Dictionary <string, List <ProcessedPeak <I> > > ConvertToListOfProcessedPeaks(IPeakConstructor <I> peakConstructor, int degreeOfParallelism) { var rtv = new Dictionary <string, List <ProcessedPeak <I> > >(); foreach (var chr in _consensusPeaks) { rtv.Add(chr.Key, new List <ProcessedPeak <I> >(capacity: chr.Value.Count)); } int counter = 0; Parallel.ForEach( _consensusPeaks, new ParallelOptions { MaxDegreeOfParallelism = degreeOfParallelism }, chr => { foreach (var peak in chr.Value) { rtv[chr.Key].Add(new ProcessedPeak <I>( peakConstructor.Construct( peak.Key.left, peak.Key.right, ChiSqrd.ChiSqrdDistRTP(peak.Key.xSquard, peak.Key.involvedPeaksCount * 2), "MSPC_Peak_" + Interlocked.Increment(ref counter), (peak.Key.right - peak.Key.left) / 2), peak.Key.xSquard, peak.Key.involvedPeaksCount - 1)); } }); return(rtv); }
internal Processor(IPeakConstructor <I> peakConstructor) { _samples = new Dictionary <uint, Bed <I> >(); _peakConstructor = peakConstructor; DegreeOfParallelism = Environment.ProcessorCount; }