コード例 #1
0
ファイル: mutation.py プロジェクト: kinkalow/paplot
def genes_list(colmun, colmun_f, colmun_id, funcs, id_list, config):

    import paplot.subcode.tools as tools
    import paplot.convert as convert

    sept = tools.config_getstr(config, "result_format_mutation", "sept_gene")

    genes_di = {}
    ids_di = {}

    for i in range(len(colmun)):
        if (colmun_f[i] in funcs) is False:
            continue

        row = colmun[i].replace('"', '')
        splt = []
        if sept == "":
            splt.append(row)
        else:
            splt = row.split(sept)

        for gene in splt:
            if gene == "":
                continue
            if gene in ids_di.keys():
                if (colmun_id[i] in ids_di[gene]) is True:
                    continue
                else:
                    ids_di[gene].append(colmun_id[i])
            else:
                ids_di.update({gene: [colmun_id[i]]})

            value = 1
            if gene in genes_di.keys():
                value = genes_di[gene] + 1
            genes_di.update({gene: value})

    # gene list
    use_gene_rate = config.getfloat("mutation", "use_gene_rate")
    limited_list = convert.text_to_list(
        tools.config_getstr(config, "mutation", "limited_gene"), ",")
    nouse_list = convert.text_to_list(
        tools.config_getstr(config, "mutation", "nouse_gene"), ",")

    genes = []
    for key in genes_di:
        if len(limited_list) > 0 and convert.fnmatch_list(
                key, limited_list) is False:
            continue
        if convert.fnmatch_list(key, nouse_list):
            continue
        if genes_di[key] < float(len(id_list)) * use_gene_rate:
            continue

        genes.append(key)

    genes.sort()
    return genes
コード例 #2
0
ファイル: mut.py プロジェクト: Genomon-Project/paplot
def genes_list(colmun, colmun_f, colmun_id, funcs, Ids, config):
    
    import paplot.subcode.tools as tools
    import paplot.convert as convert
    
    sept = tools.config_getstr(config, "result_format_mutation", "sept_gene")
    use_gene_rate = config.getfloat("mut", "use_gene_rate")
    
    limited_list = convert.text_to_list(tools.config_getstr(config, "mut", "limited_genes"), ",")
    nouse_list = convert.text_to_list(tools.config_getstr(config, "mut", "nouse_genes"), ",")
    
    genes_di = {}
    ids_di = {}
    
    for i in range(len(colmun)):
        if (colmun_f[i] in funcs) == False: continue
        
        row = colmun[i].replace('"', '')
        splt = []
        if sept == "": splt.append(row)
        else: splt = row.split(sept)
        
        for gene in splt:
            if gene == "": continue
            if gene in ids_di.keys():
                if (colmun_id[i] in ids_di[gene]) == True: continue
                else: ids_di[gene].append(colmun_id[i])
            else:
                ids_di.update({gene: [colmun_id[i]]})
            
            value = 1            
            if gene in genes_di.keys():
                value = genes_di[gene] + 1
            genes_di.update({gene: value})
            
    # gene list
    genes = []
    for key in genes_di:
        if len(limited_list) > 0:
            if (key in limited_list) == False: continue   
        if key in nouse_list: continue
        if genes_di[key] < float(len(Ids))*use_gene_rate: continue

        genes.append(key)

    genes.sort()
    return genes
コード例 #3
0
ファイル: mutation.py プロジェクト: ken0-1n/paplot
def load_subdata(ids, sec, config):
    import os
    import paplot.subcode.tools as tools
    import paplot.convert as convert
    import paplot.color as color

    input_file = tools.config_getpath(config, sec, "path", default = "")
    if os.path.exists(input_file) == False:
        print ("[ERROR] file is not exist. %s" % input_file)
        return None

    sept = tools.config_getstr(config, sec, "sept").replace("\\t", "\t").replace("\\n", "\n").replace("\\r", "\r")
    mode = tools.config_getstr(config, sec, "mode")
    comment = tools.config_getstr(config, sec, "comment")
    title = tools.config_getstr(config, sec, "title")
    
    label = []
    item = []
    colors_n_di = {}
    colors_h_di = {}
    for name_set in tools.config_getstr(config, sec, "name_set").split(","):
        name_set_split = convert.text_to_list(name_set, ":")
        for i in range(len(name_set_split)):
            text = name_set_split[i]
            if i == 0:
                item.append(text)
                if len(name_set_split) == 1:
                    label.append(text)
            elif i == 1:
                label.append(text)
            elif i == 2:
                colors_n_di[name_set_split[0]] = color.name_to_value(text)
            elif i == 3:
                colors_h_di[name_set_split[0]] = color.name_to_value(text)
    
    # fill in undefined items
    colors_n_di = color.create_color_dict(item, colors_n_di, color.osaka_subway_colors) 
    colors_h_di2 = {}
    for key in colors_n_di:
        if key in colors_h_di: continue
        colors_h_di2[key] = color.saturation_down(colors_n_di[key])
    
    # dict to value
    colors_n = []
    for key in item:
        colors_n.append(colors_n_di[key])
    
    if mode == "range":
        item.remove(item[0])
    
    header = []
    if tools.config_getboolean(config, sec, "header") == True:
        pos_value = -1
        pos_id = -1
    else:
        pos_value = tools.config_getint(config, sec, "col_value")-1
        pos_id = tools.config_getint(config, sec, "col_ID")-1
        header = ["",""]
    
    # copy id_list for find check
    unlookup = []
    for iid in ids:
        unlookup.append(iid)
        
    # read
    data_text = ""
    values = []
    for line in open(input_file):
        line = line.strip()
        if len(line.replace(sept, "")) == 0:
            continue
        
        if comment != "" and line.find(comment) == 0:
            continue
        
        if len(header) == 0:
            header = convert.text_to_list(line,sept)
            try:
                colname = tools.config_getstr(config, sec, "col_value")
                pos_value = header.index(colname)
                colname = tools.config_getstr(config, sec, "col_ID")
                pos_id = header.index(colname)
            except Exception as e:
                print(e.message)
                return None
                
            continue
        
        cols = convert.text_to_list(line,sept)
        if (cols[pos_id] in ids) == False: continue
        else: unlookup.remove(cols[pos_id])

        id_pos = ids.index(cols[pos_id])
        
        if mode == "fix":
            if cols[pos_value] in item:
                data_text += subdata_data_template.format(id = id_pos, item = item.index(cols[pos_value]))
            else:
                print("[" + sec + "] name_set: data is undefined." + cols[pos_value] + "\n")
                continue
        elif mode == "range" or mode == "gradient":
            try:
                values.append(float(cols[pos_value]))
            except Exception as e:
                print(colname + ": data type is invalid.\n" + e.message)
                continue
            
            data_text += subdata_data_template.format(id = id_pos, item = cols[pos_value])

    if len(unlookup) > 0:
        print("[WARNING] can't find IDs subplot data.")
        print(unlookup)
        
    if mode == "gradient" and len(values) > 0:
        item[0] = min(values)
        item[1] = max(values)
        
    return [data_text, item, colors_n, label, title] 
コード例 #4
0
ファイル: mutation.py プロジェクト: ken0-1n/paplot
def convert_tojs(input_file, output_file, positions, config):
    import os
    import paplot.subcode.data_frame as data_frame
    import paplot.subcode.merge as merge
    import paplot.subcode.tools as tools
    import paplot.convert as convert
    
    cols_di = merge.position_to_dict(positions)

    # data read
    try:
        df = data_frame.load_file(input_file, header = 1, \
            sept = tools.config_getstr(config, "result_format_mutation", "sept"), \
            comment = tools.config_getstr(config, "result_format_mutation", "comment") \
            )
    except Exception as e:
        print ("failure open data %s, %s" % (input_file, e.message))
        return None

    if len(df.data) == 0:
        print ("no data %s" % input_file)
        return None

    # func replace 
    for f in range(len(df.data)):
        func_pos = df.name_to_index(cols_di["group"])
        
        if df.data[f][func_pos] == "":
            df.data[f][func_pos] = "_blank_"
            
    [funcs, colors_n] = convert.group_list(df.column(cols_di["group"]), "mutation", "group", config)

    # ID list
    id_list = []
    for row in df.data:
        iid = row[df.name_to_index(cols_di["id"])]
        if iid != "": id_list.append(iid)
    id_list = list(set(id_list))
    id_list.sort()
    
    # gene list
    genes = genes_list(df.column(cols_di["gene"]), \
                        df.column(cols_di["group"]), \
                        df.column(cols_di["id"]), \
                        funcs, id_list, config)    

    option_keys = tools.dict_keys(cols_di)
    option_keys.remove("id")
    option_keys.remove("group")
    option_keys.remove("gene")
            
    # mutation list
    f = open(output_file, "w")
    f.write(js_header)
    f.write(js_mutations_1)

    mutations = {}
    tooltips = {}
    for row in df.data:
        iid = row[df.name_to_index(cols_di["id"])]
        if iid == "": continue
            
        if (iid in mutations) == False:
            mutations[iid] = {}
            tooltips[iid] = {}
                
        func_split = convert.text_to_list(row[df.name_to_index(cols_di["group"])], \
            tools.config_getstr(config, "result_format_mutation", "sept_group"))
        
        tooltip_items = []
        for k in range(len(option_keys)):
            key = option_keys[k]
            if cols_di[key] == "": continue
            tooltip_items.append(row[df.name_to_index(cols_di[key])])
            
        for func in func_split:
            if (func in mutations[iid]) == False:
                mutations[iid][func] = {}
                tooltips[iid][func] = {}

            gene_split = convert.text_to_list(row[df.name_to_index(cols_di["gene"])], \
                tools.config_getstr(config, "result_format_mutation", "sept_gene"))
                
            for gene in gene_split:
                if (gene in mutations[iid][func]) == False:
                    mutations[iid][func][gene] = 1
                    tooltips[iid][func][gene] = []
                else:
                    mutations[iid][func][gene] += 1

                tooltips[iid][func][gene].append(tooltip_items)

    mutations_sum = 0
    for iid in tools.dict_keys(mutations):
        for func in tools.dict_keys(mutations[iid]):
            for gene in tools.dict_keys(mutations[iid][func]):
                idx_i = convert.value_to_index(id_list, iid, -1)
                idx_f = convert.value_to_index(funcs, func, -1)
                idx_g = convert.value_to_index(genes, gene, -1)

                if idx_i >= 0 and idx_f >= 0 and idx_g >= 0:
                    
                    tooltip_items = ""
                    for tips in tooltips[iid][func][gene]: 
                        tooltip_items += "[" + convert.list_to_text(tips) + "],"

                    f.write(mu_mutations_template.format(ID = idx_i, \
                        func = idx_f , \
                        gene = idx_g, \
                        num = mutations[iid][func][gene],
                        tooltip = tooltip_items))
                        
                    mutations_sum += mutations[iid][func][gene]
                    
    f.write(js_mutations_2.format(mutations_sum = mutations_sum))
    
    # write id, func, gene ... list
    f.write(js_dataset.format(
        Ids = convert.list_to_text(id_list), \
        genes = convert.list_to_text(convert.list_prohibition(genes)), \
        funcs = convert.list_to_text(convert.list_prohibition(funcs)), \
        func_colors_n = convert.list_to_text(colors_n), \
        mutation_header = convert.list_to_text(option_keys), \
        checker_title = convert.pyformat_to_jstooltip_text(cols_di, config, "mutation", "result_format_mutation", "tooltip_format_checker_title"), \
        checker_partial = convert.pyformat_to_jstooltip_text(cols_di, config, "mutation", "result_format_mutation", "tooltip_format_checker_partial"), \
        gene_title = convert.pyformat_to_jstooltip_text(cols_di, config, "mutation", "result_format_mutation", "tooltip_format_gene_title"), \
        gene_partial = convert.pyformat_to_jstooltip_text(cols_di, config, "mutation", "result_format_mutation", "tooltip_format_gene_partial"), \
        id_title = convert.pyformat_to_jstooltip_text(cols_di, config, "mutation", "result_format_mutation", "tooltip_format_id_title"), \
        id_partial = convert.pyformat_to_jstooltip_text(cols_di, config, "mutation", "result_format_mutation", "tooltip_format_id_partial"), \
    ))
    
    dataset = {}
    
    ##### subdata #####
    f.write(js_subdata_1)
    subdata = []
    counter = 0
    for sec in config.sections():
        if sec.startswith("mutation_subplot_type1_"):
            ret_val = load_subdata(id_list, sec, config)
            if ret_val == None: continue
            [data_text, item, colors_n, label, title] = ret_val
            
            name = "sub%d" % (counter)
            pos = 1
            counter += 1
            
        elif sec.startswith("mutation_subplot_type2_"):
            ret_val = load_subdata(id_list, sec, config)
            if ret_val == None: continue
            [data_text, item, colors_n, label, title] = ret_val
            
            name = "sub%d" % (counter)
            pos = 2
            counter += 1
            
        else: continue
    
        f.write(subdata_template.format(name = name, \
                title = title, \
                type = tools.config_getstr(config, sec, "mode"), \
                item = convert.list_to_text(item), \
                label = convert.list_to_text(label), \
                colors_n = convert.list_to_text(colors_n), \
                data = data_text ))

        subdata.append({"pos":pos, "label":label, "color":colors_n, "title": title})
         
    f.write(js_subdata_2)
    
    ##### functions #####
    f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/data_mutation.js")
    js_function = f_template.read()
    f_template.close()
    f.write(js_function)
    f.write(js_footer)

    f.close()

    dataset["subdata"] = subdata
    return dataset 
コード例 #5
0
def convert_tojs(input_file, output_file, positions, config):

    import os
    import paplot.subcode.data_frame as data_frame
    import paplot.subcode.merge as merge
    import paplot.subcode.tools as tools
    import paplot.convert as convert
    import paplot.color as color

    cols_di = merge.position_to_dict(positions)

    # data read
    try:
        df = data_frame.load_file(input_file, header = 1, \
            sept = tools.config_getstr(config, "result_format_qc", "sept"), \
            comment = tools.config_getstr(config, "result_format_qc", "comment") \
            )
    except Exception as e:
        print("failure open data %s, %s" % (input_file, e.message))
        return None

    if len(df.data) == 0:
        print("no data %s" % input_file)
        return None

    # chart list
    plots_text = ""
    plots_option = []

    config_sections = config.sections()
    config_sections.sort()
    if "qc_chart_brush" in config_sections:
        config_sections.remove("qc_chart_brush")
        config_sections.insert(0, "qc_chart_brush")

    for sec in config.sections():
        if not sec.startswith("qc_chart_"):
            continue

        chart_id = sec.replace("qc_chart_", "chart_")

        stack_id = []
        label = []
        colors_di = {}
        counter = 0
        for name_set in tools.config_getstr(config, sec,
                                            "name_set").split(","):
            name_set_split = convert.text_to_list(name_set, ":")
            if len(name_set_split) == 0:
                continue

            stack_id.append("stack" + str(counter))
            label.append(name_set_split[0])

            if len(name_set_split) > 1:
                colors_di[name_set_split[0]] = color.name_to_value(
                    name_set_split[1])
            counter += 1

        # fill in undefined items
        colors_di = color.create_color_dict(label, colors_di,
                                            color.metro_colors)

        # dict to value
        colors_li = []
        for key in label:
            colors_li.append(colors_di[key])

        plots_text += plot_template.format(
            chart_id = chart_id, \
            title = tools.config_getstr(config, sec, "title"), \
            title_y = tools.config_getstr(config, sec, "title_y"), \
            stack = convert.pyformat_to_jstooltip_text(cols_di, config, sec, "result_format_qc", "stack"), \
            stack_id = convert.list_to_text(stack_id), \
            label = convert.list_to_text(label), \
            color = convert.list_to_text(colors_li), \
            tooltip = convert.pyformat_to_jstooltip_text(cols_di, config, sec, "result_format_qc", "tooltip_format"), \
            )
        plots_option.append(chart_id)

    # ID list
    id_list = []
    for row in df.data:
        iid = row[df.name_to_index(cols_di["id"])]
        if iid != "": id_list.append(iid)
    id_list = list(set(id_list))
    id_list.sort()

    # header
    headers = tools.dict_keys(cols_di)

    f = open(output_file, "w")
    f.write(js_header)
    f.write(js_dataset.format(IDs = convert.list_to_text(id_list), \
                            header = convert.list_to_text(headers), \
                            plots = plots_text))
    f.write(js_data1)

    # values
    for row in df.data:
        iid = row[df.name_to_index(cols_di["id"])]
        if iid == "": continue

        values = ""
        for item in headers:
            if len(values) > 0:
                values += ","
            val = row[df.name_to_index(cols_di[item])]
            if type(val) == type(""):
                values += "'" + val + "'"
            elif type(val) == type(0.0):
                values += str('%.2f' % val)
            else:
                values += str(val)

        f.write("[" + values + "],")

    f.write(js_data2)

    f_template = open(
        os.path.dirname(os.path.abspath(__file__)) + "/templates/data_qc.js")
    js_function = f_template.read()
    f_template.close()
    f.write(js_function)
    f.write(js_footer)

    f.close()

    return {"plots": plots_option}
コード例 #6
0
ファイル: qc.py プロジェクト: Genomon-Project/paplot
def convert_tojs(input_file, output_file, positions, config):

    import paplot.subcode.data_frame as data_frame
    import paplot.subcode.merge as merge
    import paplot.subcode.tools as tools
    import paplot.convert as convert
    import paplot.color as color
    
    cols_di = merge.position_to_dict(positions)

    # data read
    try:
        df = data_frame.load_file(input_file, header = 1, \
            sept = tools.config_getstr(config, "merge_format_qc", "sept"), \
            comment = tools.config_getstr(config, "result_format_qc", "comment") \
            )
    except Exception as e:
        print ("failure open data %s, %s" % (input_file, e.message))
        return None

    if len(df.data) == 0:
        print ("no data %s" % input_file)
        return None

    # chart list
    plots_text = ""
    plots_option = []
    
    config_sections = config.sections()
    config_sections.sort()
    if "qc_chart_brush" in config_sections:
        config_sections.remove("qc_chart_brush")
        config_sections.insert(0, "qc_chart_brush")
        
    for sec in config.sections():
        if not sec.startswith("qc_chart_"):
            continue
        
        chart_id = sec.replace("qc_chart_", "chart_")
        
        stack_id = []
        label = []
        colors_di = {}
        counter = 0
        for name_set in tools.config_getstr(config, sec, "name_set").split(","):
            name_set_split = convert.text_to_list(name_set, ":")
            if len(name_set_split) == 0:
                continue
            
            stack_id.append("stack" + str(counter))
            label.append(name_set_split[0])
            
            if len(name_set_split) > 1:
                colors_di[name_set_split[0]] = color.name_to_value(name_set_split[1])
            counter += 1
            
        # fill in undefined items
        colors_di = color.create_color_dict(label, colors_di, color.metro_colors) 
        
        # dict to value
        colors_li = []
        for key in label:
            colors_li.append(colors_di[key])
        
        plots_text += plot_template.format(
            chart_id = chart_id, \
            title = tools.config_getstr(config, sec, "title"), \
            title_y = tools.config_getstr(config, sec, "title_y"), \
            stack = convert.pyformat_to_jstooltip_text(cols_di, config, sec, "result_format_qc", "stack"), \
            stack_id = convert.list_to_text(stack_id), \
            label = convert.list_to_text(label), \
            color = convert.list_to_text(colors_li), \
            tooltip = convert.pyformat_to_jstooltip_text(cols_di, config, sec, "result_format_qc", "tooltip_format"), \
            )
        plots_option.append(chart_id)
    
    # ID list
    Ids = []
    for row in df.data:
        iid = row[df.name_to_index(cols_di["id"])]
        if iid != "": Ids.append(iid)
    Ids = list(set(Ids))
    Ids.sort()
    
    # header 
    headers = cols_di.keys()
    headers.sort()
    
    f = open(output_file, "w")
    f.write(js_header)
    f.write(js_dataset.format(IDs = convert.list_to_text(Ids), \
                            header = convert.list_to_text(headers), \
                            plots = plots_text))    
    f.write(js_data1)
                        
    # values
    for row in df.data:
        iid = row[df.name_to_index(cols_di["id"])]
        if iid == "": continue
            
        values = ""
        for item in headers:
            if len(values) > 0:
                values += ","
            val = row[df.name_to_index(cols_di[item])]
            if type(val) == type(""):
                values += "'" + val + "'"
            elif type(val) == type(0.0):
                values += str('%.2f' % val)
            else:
                values += str(val)
        
        f.write("[" + values + "],")

    f.write(js_data2)
    f.write(js_function)
    f.close()
    
    return {"plots": plots_option}
コード例 #7
0
ファイル: mut.py プロジェクト: Genomon-Project/paplot
def load_subdata(ids, sec, config):
    import os
    import paplot.subcode.tools as tools
    import paplot.convert as convert
    import paplot.color as color

    input_file = tools.config_getpath(config, sec, "path", default = "../../example/sample_summary.csv")
    if os.path.exists(input_file) == False:
        print ("[ERROR] file is not exist. %s" % input_file)
        return None

    sept = tools.config_getstr(config, sec, "sept")
    mode = tools.config_getstr(config, sec, "mode")
    comment = tools.config_getstr(config, sec, "comment")
    title = tools.config_getstr(config, sec, "title")
    
    label = []
    item = []
    colors_n_di = {}
    colors_h_di = {}
    for name_set in tools.config_getstr(config, sec, "name_set").split(","):
        name_set_split = convert.text_to_list(name_set, ":")
        for i in range(len(name_set_split)):
            text = name_set_split[i]
            if i == 0:
                item.append(text)
                if len(name_set_split) == 1:
                    label.append(text)
            elif i == 1:
                label.append(text)
            elif i == 2:
                colors_n_di[name_set_split[0]] = color.name_to_value(text)
            elif i == 3:
                colors_h_di[name_set_split[0]] = color.name_to_value(text)
    
    # fill in undefined items
    colors_n_di = color.create_color_dict(item, colors_n_di, color.osaka_subway_colors) 
    colors_h_di2 = {}
    for key in colors_n_di:
        if colors_h_di.has_key(key): continue
        colors_h_di2[key] = color.Saturation_down(colors_n_di[key])
    
    # dict to value
    colors_n = []
    for key in item:
        colors_n.append(colors_n_di[key])
    
    if mode == "range":
        item.remove(item[0])
    
    header = []
    if tools.config_getboolean(config, sec, "header") == True:
        pos_value = -1
        pos_ID = -1
    else:
        pos_value = tools.config_getint(config, sec, "col_value")
        pos_ID = tools.config_getint(config, sec, "col_ID")
        header = ["",""]
    
    # copy Ids for find check
    unlookup = []
    for iid in ids:
        unlookup.append(iid)
        
    # read
    data_text = ""
    values = []
    for line in open(input_file):
        line = line.strip()
        if len(line.replace(sept, "")) == 0:
            continue
        
        if comment != "" and line.find(comment) == 0:
            continue
        
        if len(header) == 0:
            header = convert.text_to_list(line,sept)
            try:
                colname = tools.config_getstr(config, sec, "col_value")
                pos_value = header.index(colname)
                colname = tools.config_getstr(config, sec, "col_ID")
                pos_ID = header.index(colname)
            except Exception as e:
                print(e.message)
                return None
                
            continue
        
        cols = convert.text_to_list(line,sept)
        if (cols[pos_ID] in ids) == False: continue
        else: unlookup.remove(cols[pos_ID])

        id_pos = ids.index(cols[pos_ID])
        
        if mode == "fix":
            if cols[pos_value] in item:
                data_text += subdata_data_template.format(id = id_pos, item = item.index(cols[pos_value]))
            else:
                print("[" + sec + "] name_set: data is undefined." + cols[pos_value] + "\n")
                continue
        elif mode == "range":
            try:
                values.append(float(cols[pos_value]))
            except Exception as e:
                print(colname + ": data type is invalid.\n" + e.message)
                continue
            
            data_text += subdata_data_template.format(id = id_pos, item = cols[pos_value])
            
        elif mode == "gradient":
            try:
                values.append(float(cols[pos_value]))
            except Exception as e:
                print(colname + ": data type is invalid.\n" + e.message)
                continue
            
            data_text += subdata_data_template.format(id = id_pos, item = cols[pos_value])
    
    if len(unlookup) > 0:
        print("[WARNING] can't find IDs subplot data.")
        print(unlookup)
        
    if mode == "gradient" and len(values) > 0:
        item[0] = min(values)
        item[1] = max(values)
        
    return [data_text, item, colors_n, label, title] 
コード例 #8
0
ファイル: mut.py プロジェクト: Genomon-Project/paplot
def convert_tojs(input_file, output_file, positions, config):
    
    import paplot.subcode.data_frame as data_frame
    import paplot.subcode.merge as merge
    import paplot.subcode.tools as tools
    import paplot.convert as convert
    
    cols_di = merge.position_to_dict(positions)

    # data read
    try:
        df = data_frame.load_file(input_file, header = 1, \
            sept = tools.config_getstr(config, "merge_format_mutation", "sept"), \
            comment = tools.config_getstr(config, "result_format_mutation", "comment") \
            )
    except Exception as e:
        print ("failure open data %s, %s" % (input_file, e.message))
        return None

    if len(df.data) == 0:
        print ("no data %s" % input_file)
        return None

    # func replace 
    for f in range(len(df.data)):
        func_pos = df.name_to_index(cols_di["func"])
        func = df.data[f][func_pos]
        df.data[f][func_pos] = func.replace(" ", "_")
        if func == "":
            df.data[f][func_pos] = "_blank_"

    [funcs, colors_n] = convert.group_list(df.column(cols_di["func"]), "mut", "func", config)

    # ID list
    Ids = []
    for row in df.data:
        iid = row[df.name_to_index(cols_di["id"])]
        if iid != "": Ids.append(iid)
    Ids = list(set(Ids))
    Ids.sort()
    
    genes = genes_list(df.column(cols_di["gene"]), \
                        df.column(cols_di["func"]), \
                        df.column(cols_di["id"]), \
                        funcs, Ids, config)    

    option_keys = cols_di.keys()
    option_keys.remove("id")
    option_keys.remove("func")
    option_keys.remove("gene")
            
    f = open(output_file, "w")
    f.write(js_header \
        + js_dataset.format(Ids = convert.list_to_text(Ids), \
            genes = convert.list_to_text(genes), \
            funcs = convert.list_to_text(funcs), \
            func_colors_n = convert.list_to_text(colors_n), \
            mutation_header = convert.list_to_text(option_keys), \
            checker_title = convert.pyformat_to_jstooltip_text(cols_di, config, "mut", "result_format_mutation", "tooltip_format_checker_title"), \
            checker_partial = convert.pyformat_to_jstooltip_text(cols_di, config, "mut", "result_format_mutation", "tooltip_format_checker_partial"), \
            gene_title = convert.pyformat_to_jstooltip_text(cols_di, config, "mut", "result_format_mutation", "tooltip_format_gene_title"), \
            gene_partial = convert.pyformat_to_jstooltip_text(cols_di, config, "mut", "result_format_mutation", "tooltip_format_gene_partial"), \
            id_title = convert.pyformat_to_jstooltip_text(cols_di, config, "mut", "result_format_mutation", "tooltip_format_id_title"), \
            id_partial = convert.pyformat_to_jstooltip_text(cols_di, config, "mut", "result_format_mutation", "tooltip_format_id_partial"), \
            ))
            
    # mutation list
    f.write(js_mutations_1)

    mutations = {}
    tooltips = {}
    for row in df.data:
        iid = row[df.name_to_index(cols_di["id"])]
        if iid == "": continue
            
        if (iid in mutations) == False:
            mutations[iid] = {}
            tooltips[iid] = {}
                
        func_split = convert.text_to_list(row[df.name_to_index(cols_di["func"])], \
                                tools.config_getstr(config, "result_format_mutation", "sept_func"))
                                
        tooltip_items = []
        for k in range(len(option_keys)):
            key = option_keys[k]
            if cols_di[key] == "": continue
            tooltip_items.append(row[df.name_to_index(cols_di[key])])
            
        for func in func_split:
            if (func in mutations[iid]) == False:
                mutations[iid][func] = {}
                tooltips[iid][func] = {}

            gene_split = convert.text_to_list(row[df.name_to_index(cols_di["gene"])], \
                                tools.config_getstr(config, "result_format_mutation", "sept_gene"))
            for gene in gene_split:
                if (gene in mutations[iid][func]) == False:
                    mutations[iid][func][gene] = 1
                    tooltips[iid][func][gene] = []
                else:
                    mutations[iid][func][gene] += 1

                tooltips[iid][func][gene].append(tooltip_items)

    mutations_sum = 0
    for iid in mutations:
        for func in mutations[iid]:
            for gene in mutations[iid][func]:
                idx_i = convert.value_to_index(Ids, iid, -1)
                idx_f = convert.value_to_index(funcs, func, -1)
                idx_g = convert.value_to_index(genes, gene, -1)

                if idx_i >= 0 and idx_f >= 0 and idx_g >= 0:
                    
                    tooltip_items = ""
                    for tips in tooltips[iid][func][gene]: 
                        tooltip_items += "[" + convert.list_to_text(tips) + "],"

                    f.write(mu_mutations_template.format(ID = idx_i, \
                        func = idx_f , \
                        gene = idx_g, \
                        num = mutations[iid][func][gene],
                        tooltip = tooltip_items))
                        
                    mutations_sum += mutations[iid][func][gene]
                    
    f.write(js_mutations_2.format(mutations_sum = mutations_sum))
    
    dataset = {"func":funcs, "color":colors_n}
    
    ##### subdata #####
    f.write(js_subdata_1)
    subdata = []
    counter = 0
    for sec in config.sections():
        if sec.startswith("mut_subplot_type1_"):
            ret_val = load_subdata(Ids, sec, config)
            if ret_val == None: continue
            [data_text, item, colors_n, label, title] = ret_val
            
            name = "sub%d" % (counter)
            pos = 1
            counter += 1
            
        elif sec.startswith("mut_subplot_type2_"):
            ret_val = load_subdata(Ids, sec, config)
            if ret_val == None: continue
            [data_text, item, colors_n, label, title] = ret_val
            
            name = "sub%d" % (counter)
            pos = 2
            counter += 1
            
        else: continue
    
        f.write(subdata_template.format(name = name, \
                title = title, \
                type = tools.config_getstr(config, sec, "mode"), \
                item = convert.list_to_text(item), \
                label = convert.list_to_text(label), \
                colors_n = convert.list_to_text(colors_n), \
                data = data_text ))

        subdata.append({"pos":pos, "label":label, "color":colors_n, "title": title})
         
    f.write(js_subdata_2)
    
    ##### functions #####
    f.write(js_function)
    f.close()

    dataset["subdata"] = subdata
    return dataset