def removeZeros(infile, outfile, prop=0.5, genecols=2):
    """Remove lines from `infile' in which the proportion of zeros is equal to or higher than `prop'. `genecols' is the number of columns containing gene identifiers at the beginning of each row. Writes filtered lines to `outfile'."""
    nin = 0
    nout = 0
    with open(infile, "r") as f:
        hdr = f.readline()
        columns = hdr.split("\t")
        ncols = len(columns)-genecols
        maxzeros = ncols*prop
        with open(outfile, "w") as out:
            out.write(hdr)
            while True:
                line = f.readline()
                if line == '':
                    break
                nin += 1
                pline = line.rstrip("\r\n").split("\t")
                nzeros = 0
                for v in pline[genecols:]:
                    if float(v) == 0:
                        nzeros += 1
                if nzeros < maxzeros:
                    out.write(line)
                    nout += 1
    return (nin, nout)