Example #1
0
def add_info_to_dict(data_dict, cpg_key='CpG'):

    annotations_keys = [
        'CHR', 'MAPINFO', 'UCSC_REFGENE_NAME', 'UCSC_REFGENE_GROUP',
        'RELATION_TO_UCSC_CPG_ISLAND'
    ]
    annotations_dict = load_annotations_dict()

    for key in annotations_keys:
        data_dict[key] = []

    for cpg in data_dict[cpg_key]:
        for key in annotations_keys:
            data_dict[key].append(annotations_dict[key][cpg])

    reject, pvals_corr, alphacSidak, alphacBonf = multipletests(
        data_dict['Sex_P.Value'], 0.05, method='fdr_bh')
    data_dict['Sex_P.Value_fdr_bh'] = pvals_corr

    reject, pvals_corr, alphacSidak, alphacBonf = multipletests(
        data_dict['Sex_P.Value'], 0.05, method='bonferroni')
    data_dict['Sex_P.Value_bf'] = pvals_corr

    reject, pvals_corr, alphacSidak, alphacBonf = multipletests(
        data_dict['Age_P.Value'], 0.05, method='fdr_bh')
    data_dict['Age_P.Value_fdr_bh'] = pvals_corr

    reject, pvals_corr, alphacSidak, alphacBonf = multipletests(
        data_dict['Age_P.Value'], 0.05, method='bonferroni')
    data_dict['Age_P.Value_bf'] = pvals_corr

    return data_dict
def get_cpg_dataset_save_dicts(sets, data_dicts, cpg_dicts, key='item'):

    annotations_keys = [
        'CHR', 'MAPINFO', 'UCSC_REFGENE_NAME', 'UCSC_REFGENE_GROUP',
        'RELATION_TO_UCSC_CPG_ISLAND'
    ]
    papers_keys = ['inoshita', 'singmann', 'yousefi']
    annotations_dict = load_annotations_dict()
    papers_dict = load_papers_dict()

    save_dicts = {}

    for set_key in sets:

        save_dicts[set_key] = {}

        for metrics_key in [key] + annotations_keys + papers_keys:
            save_dicts[set_key][metrics_key] = []

        curr_datasets = set_key.split('_')
        for dataset in curr_datasets:
            for ds_key in data_dicts[dataset]:
                if ds_key not in save_dicts[set_key]:
                    save_dicts[set_key][ds_key + '_' + dataset] = []

        for cpg in sets[set_key]:
            save_dicts[set_key][key].append(cpg)
            for dataset in curr_datasets:
                for ds_key in data_dicts[dataset]:
                    if ds_key not in save_dicts[set_key]:
                        save_dicts[set_key][ds_key + '_' + dataset].append(
                            data_dicts[dataset][ds_key][cpg_dicts[dataset]
                                                        [cpg]])
            for ann_key in annotations_keys:
                save_dicts[set_key][ann_key].append(
                    annotations_dict[ann_key][cpg])
            for paper_key in papers_keys:
                if cpg in papers_dict[paper_key]:
                    save_dicts[set_key][paper_key].append(1)
                else:
                    save_dicts[set_key][paper_key].append(0)

    return save_dicts
def add_chars_to_dict(data_dict, item_key='item'):

    annotations_keys = [
        'CHR', 'MAPINFO', 'UCSC_REFGENE_NAME', 'UCSC_REFGENE_GROUP',
        'RELATION_TO_UCSC_CPG_ISLAND'
    ]
    papers_keys = ['inoshita', 'singmann', 'yousefi']
    annotations_dict = load_annotations_dict()
    papers_dict = load_papers_dict()

    add_keys = annotations_keys + papers_keys
    for key in add_keys:
        data_dict[key] = []

    for item in data_dict[item_key]:

        for paper_key in papers_keys:
            if item in papers_dict[paper_key]:
                data_dict[paper_key].append(1)
            else:
                data_dict[paper_key].append(0)

        for ann_key in annotations_keys:
            data_dict[ann_key].append(annotations_dict[ann_key][item])
Example #4
0
papers_keys = ['inoshita', 'singmann', 'yousefi']

path = 'E:/YandexDisk/Work/pydnameth/draft/fixes/materials_and_methods/update_4_bonferroni'

data_dicts_passed = {}
cpgs_dicts_passed = {}
R2s = {}
R2_percentiles = {}

data_dict = load_table_dict_xlsx(f'{path}/{name}.xlsx')

for key in annotations_keys:
    data_dict[key] = []
for key in papers_keys:
    data_dict[key] = []

annotations_dict = load_annotations_dict()
papers_dict = load_papers_dict()

for cpg in tqdm(data_dict[cpg_key], desc=f'intersection processing'):
    for key in annotations_keys:
        data_dict[key].append(annotations_dict[key][cpg])

    for paper_key in papers_keys:
        if cpg in papers_dict[paper_key]:
            data_dict[paper_key].append(1)
        else:
            data_dict[paper_key].append(0)

save_table_dict_xlsx(f'{path}/{name}_with_added_info', data_dict)