GATK LikelihoodMatrix接口介绍

LikelihoodMatrix 是 GATK 中用来表示测序数据的似然值矩阵的接口。它在变异检测中扮演了重要角色,通过它可以访问和操作样本中读取序列(reads)与等位基因之间的似然值。LikelihoodMatrix 是一个泛型接口,通常与样本类型(例如 String)和读取序列类型(例如 GATKRead)一起使用。

核心功能

  • 表示似然值矩阵LikelihoodMatrix 的核心功能是存储读取序列与等位基因的似然值。
  • 获取和设置似然值: 可以通过 get 和 set 方法访问和修改矩阵中的值。
  • 获取矩阵维度: 提供了获取样本数、读取序列数和等位基因数的方法。

主要方法

实现类

LikelihoodMatrix接口源码

package org.broadinstitute.hellbender.utils.genotyper;

import htsjdk.variant.variantcontext.Allele;
import org.apache.commons.math3.linear.RealMatrix;
import org.ojalgo.access.Access2D;
import org.ojalgo.commons.math3.linear.Access2DWrapper;

import java.util.List;

/**
 * Likelihood matrix between a set of alleles and evidence.
 * @param <A> the allele-type.
 */
public interface LikelihoodMatrix<EVIDENCE,A extends Allele> extends AlleleList<A> {

    /**
     * List of evidence in the matrix sorted by their index therein.
     * @return never {@code null}.
     */
    List<EVIDENCE> evidence();

    /**
     * List of alleles in the matrix sorted by their index in the collection.
     * @return never {@code null}.
     */
    List<A> alleles();

    /**
     * Set the likelihood of a unit of evidence given an allele through their indices.
     *
     * @param alleleIndex the target allele index.
     * @param evidenceIndex the target evidence index.
     * @param value new likelihood value for the target evidence give the target allele.
     *
     * @throws IllegalArgumentException if {@code alleleIndex} or {@code evidenceIndex}
     *  are not valid allele and evidence indices respectively.
     */
    void set(final int alleleIndex, final int evidenceIndex, final double value);

    /**
     * Returns the likelihood of a unit of evidence given a haplotype.
     *
     * @param alleleIndex the index of the given haplotype.
     * @param evidenceIndex the index of the target evidence.
     *
     * @throws IllegalArgumentException if {@code alleleIndex} or {@code evidenceIndex} is not a
     * valid allele or evidence index respectively.
     *
     * @return the requested likelihood, whatever value was provided using {@link #set(int,int,double) set}
     *    or 0.0 if none was set.
     */
    double get(final int alleleIndex, final int evidenceIndex);

    /**
     * Queries the index of an allele in the matrix.
     *
     * @param allele the target allele.
     *
     * @throws IllegalArgumentException if {@code allele} is {@code null}.
     * @return -1 if such allele does not exist, otherwise its index which 0 or greater.
     */
    @Override
    int indexOfAllele(final Allele allele);

    /**
     * Queries the index of a unit of evidence in the matrix.
     *
     * @param evidence the target evidence.
     *
     * @throws IllegalArgumentException if {@code evidence} is {@code null}.
     *
     * @return -1 if there is not such a evidence in the matrix, otherwise its index
     *    which is 0 or greater.
     */
    int indexOfEvidence(final EVIDENCE evidence);

    /**
     * Number of allele in the matrix.
     * @return never negative.
     */
    @Override
    int numberOfAlleles();

    /**
     * Count of evidence in the matrix.
     * @return never negative.
     */
    int evidenceCount();

    /**
     * Returns the allele given its index.
     *
     * @param alleleIndex the target allele index.
     *
     * @throws IllegalArgumentException if {@code alleleIndex} is not a valid allele index.
     * @return never {@code null}.
     */
    @Override
    A getAllele(final int alleleIndex);

    /**
     * Returns the allele given its index.
     *
     * @param evidenceIndex the target allele index.
     *
     * @throws IllegalArgumentException if {@code evidenceIndex} is not a valid evidence index.
     * @return never {@code null}.
     */
    EVIDENCE getEvidence(final int evidenceIndex);


    /**
     * Copies the likelihood of all the evidence for a given allele into an array from a particular offset.
     * @param alleleIndex the targeted allele
     * @param dest the destination array.
     * @param offset the copy offset within the destination allele
     */
    void copyAlleleLikelihoods(final int alleleIndex, final double[] dest, final int offset);

    /**
     * Returns this matrix as a {@link RealMatrix}.
     * <p>
     *     Changes in the return matrix may affect the content of this likelihoods matrix.
     * </p>
     * @return never {@code null}.
     */
    default RealMatrix asRealMatrix() {
        return Access2DWrapper.of(new Access2D<Number>() {
            @Override
            public double doubleValue(long row, long col) {
                return LikelihoodMatrix.this.get((int) row, (int) col);
            }

            @Override
            public Number get(long row, long col) {
                return LikelihoodMatrix.this.get((int) row, (int) col);
            }

            @Override
            public long countColumns() {
                return evidenceCount();
            }

            @Override
            public long countRows() {
                return numberOfAlleles();
            }
        });
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值