htsjdk.samtools.util.Histogram.getMean()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中htsjdk.samtools.util.Histogram.getMean()方法的一些代码示例,展示了Histogram.getMean()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.getMean()方法的具体详情如下:
包路径:htsjdk.samtools.util.Histogram
类名称:Histogram
方法名:getMean

Histogram.getMean介绍

[英]Assuming that the key type for the histogram is a Number type, returns the mean of all the items added to the histogram.
[中]假设直方图的键类型是数字类型,则返回添加到直方图的所有项目的平均值。

代码示例

代码示例来源:origin: com.github.samtools/htsjdk

public double getStandardDeviation() {
  final double mean = getMean();
  double count = 0;
  double total = 0;
  for (final Bin<K> bin : map.values()) {
    final double localCount = bin.getValue();
    final double value = bin.getIdValue();
    count += localCount;
    total += localCount * pow(value - mean, 2);
  }
  return Math.sqrt(total / (count-1));
}

代码示例来源:origin: samtools/htsjdk

public double getStandardDeviation() {
  final double mean = getMean();
  double count = 0;
  double total = 0;
  for (final Bin<K> bin : map.values()) {
    final double localCount = bin.getValue();
    final double value = bin.getIdValue();
    count += localCount;
    total += localCount * pow(value - mean, 2);
  }
  return Math.sqrt(total / (count-1));
}

代码示例来源:origin: org.seqdoop/htsjdk

public double getStandardDeviation() {
  final double mean = getMean();
  double count = 0;
  double total = 0;
  for (final Bin bin : values()) {
    final double localCount = bin.getValue();
    final double value = bin.getIdValue();
    count += localCount;
    total += localCount * pow(value - mean, 2);
  }
  return Math.sqrt(total / (count-1));
}

代码示例来源:origin: broadinstitute/picard

final double averageQuality = qualityHistogram.getMean();
final double standardDeviationQuality = qualityHistogram.getStandardDeviation();

代码示例来源:origin: broadinstitute/picard

public void onComplete() {
  //summarize read data
  if (metrics.TOTAL_READS > 0)
  {
    metrics.PCT_PF_READS = (double) metrics.PF_READS / (double) metrics.TOTAL_READS;
    metrics.PCT_ADAPTER = this.adapterReads / (double) metrics.PF_READS;
    metrics.MEAN_READ_LENGTH = readLengthHistogram.getMean();
    //Calculate BAD_CYCLES
    metrics.BAD_CYCLES = 0;
    for (final Histogram.Bin<Integer> cycleBin : badCycleHistogram.values()) {
      final double badCyclePercentage = cycleBin.getValue() / metrics.TOTAL_READS;
      if (badCyclePercentage >= 0.8) {
        metrics.BAD_CYCLES++;
      }
    }
    if(doRefMetrics) {
      if (metrics.PF_READS > 0)         metrics.PCT_PF_READS_ALIGNED = (double) metrics.PF_READS_ALIGNED / (double) metrics.PF_READS;
      if (metrics.PF_READS_ALIGNED > 0) metrics.PCT_READS_ALIGNED_IN_PAIRS = (double) metrics.READS_ALIGNED_IN_PAIRS / (double) metrics.PF_READS_ALIGNED;
      if (metrics.PF_READS_ALIGNED > 0) metrics.PCT_PF_READS_IMPROPER_PAIRS = (double) metrics.PF_READS_IMPROPER_PAIRS / (double) metrics.PF_READS_ALIGNED;
      if (metrics.PF_READS_ALIGNED > 0) metrics.STRAND_BALANCE = numPositiveStrand / (double) metrics.PF_READS_ALIGNED;
      if (this.chimerasDenominator > 0) metrics.PCT_CHIMERAS = this.chimeras / (double) this.chimerasDenominator;
      if (nonBisulfiteAlignedBases > 0) metrics.PF_MISMATCH_RATE = mismatchHistogram.getSum() / (double) nonBisulfiteAlignedBases;
      metrics.PF_HQ_MEDIAN_MISMATCHES = hqMismatchHistogram.getMedian();
      if (hqNonBisulfiteAlignedBases > 0) metrics.PF_HQ_ERROR_RATE = hqMismatchHistogram.getSum() / (double) hqNonBisulfiteAlignedBases;
      if (metrics.PF_ALIGNED_BASES > 0) metrics.PF_INDEL_RATE = this.indels / (double) metrics.PF_ALIGNED_BASES;
    }
  }
}

代码示例来源:origin: com.github.broadinstitute/picard

public void onComplete() {
  //summarize read data
  if (metrics.TOTAL_READS > 0)
  {
    metrics.PCT_PF_READS = (double) metrics.PF_READS / (double) metrics.TOTAL_READS;
    metrics.PCT_ADAPTER = this.adapterReads / (double) metrics.PF_READS;
    metrics.MEAN_READ_LENGTH = readLengthHistogram.getMean();
    //Calculate BAD_CYCLES
    metrics.BAD_CYCLES = 0;
    for (final Histogram.Bin<Integer> cycleBin : badCycleHistogram.values()) {
      final double badCyclePercentage = cycleBin.getValue() / metrics.TOTAL_READS;
      if (badCyclePercentage >= 0.8) {
        metrics.BAD_CYCLES++;
      }
    }
    if(doRefMetrics) {
      if (metrics.PF_READS > 0)         metrics.PCT_PF_READS_ALIGNED = (double) metrics.PF_READS_ALIGNED / (double) metrics.PF_READS;
      if (metrics.PF_READS_ALIGNED > 0) metrics.PCT_READS_ALIGNED_IN_PAIRS = (double) metrics.READS_ALIGNED_IN_PAIRS / (double) metrics.PF_READS_ALIGNED;
      if (metrics.PF_READS_ALIGNED > 0) metrics.PCT_PF_READS_IMPROPER_PAIRS = (double) metrics.PF_READS_IMPROPER_PAIRS / (double) metrics.PF_READS_ALIGNED;
      if (metrics.PF_READS_ALIGNED > 0) metrics.STRAND_BALANCE = numPositiveStrand / (double) metrics.PF_READS_ALIGNED;
      if (this.chimerasDenominator > 0) metrics.PCT_CHIMERAS = this.chimeras / (double) this.chimerasDenominator;
      if (nonBisulfiteAlignedBases > 0) metrics.PF_MISMATCH_RATE = mismatchHistogram.getSum() / (double) nonBisulfiteAlignedBases;
      metrics.PF_HQ_MEDIAN_MISMATCHES = hqMismatchHistogram.getMedian();
      if (hqNonBisulfiteAlignedBases > 0) metrics.PF_HQ_ERROR_RATE = hqMismatchHistogram.getSum() / (double) hqNonBisulfiteAlignedBases;
      if (metrics.PF_ALIGNED_BASES > 0) metrics.PF_INDEL_RATE = this.indels / (double) metrics.PF_ALIGNED_BASES;
    }
  }
}

代码示例来源:origin: com.github.broadinstitute/picard

final double averageQuality = qualityHistogram.getMean();
final double standardDeviationQuality = qualityHistogram.getStandardDeviation();

代码示例来源:origin: broadinstitute/picard

@Test(dataProvider = "sumOfGaussiansDataProvider")
public void testDrawSumOfQScores(final File metricsFile, final int altDepth, final double tolerance) throws Exception {
  final MetricsFile<TheoreticalSensitivityMetrics, Integer> metrics = new MetricsFile<>();
  try (final FileReader metricsFileReader = new FileReader(metricsFile)) {
    metrics.read(metricsFileReader);
  }
  final List<Histogram<Integer>> histograms = metrics.getAllHistograms();
  final Histogram<Integer> qualityHistogram = histograms.get(1);
  final TheoreticalSensitivity.RouletteWheel qualityRW = new TheoreticalSensitivity.RouletteWheel(TheoreticalSensitivity.trimDistribution(TheoreticalSensitivity.normalizeHistogram(qualityHistogram)));
  final Random randomNumberGenerator = new Random(51);
  // Calculate mean and deviation of quality score distribution to enable Gaussian sampling below
  final double averageQuality = qualityHistogram.getMean();
  final double standardDeviationQuality = qualityHistogram.getStandardDeviation();
  for (int k = 0; k < 1; k++) {
    int sumOfQualitiesFull = IntStream.range(0, altDepth).map(n -> qualityRW.draw()).sum();
    int sumOfQualities = TheoreticalSensitivity.drawSumOfQScores(altDepth, averageQuality, standardDeviationQuality, randomNumberGenerator.nextGaussian());
    Assert.assertEquals(sumOfQualitiesFull, sumOfQualities, sumOfQualitiesFull * tolerance);
  }
}

代码示例来源:origin: samtools/htsjdk

@Test(dataProvider = "histogramData")
public void testHistogramFunctions(final int[] values, final double mean, final double stdev, final Integer trimByWidth) {
  final Histogram<Integer> histo = new Histogram<>();
  for (int value : values) {
    histo.increment(value);
  }
  if (trimByWidth != null) histo.trimByWidth(trimByWidth);
  final double m = histo.getMean();
  final double sd = histo.getStandardDeviation();
  Assert.assertEquals(round(mean), round(m), "Means are not equal");
  Assert.assertEquals(round(stdev), round(sd), "Stdevs are not equal");
}

代码示例来源:origin: broadinstitute/picard

metrics.MEAN_INSERT_SIZE = trimmedHistogram.getMean();
metrics.STANDARD_DEVIATION = trimmedHistogram.getStandardDeviation();

代码示例来源:origin: com.github.broadinstitute/picard

metrics.MEAN_INSERT_SIZE = trimmedHistogram.getMean();
metrics.STANDARD_DEVIATION = trimmedHistogram.getStandardDeviation();

代码示例来源:origin: com.github.broadinstitute/picard

metrics.JUMP_LIBRARY_SIZE = (outies > 0 && outieDupes > 0) ? DuplicationMetrics.estimateLibrarySize(outies, outies - outieDupes) : 0;
outieHistogram.trimByTailLimit(TAIL_LIMIT);
metrics.JUMP_MEAN_INSERT_SIZE = outieHistogram.getMean();
metrics.JUMP_STDEV_INSERT_SIZE = outieHistogram.getStandardDeviation();
metrics.NONJUMP_PAIRS = innies;
metrics.NONJUMP_LIBRARY_SIZE = (innies > 0 && innieDupes > 0) ? DuplicationMetrics.estimateLibrarySize(innies, innies - innieDupes) : 0;
innieHistogram.trimByTailLimit(TAIL_LIMIT);
metrics.NONJUMP_MEAN_INSERT_SIZE = innieHistogram.getMean();
metrics.NONJUMP_STDEV_INSERT_SIZE = innieHistogram.getStandardDeviation();
metrics.CHIMERIC_PAIRS = crossChromPairs + superSized + tandemPairs;

代码示例来源:origin: broadinstitute/picard

metrics.JUMP_LIBRARY_SIZE = (outies > 0 && outieDupes > 0) ? DuplicationMetrics.estimateLibrarySize(outies, outies - outieDupes) : 0;
outieHistogram.trimByTailLimit(TAIL_LIMIT);
metrics.JUMP_MEAN_INSERT_SIZE = outieHistogram.getMean();
metrics.JUMP_STDEV_INSERT_SIZE = outieHistogram.getStandardDeviation();
metrics.NONJUMP_PAIRS = innies;
metrics.NONJUMP_LIBRARY_SIZE = (innies > 0 && innieDupes > 0) ? DuplicationMetrics.estimateLibrarySize(innies, innies - innieDupes) : 0;
innieHistogram.trimByTailLimit(TAIL_LIMIT);
metrics.NONJUMP_MEAN_INSERT_SIZE = innieHistogram.getMean();
metrics.NONJUMP_STDEV_INSERT_SIZE = innieHistogram.getStandardDeviation();
metrics.CHIMERIC_PAIRS = crossChromPairs + superSized + tandemPairs;

代码示例来源:origin: com.github.broadinstitute/picard

MEAN_COVERAGE    = highQualityDepthHistogram.getMean();
SD_COVERAGE      = highQualityDepthHistogram.getStandardDeviation();
MEDIAN_COVERAGE  = highQualityDepthHistogram.getMedian();

代码示例来源:origin: broadinstitute/picard

MEAN_COVERAGE    = highQualityDepthHistogram.getMean();
SD_COVERAGE      = highQualityDepthHistogram.getStandardDeviation();
MEDIAN_COVERAGE  = highQualityDepthHistogram.getMedian();

相关文章