def get_qtls_from_rqtl_data(matrix, lod_threshold):
    """ Retrieve the list of significants QTLs for the given input
    matrix and using the specified LOD threshold.
    This assumes one QTL per linkage group.

    :arg matrix, the MapQTL file read in memory
    :arg threshold, threshold used to determine if a given LOD value is
        reflective the presence of a QTL.

    """
    t_matrix = list(zip(*matrix))
    qtls = [['Trait', 'Linkage Group', 'Position', 'Exact marker', 'LOD']]
    # row 0: markers
    # row 1: chr
    # row 2: pos
    for row in t_matrix[3:]:
        lgroup = None
        max_lod = None
        peak = None
        cnt = 1
        while cnt < len(row):
            if lgroup is None:
                lgroup = t_matrix[1][cnt]

            if lgroup == t_matrix[1][cnt]:
                if max_lod is None:
                    max_lod = float(row[cnt])
                if float(row[cnt]) > float(max_lod):
                    max_lod = float(row[cnt])
                    peak = cnt
            else:
                if max_lod \
                        and float(max_lod) > float(lod_threshold) \
                        and peak:
                    qtl = [row[0],             # trait
                           t_matrix[1][peak],  # LG
                           t_matrix[2][peak],  # pos
                           t_matrix[0][peak],  # marker
                           max_lod,            # LOD value
                           ]
                    qtls.append(qtl)
                lgroup = None
                max_lod = None
                peak = cnt
            cnt = cnt + 1
    return qtls
def get_qtls_from_rqtl_data ( matrix , lod_threshold ) : t_matrix = list ( zip ( * matrix ) ) qtls = [ [ 'Trait' , 'Linkage Group' , 'Position' , 'Exact marker' , 'LOD' ] ] for row in t_matrix [ 3 : ] : lgroup = None max_lod = None peak = None cnt = 1 while cnt < len ( row ) : if lgroup is None : lgroup = t_matrix [ 1 ] [ cnt ] if lgroup == t_matrix [ 1 ] [ cnt ] : if max_lod is None : max_lod = float ( row [ cnt ] ) if float ( row [ cnt ] ) > float ( max_lod ) : max_lod = float ( row [ cnt ] ) peak = cnt else : if max_lod and float ( max_lod ) > float ( lod_threshold ) and peak : qtl = [ row [ 0 ] , t_matrix [ 1 ] [ peak ] , t_matrix [ 2 ] [ peak ] , t_matrix [ 0 ] [ peak ] , max_lod , ] qtls . append ( qtl ) lgroup = None max_lod = None peak = cnt cnt = cnt + 1 return qtls
Retrieve the list of significants QTLs for the given input
    matrix and using the specified LOD threshold.
    This assumes one QTL per linkage group.

    :arg matrix, the MapQTL file read in memory
    :arg threshold, threshold used to determine if a given LOD value is
        reflective the presence of a QTL.