Ejemplo n.º 1
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,
        )
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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()
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo 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)
Ejemplo n.º 10
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()
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
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)
Ejemplo n.º 14
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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
0
def table_ancova(
    data_type,
    data,
    annotations,
    attributes,
    observables_list,
    data_params=None,
    task_params=None,
    method_params=None
):

    config_ancova = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=data_type,
            task=Task.table,
            method=Method.ancova,
            data_params=copy.deepcopy(data_params),
            method_params=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_ancova), config=config_ancova)

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

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

        attributes_linreg = Attributes(
            target=copy.deepcopy(attributes.target),
            observables=observables_linreg,
            cells=cells_linreg,
        )

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

    build_tree(root)
    calc_tree(root)
Ejemplo n.º 17
0
def table_aggregator_variance(
    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)

    config_lvl_1 = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=data_type,
            task=Task.table,
            method=Method.polygon,
            data_params=copy.deepcopy(data_params),
            method_params={'method': Method.variance}
        ),
        annotations=copy.deepcopy(annotations),
        attributes=copy.deepcopy(attributes),
        is_run=True,
        is_root=False
    )
    node_lvl_1 = Node(name=str(config_lvl_1), config=config_lvl_1, parent=root)

    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=Method.variance,
                data_params=copy.deepcopy(data_params),
                method_params={
                    'semi_window': 8,
                    'box_b': 'Q5',
                    'box_t': 'Q95',
                }
            ),
            annotations=copy.deepcopy(annotations),
            attributes=attributes_lvl_2,
            is_run=True,
            is_root=False
        )
        Node(name=str(config_lvl_2), config=config_lvl_2, parent=node_lvl_1)

    cluster_types = copy.deepcopy(observables_list[0])
    cluster_types.pop('gender', None)
    cluster_types.pop('sex', None)
    observables_cluster = Observables(
        name=copy.deepcopy(attributes.observables.name),
        types=cluster_types
    )

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

    attributes_cluster = Attributes(
        target=copy.deepcopy(attributes.target),
        observables=observables_cluster,
        cells=cells_cluster,
    )

    config_cluster = Config(
        data=copy.deepcopy(data),
        experiment=Experiment(
            data=data_type,
            task=Task.table,
            method=Method.cluster,
            data_params=copy.deepcopy(data_params),
            method_params={
                'eps': 0.2,
                'min_samples_percentage': 1
            }
        ),
        annotations=copy.deepcopy(annotations),
        attributes=attributes_cluster,
        is_run=True,
        is_root=False
    )
    Node(name=str(config_cluster), config=config_cluster, parent=root)

    build_tree(root)
    calc_tree(root)
Ejemplo n.º 18
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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
def plot_scatter_comparison(
    data_type,
    data_list,
    annotations_list,
    attributes_list,
    observables_list,
    data_params_list,
    rows_dict,
    cols_dict,
    child_method=Method.linreg,
    method_params=None,
):

    data = copy.deepcopy(data_list[0])
    data.base = 'comparison'
    annotations = annotations_list[0]
    attributes = attributes_list[0]

    items = rows_dict['items']
    reverses = rows_dict['reverses']
    data_bases = cols_dict['data_bases']

    task_params = {'type': 'run'}

    method_params['items'] = items
    method_params['reverses'] = reverses
    method_params['data_bases'] = data_bases
    if 'aux' in rows_dict:
        method_params['aux'] = rows_dict['aux']
    method_params['x_ranges'] = []
    for data_base_id, data_base in enumerate(data_bases):
        method_params['x_ranges'].append([
            cols_dict['begins'][data_base_id], cols_dict['ends'][data_base_id]
        ])

    method_params['y_ranges'] = []
    for item_id in range(0, len(items)):
        method_params['y_ranges'].append(
            [rows_dict['begins'][item_id], rows_dict['ends'][item_id]])

    config_root = Config(data=copy.deepcopy(data),
                         experiment=Experiment(
                             data=data_type,
                             task=Task.plot,
                             method=Method.scatter_comparison,
                             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,
                         is_init=False,
                         is_init_child=False)
    root = Node(name=str(config_root), config=config_root)

    for data_base_id, data_base in enumerate(data_bases):
        method_params_lvl_1 = copy.deepcopy(method_params)
        method_params_lvl_1['items'] = items
        method_params_lvl_1['reverses'] = reverses
        method_params_lvl_1['x_ranges'] = [
            cols_dict['begins'][data_base_id], cols_dict['ends'][data_base_id]
        ]
        method_params_lvl_1['y_ranges'] = []

        for item_id in range(0, len(items)):
            method_params_lvl_1['y_ranges'].append(
                [rows_dict['begins'][item_id], rows_dict['ends'][item_id]])

        task_params_lvl_1 = {'type': 'prepare'}

        config_lvl_1 = Config(
            data=copy.deepcopy(data_list[data_base_id]),
            experiment=Experiment(data=data_type,
                                  task=Task.plot,
                                  method=Method.scatter,
                                  data_params=copy.deepcopy(
                                      data_params_list[data_base_id]),
                                  task_params=task_params_lvl_1,
                                  method_params=method_params_lvl_1),
            annotations=copy.deepcopy(annotations_list[data_base_id]),
            attributes=copy.deepcopy(attributes_list[data_base_id]),
            is_run=True,
            is_root=False,
            is_load_child=False)

        node_lvl_1 = Node(name=str(config_lvl_1),
                          config=config_lvl_1,
                          parent=root)

        for d in observables_list[data_base_id]:
            observables_child = Observables(name=copy.deepcopy(
                attributes_list[data_base_id].observables.name),
                                            types=d)

            cells_child = Cells(
                name=copy.deepcopy(attributes_list[data_base_id].cells.name),
                types=copy.deepcopy(attributes_list[data_base_id].cells.types))

            attributes_child = Attributes(
                target=copy.deepcopy(attributes_list[data_base_id].target),
                observables=observables_child,
                cells=cells_child,
            )

            config_child = Config(
                data=copy.deepcopy(data_list[data_base_id]),
                experiment=Experiment(
                    data=data_type,
                    task=Task.table,
                    method=copy.deepcopy(child_method),
                    data_params=copy.deepcopy(data_params_list[data_base_id]),
                ),
                annotations=copy.deepcopy(annotations_list[data_base_id]),
                attributes=attributes_child,
                is_run=False,
                is_root=False,
                is_load_child=False)
            Node(name=str(config_child),
                 config=config_child,
                 parent=node_lvl_1)

    build_tree(root)
    calc_tree(root)
Ejemplo n.º 21
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)
Ejemplo n.º 22
0
def cpg_proc_table_aggregator_dev(data,
                                  annotations,
                                  attributes,
                                  observables_list,
                                  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(type=DataType.cpg,
                                               task=Task.table,
                                               method=Method.aggregator,
                                               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 child_method_lvl_1 in child_methods_lvl_1:
        config_lvl_1 = Config(data=copy.deepcopy(data),
                              experiment=Experiment(type=DataType.cpg,
                                                    task=Task.table,
                                                    method=child_method_lvl_1,
                                                    params={}),
                              annotations=copy.deepcopy(annotations),
                              attributes=copy.deepcopy(attributes),
                              is_run=True,
                              is_root=False)
        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(
                        type=DataType.cpg,
                        task=Task.table,
                        method=copy.deepcopy(child_method_lvl_2),
                        params={}),
                    annotations=copy.deepcopy(annotations),
                    attributes=attributes_lvl_2,
                    is_run=True,
                    is_root=False)
                Node(name=str(config_lvl_2),
                     config=config_lvl_2,
                     parent=node_lvl_1)

    build_tree(root)
    calc_tree(root)