Exemplo n.º 1
0
def betas_adj_table_approach_3(data, annotations, attributes, target_list,
                               data_params_list):
    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(data=DataType.betas_adj,
                                               task=Task.table,
                                               method=Method.aggregator,
                                               data_params=copy.deepcopy(
                                                   data_params_list[0])),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True)
    root = Node(name=str(config_root), config=config_root)

    for id, target in enumerate(target_list):
        attributes_common = copy.deepcopy(attributes)
        attributes_common.target = target
        config_common = Config(data=copy.deepcopy(data),
                               experiment=Experiment(
                                   data=DataType.betas_adj,
                                   task=Task.table,
                                   method=Method.oma,
                                   data_params=copy.deepcopy(
                                       data_params_list[id])),
                               annotations=copy.deepcopy(annotations),
                               attributes=attributes_common,
                               is_run=True,
                               is_root=False)
        Node(name=str(config_common), config=config_common, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 2
0
def cpg_proc_clock_linreg_dev(data,
                              annotations,
                              attributes,
                              child_method=Method.linreg,
                              params=None):
    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(type=DataType.cpg,
                                               task=Task.clock,
                                               method=Method.linreg,
                                               params=copy.deepcopy(params)),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True)
    root = Node(name=str(config_root), config=config_root)

    config_child = Config(data=copy.deepcopy(data),
                          experiment=Experiment(
                              type=DataType.cpg,
                              task=Task.table,
                              method=copy.deepcopy(child_method),
                              params={}),
                          annotations=copy.deepcopy(annotations),
                          attributes=copy.deepcopy(attributes),
                          is_run=True,
                          is_root=False)

    Node(name=str(config_child), config=config_child, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 3
0
def cpg_proc_clock_linreg(
    data,
    annotations,
    attributes,
    child_method = Method.linreg
):
    config_root = Config(
        data=data,
        experiment=Experiment(
            type=DataType.cpg,
            task=Task.clock,
            method=Method.linreg,
            params={}
        ),
        annotations=annotations,
        attributes=attributes
    )
    root = Node(name=str(config_root), config=config_root)

    config_child = Config(
        data=data,
        experiment=Experiment(
            type=DataType.cpg,
            task=Task.table,
            method=child_method,
            params={}
        ),
        annotations=annotations,
        attributes=attributes
    )

    Node(name=str(config_child), config=config_child, parent=root)

    calc_tree(root)
Exemplo n.º 4
0
def betas_clock_linreg(data, annotations, attributes, method_params=None):
    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(
                             data=DataType.betas,
                             task=Task.clock,
                             method=Method.linreg,
                             method_params=copy.deepcopy(method_params)),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True)
    root = Node(name=str(config_root), config=config_root)

    config_child = Config(data=copy.deepcopy(data),
                          experiment=Experiment(data=DataType.betas,
                                                task=Task.table,
                                                method=Method.linreg),
                          annotations=copy.deepcopy(annotations),
                          attributes=copy.deepcopy(attributes),
                          is_run=True,
                          is_root=False)

    Node(name=str(config_child), config=config_child, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 5
0
def cpg_plot_methylation_scatter(
    data,
    annotations,
    attributes,
    cpg_list,
    observables_list,
    child_method=Method.linreg,
):
    for cpg in cpg_list:

        config_root = Config(
            data=data,
            experiment=Experiment(
                type=DataType.cpg,
                task=Task.methylation,
                method=Method.scatter,
                params={}
            ),
            annotations=annotations,
            attributes=attributes
        )
        config_root.experiment.params['item'] = cpg

        root = Node(name=str(config_root), config=config_root)

        for d in observables_list:
            observables_child = Observables(
                name=attributes.observables.name,
                types=d
            )

            cells_child = Cells(
                name=attributes.cells.name,
                types=attributes.cells.types
            )

            attributes_child = Attributes(
                target=attributes.target,
                observables=observables_child,
                cells=cells_child,
            )

            config_child = Config(
                data=data,
                experiment=Experiment(
                    type=DataType.cpg,
                    task=Task.table,
                    method=child_method,
                    params={}
                ),
                annotations=annotations,
                attributes=attributes_child,
                is_run=False
            )
            Node(name=str(config_child), config=config_child, parent=root)

        calc_tree(root)
Exemplo n.º 6
0
def table_aggregator_approach_4(
    data_type,
    data,
    annotations,
    attributes,
    observables_list,
    data_params,
):
    config_root = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=data_type,
            task=Task.table,
            method=Method.aggregator,
            data_params=copy.deepcopy(data_params),
        ),
        annotations=copy.deepcopy(annotations),
        attributes=copy.deepcopy(attributes),
        is_run=True,
        is_root=True
    )
    root = Node(name=str(config_root), config=config_root)

    for d in observables_list:
        observables_lvl_1 = Observables(
            name=copy.deepcopy(attributes.observables.name),
            types=d
        )

        cells_lvl_1 = Cells(
            name=copy.deepcopy(attributes.cells.name),
            types=copy.deepcopy(attributes.cells.types)
        )

        attributes_lvl_1 = Attributes(
            target=copy.deepcopy(attributes.target),
            observables=observables_lvl_1,
            cells=cells_lvl_1,
        )

        config_lvl_1 = Config(
            data=copy.deepcopy(data),
            experiment=Experiment(
                data=data_type,
                task=Task.table,
                method=Method.heteroskedasticity,
                data_params=copy.deepcopy(data_params)
            ),
            annotations=copy.deepcopy(annotations),
            attributes=attributes_lvl_1,
            is_run=True,
            is_root=False
        )
        Node(name=str(config_lvl_1), config=config_lvl_1, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 7
0
def betas_plot_variance_histogram_dev(data,
                                      annotations,
                                      attributes,
                                      cpg_list,
                                      observables_list,
                                      child_method=Method.linreg,
                                      method_params=None):
    for cpg in cpg_list:

        config_root = Config(data=copy.deepcopy(data),
                             experiment=Experiment(
                                 data=DataType.betas,
                                 task=Task.methylation,
                                 method=Method.variance_histogram,
                                 method_params=copy.deepcopy(method_params)),
                             annotations=copy.deepcopy(annotations),
                             attributes=copy.deepcopy(attributes),
                             is_run=True,
                             is_root=True,
                             is_load_child=False)

        if config_root.experiment.method_params is None:
            config_root.experiment.method_params = dict()

        config_root.experiment.method_params['item'] = cpg

        root = Node(name=str(config_root), config=config_root)

        for d in observables_list:
            observables_child = Observables(name=copy.deepcopy(
                attributes.observables.name),
                                            types=d)

            cells_child = Cells(name=copy.deepcopy(attributes.cells.name),
                                types=copy.deepcopy(attributes.cells.types))

            attributes_child = Attributes(
                target=copy.deepcopy(attributes.target),
                observables=observables_child,
                cells=cells_child,
            )

            config_child = Config(data=copy.deepcopy(data),
                                  experiment=Experiment(
                                      data=DataType.betas,
                                      task=Task.table,
                                      method=copy.deepcopy(child_method)),
                                  annotations=copy.deepcopy(annotations),
                                  attributes=attributes_child,
                                  is_run=False,
                                  is_root=False,
                                  is_load_child=False)
            Node(name=str(config_child), config=config_child, parent=root)

        build_tree(root)
        calc_tree(root)
Exemplo n.º 8
0
def plot_scatter(data_type,
                 data,
                 annotations,
                 attributes,
                 observables_list,
                 child_method=Method.linreg,
                 data_params=None,
                 method_params=None):
    task_params = {'type': 'run'}

    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(
                             data=data_type,
                             task=Task.plot,
                             method=Method.scatter,
                             data_params=copy.deepcopy(data_params),
                             method_params=copy.deepcopy(method_params),
                             task_params=task_params),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True,
                         is_load_child=False)

    root = Node(name=str(config_root), config=config_root)

    for d in observables_list:
        observables_child = Observables(name=copy.deepcopy(
            attributes.observables.name),
                                        types=d)

        cells_child = Cells(name=copy.deepcopy(attributes.cells.name),
                            types=copy.deepcopy(attributes.cells.types))

        attributes_child = Attributes(
            target=copy.deepcopy(attributes.target),
            observables=observables_child,
            cells=cells_child,
        )

        config_child = Config(data=copy.deepcopy(data),
                              experiment=Experiment(
                                  data=data_type,
                                  task=Task.table,
                                  method=copy.deepcopy(child_method),
                                  data_params=copy.deepcopy(data_params),
                              ),
                              annotations=copy.deepcopy(annotations),
                              attributes=attributes_child,
                              is_run=False,
                              is_root=False,
                              is_load_child=False)
        Node(name=str(config_child), config=config_child, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 9
0
def cpg_proc_table_polygon(
    data,
    annotations,
    attributes,
    observables_list,
    child_method = Method.linreg
):
    config_root = Config(
        data=data,
        experiment=Experiment(
            type=DataType.cpg,
            task=Task.table,
            method=Method.polygon,
            params={}
        ),
        annotations=annotations,
        attributes=attributes
    )
    root = Node(name=str(config_root), config=config_root)

    for d in observables_list:

        observables_child = Observables(
            name=attributes.observables.name,
            types=d
        )

        cells_child = Cells(
            name=attributes.cells.name,
            types=attributes.cells.types
        )

        attributes_child = Attributes(
            target=attributes.target,
            observables=observables_child,
            cells=cells_child,
        )

        config_child = Config(
            data=data,
            experiment=Experiment(
                type=DataType.cpg,
                task=Task.table,
                method=child_method,
                params={}
            ),
            annotations=annotations,
            attributes=attributes_child
        )
        Node(name=str(config_child), config=config_child, parent=root)

    calc_tree(root)
Exemplo n.º 10
0
def entropy_plot(data,
                 annotations,
                 attributes,
                 observables_list,
                 method,
                 data_params=None,
                 method_params=None):
    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(
                             data=DataType.entropy,
                             task=Task.plot,
                             method=method,
                             data_params=copy.deepcopy(data_params),
                             method_params=copy.deepcopy(method_params)),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True)

    root = Node(name=str(config_root), config=config_root)

    for types in observables_list:
        observables_child = Observables(name=copy.deepcopy(
            attributes.observables.name),
                                        types=types)

        cells_child = Cells(name=copy.deepcopy(attributes.cells.name),
                            types=copy.deepcopy(attributes.cells.types))

        attributes_child = Attributes(
            target=copy.deepcopy(attributes.target),
            observables=observables_child,
            cells=cells_child,
        )

        config_child = Config(data=copy.deepcopy(data),
                              experiment=Experiment(
                                  data=DataType.entropy,
                                  task=Task.table,
                                  method=Method.mock,
                                  data_params=copy.deepcopy(data_params)),
                              annotations=copy.deepcopy(annotations),
                              attributes=attributes_child,
                              is_run=False,
                              is_root=False)
        Node(name=str(config_child), config=config_child, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 11
0
def residuals_table_approach_3(data, annotations, attributes,
                               target_sex_specific, target_age_related,
                               data_params_sex_specific,
                               data_params_age_related):
    config_root = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=DataType.residuals,
            task=Task.table,
            method=Method.aggregator,
            data_params=copy.deepcopy(data_params_sex_specific)),
        annotations=copy.deepcopy(annotations),
        attributes=copy.deepcopy(attributes),
        is_run=True,
        is_root=True)
    root = Node(name=str(config_root), config=config_root)

    attributes_ss = copy.deepcopy(attributes)
    attributes_ss.target = target_sex_specific
    config_ss = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=DataType.residuals,
            task=Task.table,
            method=Method.pbc,
            data_params=copy.deepcopy(data_params_sex_specific)),
        annotations=copy.deepcopy(annotations),
        attributes=attributes_ss,
        is_run=True,
        is_root=False)
    Node(name=str(config_ss), config=config_ss, parent=root)

    attributes_ar = copy.deepcopy(attributes)
    attributes_ar.target = target_age_related
    config_ar = Config(data=copy.deepcopy(data),
                       experiment=Experiment(
                           data=DataType.residuals,
                           task=Task.table,
                           method=Method.oma,
                           data_params=copy.deepcopy(data_params_age_related)),
                       annotations=copy.deepcopy(annotations),
                       attributes=attributes_ar,
                       is_run=True,
                       is_root=False)
    Node(name=str(config_ar), config=config_ar, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 12
0
def cpg_proc_special_clock_linreg_dev(
    data,
    annotations,
    attributes,
    file,
    params=None,
):
    if os.path.isfile(file):

        head, tail = os.path.split(file)
        fn = os.path.splitext(tail)[0]
        ext = os.path.splitext(tail)[1]

        config_root = Config(data=copy.deepcopy(data),
                             experiment=Experiment(
                                 type=DataType.cpg,
                                 task=Task.clock,
                                 method=Method.linreg,
                                 params=copy.deepcopy(params)),
                             annotations=copy.deepcopy(annotations),
                             attributes=copy.deepcopy(attributes),
                             is_run=True,
                             is_root=True)
        root = Node(name=str(config_root), config=config_root)

        config_child = Config(data=copy.deepcopy(data),
                              experiment=Experiment(type=DataType.cpg,
                                                    task=Task.table,
                                                    method=Method.special,
                                                    params={'file_name': fn}),
                              annotations=copy.deepcopy(annotations),
                              attributes=copy.deepcopy(attributes),
                              is_run=False,
                              is_root=False)

        Node(name=str(config_child), config=config_child, parent=root)

        build_tree(root)

        new_file = get_save_path(config_child) + '/' + \
             get_file_name(config_child) + ext

        copyfile(file, new_file)

        calc_tree(root)

    else:
        raise FileNotFoundError(f'File {file} not found.')
Exemplo n.º 13
0
def epimutations_load(data):

    config = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=DataType.epimutations,
            task=None,
            method=None
        ),
        annotations=Annotations(
            name='annotations',
            exclude='bad_cpgs',
            cross_reactive='any',
            snp='any',
            chr='NS',
            gene_region='any',
            geo='any',
            probe_class='any'
        ),
        attributes=Attributes(
            target=None,
            observables=None,
            cells=None
        ),
        is_run=True,
        is_root=True
    )

    load_epimutations(config)
Exemplo n.º 14
0
def betas_horvath_calculator_create_regular(
    chip_type,
    observables_fn,
    data,
    data_params,
):
    annotations = Annotations(name='annotations',
                              type=chip_type,
                              exclude='none',
                              select_dict={})

    cells = Cells(name='cell_counts_part(wo_noIntensity_detP)', types='any')

    observables = Observables(name=observables_fn, types={})

    attributes = Attributes(target='Age', observables=observables, cells=cells)

    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(
                             data=DataType.betas_horvath_calculator,
                             task=Task.create,
                             method=Method.regular,
                             data_params=copy.deepcopy(data_params)),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True)

    root = Node(name=str(config_root), config=config_root)
    build_tree(root)
    calc_tree(root)
Exemplo n.º 15
0
    def setUp(self):
        data = Data(path=ROOT_DIR, base='fixtures')

        experiment = Experiment(data=None, task=None, method=None)

        annotations = Annotations(name='annotations',
                                  type='450k',
                                  exclude='excluded',
                                  select_dict={
                                      'CROSS_R': ['0'],
                                      'Probe_SNPs': ['empty'],
                                      'Probe_SNPs_10': ['empty'],
                                      'CHR': ['-X', '-Y'],
                                      'UCSC_REFGENE_NAME': ['non-empty'],
                                  })

        observables = Observables(name='observables', types={})

        cells = Cells(name='cells', types='any')

        attributes = Attributes(target='age',
                                observables=observables,
                                cells=cells)

        self.config = Config(data=data,
                             experiment=experiment,
                             annotations=annotations,
                             attributes=attributes,
                             is_run=True,
                             is_root=True)
        self.config.initialize()
Exemplo n.º 16
0
    def setUp(self):
        data = Data(name='cpg_beta', path=ROOT_DIR, base='fixtures')

        experiment = Experiment(type=DataType.cpg,
                                task='',
                                method='',
                                params={})

        annotations = Annotations(name='annotations',
                                  exclude=CommonTypes.none.value,
                                  cross_reactive=CrossReactive.exclude.value,
                                  snp=SNP.exclude.value,
                                  chr=Chromosome.non_sex.value,
                                  gene_region=GeneRegion.yes.value,
                                  geo=CommonTypes.any.value,
                                  probe_class=CommonTypes.any.value)

        observables = Observables(name='observables', types={})

        cells = Cells(name='cells', types=CommonTypes.any.value)

        attributes = Attributes(target='age',
                                observables=observables,
                                cells=cells)

        self.config = Config(
            data=data,
            experiment=experiment,
            annotations=annotations,
            attributes=attributes,
        )
Exemplo n.º 17
0
    def setUp(self):

        data = Data(name='cpg_beta', path=ROOT_DIR, base='fixtures')

        experiment = Experiment(type=None, task=None, method=None, params=None)

        annotations = Annotations(name='annotations',
                                  exclude='none',
                                  cross_reactive='ex',
                                  snp='ex',
                                  chr='NS',
                                  gene_region='yes',
                                  geo='any',
                                  probe_class='any')

        observables = Observables(name='observables', types={})

        cells = Cells(name='cells', types='any')

        attributes = Attributes(target='age',
                                observables=observables,
                                cells=cells)

        self.config = Config(data=data,
                             experiment=experiment,
                             annotations=annotations,
                             attributes=attributes,
                             is_run=True,
                             is_root=True)
Exemplo n.º 18
0
def table(
    data,
    annotations,
    attributes,
    data_type,
    method,
    data_params=None,
    task_params=None,
    method_params=None
):
    config_root = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=data_type,
            task=Task.table,
            method=method,
            data_params=copy.deepcopy(data_params),
            task_params=copy.deepcopy(task_params),
            method_params=copy.deepcopy(method_params)
        ),
        annotations=copy.deepcopy(annotations),
        attributes=copy.deepcopy(attributes),
        is_run=True,
        is_root=True
    )

    root = Node(name=str(config_root), config=config_root)
    build_tree(root)
    calc_tree(root)
Exemplo n.º 19
0
def cpg_proc_table_z_test_linreg_dev(data,
                                     annotations,
                                     attributes,
                                     observables_list,
                                     child_method=Method.linreg,
                                     params=None):
    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(type=DataType.cpg,
                                               task=Task.table,
                                               method=Method.z_test_linreg,
                                               params=copy.deepcopy(params)),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True)
    root = Node(name=str(config_root), config=config_root)

    for d in observables_list:
        observables_child = Observables(name=copy.deepcopy(
            attributes.observables.name),
                                        types=d)

        cells_child = Cells(name=copy.deepcopy(attributes.cells.name),
                            types=copy.deepcopy(attributes.cells.types))

        attributes_child = Attributes(
            target=copy.deepcopy(attributes.target),
            observables=observables_child,
            cells=cells_child,
        )

        config_child = Config(data=copy.deepcopy(data),
                              experiment=Experiment(
                                  type=DataType.cpg,
                                  task=Task.table,
                                  method=copy.deepcopy(child_method),
                                  params={}),
                              annotations=copy.deepcopy(annotations),
                              attributes=attributes_child,
                              is_run=True,
                              is_root=False)
        Node(name=str(config_child), config=config_child, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 20
0
    def setUp(self):

        data = Data(
            path=ROOT_DIR,
            base='fixtures'
        )

        data_params = {'cells': ['B', 'CD4T', 'NK', 'CD8T', 'Gran']}

        experiment = Experiment(
            data=None,
            task=None,
            method=None,
            data_params=data_params
        )

        annotations = Annotations(
            name='annotations',
            exclude='none',
            cross_reactive='ex',
            snp='ex',
            chr='NS',
            gene_region='yes',
            geo='any',
            probe_class='any'
        )

        observables = Observables(
            name='observables',
            types={}
        )

        cells = Cells(
            name='cells',
            types='any'
        )

        attributes = Attributes(
            target='age',
            observables=observables,
            cells=cells
        )

        self.config = Config(
            data=data,
            experiment=experiment,
            annotations=annotations,
            attributes=attributes,
            is_run=True,
            is_root=True
        )
        self.config.initialize()
Exemplo n.º 21
0
def load_beta_config(data, annotations, attributes, data_params=None):
    config = Config(data=copy.deepcopy(data),
                    experiment=Experiment(
                        data=DataType.betas,
                        task=Task.load,
                        method=Method.mock,
                        data_params=copy.deepcopy(data_params)),
                    annotations=copy.deepcopy(annotations),
                    attributes=copy.deepcopy(attributes),
                    is_run=True,
                    is_root=True)

    context = Context(config)
    context.load(config)

    return config
Exemplo n.º 22
0
def cpg_proc_table_variance_linreg_dev(data,
                                       annotations,
                                       attributes,
                                       params=None):
    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(type=DataType.cpg,
                                               task=Task.table,
                                               method=Method.variance_linreg,
                                               params=copy.deepcopy(params)),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True)

    root = Node(name=str(config_root), config=config_root)
    build_tree(root)
    calc_tree(root)
Exemplo n.º 23
0
def attributes_plot_observables_histogram(
    data,
    annotations,
    attributes,
    observables_list,
):
    config_root = Config(
        data=data,
        experiment=Experiment(
            type=DataType.attributes,
            task=Task.observables,
            method=Method.histogram,
            params={}
        ),
        annotations=annotations,
        attributes=attributes
    )
    root = Node(name=str(config_root), config=config_root)

    for d in observables_list:
        observables_child = Observables(
            name=attributes.observables.name,
            types=d
        )

        cells_child = Cells(
            name=attributes.cells.name,
            types=attributes.cells.types
        )

        attributes_child = Attributes(
            target=attributes.target,
            observables=observables_child,
            cells=cells_child,
        )

        config_child = Config(
            data=data,
            experiment=config_root.experiment,
            annotations=annotations,
            attributes=attributes_child,
            is_run=False
        )
        Node(name=str(config_child), config=config_child, parent=root)

    calc_tree(root)
Exemplo n.º 24
0
def epimutations_load(data):

    config = Config(data=copy.deepcopy(data),
                    experiment=Experiment(data=DataType.epimutations,
                                          task=None,
                                          method=None),
                    annotations=Annotations(name='annotations',
                                            type='450k',
                                            exclude='bad_cpgs',
                                            select_dict={'CHR': ['-X', '-Y']}),
                    attributes=Attributes(target=None,
                                          observables=None,
                                          cells=None),
                    is_run=True,
                    is_root=True)

    load_epimutations(config)
Exemplo n.º 25
0
def cpg_proc_table_variance_linreg(
    data,
    annotations,
    attributes
):
    config_root = Config(
        data=data,
        experiment=Experiment(
            type=DataType.cpg,
            task=Task.table,
            method=Method.variance_linreg,
            params={}
        ),
        annotations=annotations,
        attributes=attributes
    )

    root = Node(name=str(config_root), config=config_root)
    calc_tree(root)
Exemplo n.º 26
0
def betas_spec_create_regular(
    data,
    data_params,
    observables
):
    annotations = Annotations(
        name='annotations',
        type='450k',
        exclude='none',
        select_dict={
            'CHR': ['-X', '-Y']
        }
    )

    cells = Cells(
        name='cells',
        types='any'
    )

    attributes = Attributes(
        target='age',
        observables=observables,
        cells=cells
    )

    config_root = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=DataType.betas_spec,
            task=Task.create,
            method=Method.regular,
            data_params=data_params
        ),
        annotations=copy.deepcopy(annotations),
        attributes=copy.deepcopy(attributes),
        is_run=True,
        is_root=True
    )

    root = Node(name=str(config_root), config=config_root)
    build_tree(root)
    calc_tree(root)
Exemplo n.º 27
0
def attributes_plot_observables_histogram_dev(data,
                                              annotations,
                                              attributes,
                                              observables_list,
                                              params=None):
    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(type=DataType.attributes,
                                               task=Task.observables,
                                               method=Method.histogram,
                                               params=copy.deepcopy(params)),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True)
    root = Node(name=str(config_root), config=config_root)

    for d in observables_list:
        observables_child = Observables(name=copy.deepcopy(
            attributes.observables.name),
                                        types=d)

        cells_child = Cells(name=copy.deepcopy(attributes.cells.name),
                            types=copy.deepcopy(attributes.cells.types))

        attributes_child = Attributes(
            target=copy.deepcopy(attributes.target),
            observables=observables_child,
            cells=cells_child,
        )

        config_child = Config(data=copy.deepcopy(data),
                              experiment=config_root.experiment,
                              annotations=copy.deepcopy(annotations),
                              attributes=attributes_child,
                              is_run=False,
                              is_root=True)
        Node(name=str(config_child), config=config_child, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 28
0
def table_aggregator_linreg(
    data_type,
    data,
    annotations,
    attributes,
    observables_list,
    data_params=None,
    task_params=None,
    method_params=None
):
    child_methods_lvl_1 = [Method.polygon, Method.z_test_linreg]
    child_methods_lvl_2 = [Method.linreg]

    config_root = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=data_type,
            task=Task.table,
            method=Method.aggregator,
            data_params=copy.deepcopy(data_params),
            task_params=copy.deepcopy(task_params),
            method_params=copy.deepcopy(method_params)
        ),
        annotations=copy.deepcopy(annotations),
        attributes=copy.deepcopy(attributes),
        is_run=True,
        is_root=True
    )
    root = Node(name=str(config_root), config=config_root)

    for child_method_lvl_1 in child_methods_lvl_1:

        if child_method_lvl_1 == Method.polygon:
            method_params = {'method': Method.linreg}
            is_load_child = True
        elif child_method_lvl_1 == Method.z_test_linreg:
            method_params = {}
            is_load_child = True
        elif child_method_lvl_1 == Method.ancova:
            method_params = {}
            is_load_child = True
        else:
            method_params = {}
            is_load_child = False

        config_lvl_1 = Config(
            data=copy.deepcopy(data),
            experiment=Experiment(
                data=data_type,
                task=Task.table,
                method=child_method_lvl_1,
                data_params=copy.deepcopy(data_params),
                method_params=method_params
            ),
            annotations=copy.deepcopy(annotations),
            attributes=copy.deepcopy(attributes),
            is_run=True,
            is_root=False,
            is_load_child=is_load_child
        )
        node_lvl_1 = Node(name=str(config_lvl_1), config=config_lvl_1, parent=root)

        for child_method_lvl_2 in child_methods_lvl_2:
            for d in observables_list:
                observables_lvl_2 = Observables(
                    name=copy.deepcopy(attributes.observables.name),
                    types=d
                )

                cells_lvl_2 = Cells(
                    name=copy.deepcopy(attributes.cells.name),
                    types=copy.deepcopy(attributes.cells.types)
                )

                attributes_lvl_2 = Attributes(
                    target=copy.deepcopy(attributes.target),
                    observables=observables_lvl_2,
                    cells=cells_lvl_2,
                )

                config_lvl_2 = Config(
                    data=copy.deepcopy(data),
                    experiment=Experiment(
                        data=data_type,
                        task=Task.table,
                        method=copy.deepcopy(child_method_lvl_2),
                        data_params=copy.deepcopy(data_params),
                    ),
                    annotations=copy.deepcopy(annotations),
                    attributes=attributes_lvl_2,
                    is_run=True,
                    is_root=False,
                    is_load_child=is_load_child
                )
                Node(name=str(config_lvl_2), config=config_lvl_2, parent=node_lvl_1)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 29
0
def observables_plot_histogram(
    data,
    annotations,
    attributes,
    observables_list,
    method_params=None
):
    """
        Plotting histogram for target observable distribution for provided subjects subsets and provided CpG list.

        Possible parameters of experiment:

        * ``'bin_size'``: bin size for numeric target. \n
          For categorical target is not considered.
        * ``'opacity'``: opacity level.
          From ``0.0`` to ``1.0``.
        * ``'barmode'``: type of barmode. \n
          Possible options: \n
          ``'overlay'`` for overlaid histograms. \n
          ``'stack'`` for stacked histograms. \n
        * ``'x_range'``: can be ``'auto'`` or list with two elements, which are borders of target axis.

        :param data: pdm.Data instance, which specifies information about dataset.
        :param annotations: pdm.Annotations instance, which specifies subset of CpGs.
        :param attributes: pdm.Attributes instance, which specifies information about subjects.
        :param cpg_list: List of CpGs for plotting
        :param observables_list: list of subjects subsets. Each element in list is dict,
         where ``key`` is observable name and ``value`` is possible values for this observable.
        :param method_params: parameters of experiment.
    """

    config_root = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=DataType.observables,
            task=Task.observables,
            method=Method.histogram,
            method_params=copy.deepcopy(method_params)
        ),
        annotations=copy.deepcopy(annotations),
        attributes=copy.deepcopy(attributes),
        is_run=True,
        is_root=True,
        is_load_child=False
    )
    root = Node(name=str(config_root), config=config_root)

    for d in observables_list:
        observables_child = Observables(
            name=copy.deepcopy(attributes.observables.name),
            types=d
        )

        cells_child = Cells(
            name=copy.deepcopy(attributes.cells.name),
            types=copy.deepcopy(attributes.cells.types)
        )

        attributes_child = Attributes(
            target=copy.deepcopy(attributes.target),
            observables=observables_child,
            cells=cells_child,
        )

        config_child = Config(
            data=copy.deepcopy(data),
            experiment=config_root.experiment,
            annotations=copy.deepcopy(annotations),
            attributes=attributes_child,
            is_run=False,
            is_root=True,
            is_load_child=False
        )
        Node(name=str(config_child), config=config_child, parent=root)

    build_tree(root)
    calc_tree(root)
Exemplo n.º 30
0
def betas_plot_curve_clock(data,
                           annotations,
                           attributes,
                           observables_list,
                           child_method=Method.linreg,
                           data_params=None,
                           method_params=None):
    data_type = DataType.betas

    clock_method_params = {
        'type': 'all',
        'part': 0.25,
        'size': 100,
        'runs': 100,
    }

    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(
                             data=data_type,
                             task=Task.plot,
                             method=Method.curve,
                             data_params=copy.deepcopy(data_params),
                             method_params=copy.deepcopy(method_params)),
                         annotations=copy.deepcopy(annotations),
                         attributes=copy.deepcopy(attributes),
                         is_run=True,
                         is_root=True,
                         is_load_child=True)

    root = Node(name=str(config_root), config=config_root)

    for d in observables_list:

        observables_child = Observables(name=copy.deepcopy(
            attributes.observables.name),
                                        types=d)

        cells_child = Cells(name=copy.deepcopy(attributes.cells.name),
                            types=copy.deepcopy(attributes.cells.types))

        attributes_child = Attributes(
            target=copy.deepcopy(attributes.target),
            observables=observables_child,
            cells=cells_child,
        )

        config_child_lvl_1 = Config(data=copy.deepcopy(data),
                                    experiment=Experiment(
                                        data=data_type,
                                        task=Task.clock,
                                        method=copy.deepcopy(child_method),
                                        data_params=copy.deepcopy(data_params),
                                        method_params=clock_method_params),
                                    annotations=copy.deepcopy(annotations),
                                    attributes=attributes_child,
                                    is_run=False,
                                    is_root=False,
                                    is_load_child=False)
        node_lvl_1 = Node(name=str(config_child_lvl_1),
                          config=config_child_lvl_1,
                          parent=root)

        config_child_lvl_2 = Config(data=copy.deepcopy(data),
                                    experiment=Experiment(
                                        data=data_type,
                                        task=Task.table,
                                        method=Method.linreg),
                                    annotations=copy.deepcopy(annotations),
                                    attributes=attributes_child,
                                    is_run=False,
                                    is_root=False)
        Node(name=str(config_child_lvl_2),
             config=config_child_lvl_2,
             parent=node_lvl_1)

    build_tree(root)
    calc_tree(root)