当前位置: 首页>>代码示例>>Java>>正文


Java Genotype.isNoCall方法代码示例

本文整理汇总了Java中htsjdk.variant.variantcontext.Genotype.isNoCall方法的典型用法代码示例。如果您正苦于以下问题:Java Genotype.isNoCall方法的具体用法?Java Genotype.isNoCall怎么用?Java Genotype.isNoCall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在htsjdk.variant.variantcontext.Genotype的用法示例。


在下文中一共展示了Genotype.isNoCall方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTableFromSamples

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * Create the contingency table by retrieving the per-sample strand bias annotation and adding them together
 *
 * @param genotypes the genotypes from which to pull out the per-sample strand bias annotation
 * @param minCount  minimum threshold for the sample strand bias counts for each ref and alt.
 *                  If both ref and alt counts are above minCount the whole sample strand bias is added to the resulting table
 * @return the table used for several strand bias tests, will be null if none of the genotypes contain the per-sample SB annotation
 */
protected int[][] getTableFromSamples(final GenotypesContext genotypes, final int minCount) {
    if (genotypes == null) {
        throw new IllegalArgumentException("Genotypes cannot be null.");
    }

    final int[] sbArray = {0, 0, 0, 0}; // reference-forward-reverse -by- alternate-forward-reverse
    boolean foundData = false;

    for (final Genotype g : genotypes) {
        if (g.isNoCall() || !g.hasAnyAttribute(StrandBiasBySample.STRAND_BIAS_BY_SAMPLE_KEY_NAME))
            continue;

        foundData = true;
        final ArrayList<Integer> sbbsString = (ArrayList<Integer>) g.getAnyAttribute(StrandBiasBySample.STRAND_BIAS_BY_SAMPLE_KEY_NAME);
        final int[] data = Utils.list2Array(sbbsString);
        if (passesMinimumThreshold(data, minCount)) {
            for (int index = 0; index < sbArray.length; index++) {
                sbArray[index] += data[index];
            }
        }
    }

    return (foundData ? decodeSBBS(sbArray) : null);
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:33,代码来源:StrandBiasTest.java

示例2: getTableFromSamples

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 */
protected int[][] getTableFromSamples(final GenotypesContext genotypes, final int minCount) {
	if (genotypes == null) {
		if (!getTableFromSamplesWarningLogged) {
			getTableFromSamplesWarningLogged = true;
		}
		return null;
	}

	final int[] sbArray = { 0, 0, 0, 0 }; // reference-forward-reverse -by-
											// alternate-forward-reverse
	boolean foundData = false;

	for (final Genotype g : genotypes) {
		if (g.isNoCall() || !g.hasAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY))
			continue;

		foundData = true;
		int[] data;
		if (g.getAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY).getClass().equals(String.class)) {
			final String sbbsString = (String) g.getAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY);
			data = encodeSBBS(sbbsString);
		} else if (g.getAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY).getClass()
				.equals(ArrayList.class)) {
			ArrayList sbbsList = (ArrayList) g.getAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY);
			data = encodeSBBS(sbbsList);
		} else
			throw new IllegalArgumentException(
					"Unexpected " + GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY + " type");

		if (passesMinimumThreshold(data, minCount)) {
			for (int index = 0; index < sbArray.length; index++) {
				sbArray[index] += data[index];
			}
		}
	}

	return (foundData ? decodeSBBS(sbArray) : null);
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:41,代码来源:StrandBiasTest.java

示例3: annotate

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public Map<String, Object> annotate(final VariantDataTracker tracker,
                                    final ChromosomeInformationShare ref,
                                    final Mpileup mpileup,
                                    final VariantContext vc,
                                    final Map<String, PerReadAlleleLikelihoodMap> stratifiedPerReadAlleleLikelihoodMap) {

    final GenotypesContext genotypes = vc.getGenotypes();
    if ( genotypes == null || genotypes.size() < MIN_SAMPLES )
        return null;

    int refCount = 0;
    int hetCount = 0;
    int homCount = 0;
    for ( final Genotype g : genotypes ) {
        if ( g.isNoCall() )
            continue;

        // TODO - fix me:
        // Right now we just ignore genotypes that are not confident, but this throws off
        //  our HW ratios.  More analysis is needed to determine the right thing to do when
        //  the genotyper cannot decide whether a given sample is het or hom var.
        if ( g.getLog10PError() > MIN_LOG10_PERROR )
            continue;

        if ( g.isHomRef() )
            refCount++;
        else if ( g.isHet() )
            hetCount++;
        else
            homCount++;
    }

    if ( refCount + hetCount + homCount == 0)
        return null;

    double pvalue = HardyWeinbergCalculation.hwCalculate(refCount, hetCount, homCount);
    //System.out.println(refCount + " " + hetCount + " " + homCount + " " + pvalue);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(getKeyNames().get(0), String.format("%.1f", QualityUtils.phredScaleErrorRate(pvalue)));
    return map;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:42,代码来源:HardyWeinberg.java

示例4: calculateIC

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private Map<String, Object> calculateIC(final VariantContext vc) {
    final GenotypesContext genotypes = (founderIds == null || founderIds.isEmpty()) ? vc.getGenotypes() : vc.getGenotypes(founderIds);
    if ( genotypes == null || genotypes.size() < MIN_SAMPLES || !vc.isVariant())
        return null;

    int idxAA = 0, idxAB = 1, idxBB = 2;

    if (!vc.isBiallelic()) {
        // for non-bliallelic case, do test with most common alt allele.
        // Get then corresponding indeces in GL vectors to retrieve GL of AA,AB and BB.
        int[] idxVector = vc.getGLIndecesOfAlternateAllele(vc.getAltAlleleWithHighestAlleleCount());
        idxAA = idxVector[0];
        idxAB = idxVector[1];
        idxBB = idxVector[2];
    }

    double refCount = 0.0;
    double hetCount = 0.0;
    double homCount = 0.0;
    int N = 0; // number of samples that have likelihoods
    for ( final Genotype g : genotypes ) {
        if ( g.isNoCall() || !g.hasLikelihoods() )
            continue;

        if (g.getPloidy() != 2) // only work for diploid samples
            continue;

        N++;
        final double[] normalizedLikelihoods = MathUtils.normalizeFromLog10( g.getLikelihoods().getAsVector() );
        refCount += normalizedLikelihoods[idxAA];
        hetCount += normalizedLikelihoods[idxAB];
        homCount += normalizedLikelihoods[idxBB];
    }

    if( N < MIN_SAMPLES ) {
        return null;
    }

    final double p = ( 2.0 * refCount + hetCount ) / ( 2.0 * (refCount + hetCount + homCount) ); // expected reference allele frequency
    final double q = 1.0 - p; // expected alternative allele frequency
    final double F = 1.0 - ( hetCount / ( 2.0 * p * q * (double)N ) ); // inbreeding coefficient

    Map<String, Object> map = new HashMap<String, Object>();
    map.put(getKeyNames().get(0), String.format("%.4f", F));
    return map;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:47,代码来源:InbreedingCoeff.java


注:本文中的htsjdk.variant.variantcontext.Genotype.isNoCall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。