<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scan(phenotype, X, G=None, K=None, covariates=None, progress=True, options=None):
 """Association between genetic variants and phenotype. Matrix `X` shall contain the genetic markers (e.g., number of minor alleles) with rows and columns representing samples and genetic markers, respectively. The user must specify only one of the parameters `G` and `K` for defining the genetic background. Let :math:`N` be the sample size, :math:`S` the number of covariates, :math:`P_c` the number of genetic markers to be tested, and :math:`P_b` the number of genetic markers used for Kinship estimation. Args: y (array_like):
 Phenotype. Dimension (:math:`N\\times 0`). X (array_like):
 Candidate genetic markers (or any other type of explanatory variable) whose association with the phenotype will be tested. Dimension (:math:`N\\times P_c`). G (array_like):
 Genetic markers matrix used internally for kinship estimation. Dimension (:math:`N\\times P_b`). K (array_like):
 Kinship matrix. Dimension (:math:`N\\times N`). covariates (array_like):
 Covariates. Default is an offset. Dimension (:math:`N\\times S`). progress (bool) : Shows progress. Defaults to `True`. Returns: A :class:`lim.genetics.qtl._canonical.CanonicalLRTScan` instance. """

    logger = logging.getLogger(__name__)
    logger.info('%s association scan has started.', phenotype.likelihood_name)

    if options is None:
        options = dict()

    if 'fast' not in options:
        options['fast'] = True

    if 'rank_norm' not in options:
        options['rank_norm'] = True

    n = phenotype.sample_size
    covariates = ones((n, 1)) if covariates is None else covariates

    X = _clone(X)
    G = _clone(G)
    K = _clone(K)

    if not is_all_finite(X):
        raise ValueError("The candidate matrix X has non-finite values.")

    if G is not None and not is_all_finite(G):
        raise ValueError("The genetic markers matrix G has non-finite values.")

    if K is not None and not is_all_finite(K):
        raise ValueError("The Kinship matrix K has non-finite values.")

    background = Background()

    (Q0, Q1, S0) = _genetic_preprocess(X, G, K, background)
    qtl = QTLScan(phenotype, covariates, X, Q0, Q1, S0, options)
    qtl.progress = progress
    qtl.compute_statistics()

    return qtl