Exemplo n.º 1
0
def main():
    """Main"""
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-analyze_results_only",
        action="store_true",
        help="only analyze results, instead of generating them as well"
        " (useful when results already generated")
    parser.add_argument("-type",
                        choices=[
                            INSTANCE_COUNTS, FEATURE_COUNTS, NOISE_LEVELS,
                            SHUFFLING_COUNTS
                        ],
                        default=INSTANCE_COUNTS)
    parser.add_argument("-output_dir", required=True)
    parser.add_argument("-seed", type=int, required=True)

    args, pass_arglist = parser.parse_known_args(
    )  # Any unknown options will be passed to simulation.py
    args.pass_arglist = " ".join(pass_arglist)

    if not os.path.exists(args.output_dir):
        os.makedirs(args.output_dir)

    args.logger = utils.get_logger(__name__,
                                   "%s/run_simulations.log" % args.output_dir)

    args.logger.info("Begin running/analyzing simulations")
    args.config = load_config(args)
    simulations = parametrize_simulations(args)
    run_simulations(args, simulations)
    analyze_simulations(args, simulations)
    args.logger.info("End running simulations")
Exemplo n.º 2
0
def main():
    """Main"""
    parser = argparse.ArgumentParser()
    parser.add_argument("-num_trials", type=int, default=3)
    parser.add_argument("-start_seed", type=int, default=100000)
    parser.add_argument("-type",
                        choices=[
                            constants.INSTANCE_COUNTS,
                            constants.FEATURE_COUNTS, constants.NOISE_LEVELS,
                            constants.SHUFFLING_COUNTS
                        ],
                        default=constants.INSTANCE_COUNTS)
    parser.add_argument(
        "-summarize_only",
        help="enable to assume that the results are already generated,"
        " and just summarize them",
        action="store_true")
    parser.add_argument("-output_dir", required=True)

    args, pass_arglist = parser.parse_known_args()
    args.pass_arglist = " ".join(pass_arglist)

    if not os.path.exists(args.output_dir):
        os.makedirs(args.output_dir)

    args.logger = utils.get_logger(__name__,
                                   "%s/run_trials.log" % args.output_dir)

    trials = gen_trials(args)
    run_trials(args, trials)
    summarize_trials(args, trials)
Exemplo n.º 3
0
def main():
    """Main"""
    parser = argparse.ArgumentParser()
    parser.add_argument("args_filename", help="pickle file containing arguments"
                        " passed by master.py")
    cargs = parser.parse_args()
    with open(cargs.args_filename, "rb") as args_file:
        args = pickle.load(args_file)
    logger = utils.get_logger(__name__, "%s/worker_%d.log" % (args.output_dir, args.task_idx))
    pipeline(args, logger)
Exemplo n.º 4
0
def main():
    """Main"""
    parser = argparse.ArgumentParser()
    parser.add_argument("-output_dir", help="name of output directory")
    parser.add_argument(
        "-dependence_assumption",
        help=
        "choice of dependence assumption used by Lynch and Guo (2016) procedure",
        choices=[constants.POSITIVE, constants.ARBITRARY],
        default=constants.POSITIVE)
    parser.add_argument("-alpha", type=float, default=0.05)
    parser.add_argument("-procedure",
                        default=constants.YEKUTIELI,
                        choices=[constants.YEKUTIELI, constants.LYNCH_GUO])
    parser.add_argument(
        "csv_filename",
        help=
        "CSV (with header) representing hierarchy, each row corresponding to one node:"
        " the name of the node, the name of its parent node, the node's p-value and optionally a description of the node"
    )
    parser.add_argument("-effect_name", default="Effect size")
    parser.add_argument(
        "-tree_effect_size_threshold",
        help="while generating output tree of rejected hypotheses,"
        " only show nodes within given threshold of root (i.e. all nodes erased) effect size",
        type=float,
        default=1)
    parser.add_argument("-color_scheme",
                        default="ylorrd9",
                        help="color scheme to use for shading nodes")
    parser.add_argument("-color_range",
                        help="range for chosen color scheme",
                        nargs=2,
                        type=int,
                        default=[1, 9])
    parser.add_argument(
        "-sorting_param",
        help="parameter to sort on for color grading",
        default=constants.ADJUSTED_PVALUE,
        choices=[constants.ADJUSTED_PVALUE, constants.EFFECT_SIZE])
    parser.add_argument(
        "-minimal_labels",
        help="do not write descriptions/effect sizes on node labels",
        action="store_true")
    parser.add_argument(
        "-rectangle_leaves",
        help=
        "enable to generate rectangular nodes for leaves of original hierarchy",
        action="store_true")
    args = parser.parse_args()

    if not args.output_dir:
        args.output_dir = "%s_alpha_%f_effect_threshold_%f" % (
            os.path.splitext(os.path.basename(args.csv_filename))[0],
            args.alpha, args.tree_effect_size_threshold)
    if not os.path.exists(args.output_dir):
        os.makedirs(args.output_dir)

    logger = utils.get_logger(
        __name__, "%s/hierarchical_fdr_control.log" % args.output_dir)
    logger.info("Begin hierarchical_fdr_control")

    tree = build_tree(args, logger)
    F, M = process_tree(logger, tree)
    hierarchical_fdr_control(args, logger, F, M)
    write_outputs(args, logger, tree)
    logger.info("End hierarchical_fdr_control")
Exemplo n.º 5
0
def main():
    """Main"""
    parser = argparse.ArgumentParser()
    parser.add_argument("-seed", type=int, default=constants.SEED)
    parser.add_argument("-num_instances", type=int, default=10000)
    parser.add_argument("-num_features", type=int, default=100)
    parser.add_argument("-output_dir", help="Name of output directory")
    parser.add_argument("-fraction_relevant_features", type=float, default=.05)
    parser.add_argument(
        "-noise_multiplier",
        type=float,
        default=.05,
        help=
        "Multiplicative factor for noise added to polynomial computation for irrelevant features"
    )
    parser.add_argument("-noise_type",
                        choices=[
                            constants.ADDITIVE_GAUSSIAN,
                            constants.EPSILON_IRRELEVANT, constants.NO_NOISE
                        ],
                        default=constants.EPSILON_IRRELEVANT)
    parser.add_argument(
        "-hierarchy_type",
        help="Choice of hierarchy to generate",
        default=constants.CLUSTER_FROM_DATA,
        choices=[constants.CLUSTER_FROM_DATA, constants.RANDOM])
    parser.add_argument(
        "-clustering_instance_count",
        type=int,
        help="If provided, uses this number of instances to "
        "cluster the data to generate a hierarchy, allowing the hierarchy to remain same across multiple "
        "sets of instances",
        default=0)
    parser.add_argument("-num_interactions",
                        type=int,
                        default=0,
                        help="number of interaction pairs in model")
    parser.add_argument(
        "-exclude_interaction_only_features",
        help="exclude interaction-only features in model"
        " in addition to linear + interaction features (default included)",
        action="store_false",
        dest="include_interaction_only_features")
    parser.set_defaults(include_interaction_only_features=True)
    parser.add_argument(
        "-contiguous_node_names",
        action="store_true",
        help="enable to change node names in hierarchy "
        "to be contiguous for better visualization (but creating mismatch between node names and features indices)"
    )
    # Arguments used to qualify output directory, then passed to mihifepe.master
    parser.add_argument("-perturbation",
                        default=constants.SHUFFLING,
                        choices=[constants.ZEROING, constants.SHUFFLING])
    parser.add_argument("-num_shuffling_trials",
                        type=int,
                        default=100,
                        help="Number of shuffling trials to average over, "
                        "when shuffling perturbations are selected")
    parser.add_argument("-analyze_interactions",
                        help="enable analyzing interactions",
                        action="store_true")

    args, pass_args = parser.parse_known_args()
    pass_args = " ".join(pass_args)
    if not args.output_dir:
        args.output_dir = (
            "sim_outputs_inst_%d_feat_%d_noise_%.3f_relfraction_%.3f_pert_%s_shufftrials_%d"
            % (args.num_instances, args.num_features, args.noise_multiplier,
               args.fraction_relevant_features, args.perturbation,
               args.num_shuffling_trials))
    if not os.path.exists(args.output_dir):
        os.makedirs(args.output_dir)
    args.rng = np.random.RandomState(args.seed)
    args.logger = utils.get_logger(__name__,
                                   "%s/simulation.log" % args.output_dir)

    pipeline(args, pass_args)