Example #1
0
    parser.add_argument("--expression_folder", help="Folder with predicted gene expressions. (plain text file format)")
    parser.add_argument("--expression_pattern", help="Patterns to select expression files", default=None)
    parser.add_argument("--input_phenos_file", help="Text file (or gzip-compressed) where one column will be used as phenotype")
    parser.add_argument("--simulation_type", help="What kind of genotype to simulate: [random, combination, simple]")
    parser.add_argument("--output_prefix", help="File where stuff will be saved.")
    parser.add_argument("--verbosity", help="Log verbosity level. 1 is everything being logged. 10 is only high level messages, above 10 will hardly log anything", default = "10")
    parser.add_argument("--throw", action="store_true", help="Throw exception on error", default=False)
    parser.add_argument("--code_999", help="values of -999 in expression are to be ignored", action="store_true", default=False)
    parser.add_argument("--mode", help="Type of regression. Can be: {}".format(MultiPrediXcanAssociation.MTPMode.K_MODES), default=MultiPrediXcanAssociation.MTPMode.K_LINEAR)
    parser.add_argument("--pc_condition_number", help="Principal components condition number", type=int)
    parser.add_argument("--pc_eigen_ratio", help="Principal components filter, cutoff at proportion to max eigenvalue", type=float)
    parser.add_argument("--standardize_expression", help="Standardise input predicted expressions.", action="store_true", default=False)
    parser.add_argument("--only_truth", help="Run Multi-PrediXcan only with selected causal models.", action="store_true", default=False)
    parser.add_argument("--simulation_parameters", help="Depends on particular scheme", action="append", nargs=2)
    parser.add_argument("--do_predixcan", help="Also compute predixcan association", action="store_true", default=False)
    parser.add_argument("--max_n_results", help="Optional. If provided, run up to as many analysis", type=int)

    args = parser.parse_args()

    Logging.configureLogging(int(args.verbosity))

    if args.throw:
        run(args)
    else:
        try:
            run(args)
        except Exceptions.ReportableException as e:
            logging.error(e.msg)
        except Exception as e:
            logging.info("Unexpected error: %s" % str(e))
Example #2
0
    import argparse
    parser = argparse.ArgumentParser(
        description=
        'PrediXcanAssociation.py %s: Single-Tissue PrediXcan association' %
        (metax.__version__))

    add_arguments(parser)

    parser.add_argument(
        "--verbosity",
        help=
        "Log verbosity level. 1 is everything being logged. 10 is only high level messages, above 10 will hardly log anything",
        default=10)
    parser.add_argument("--throw",
                        action="store_true",
                        help="Throw exception on error",
                        default=False)

    args = parser.parse_args()

    Logging.configureLogging(int(args.verbosity))

    if args.throw:
        run(args)
    else:
        try:
            run(args)
        except Exceptions.ReportableException as e:
            logging.error(e.msg)
        except Exception as e:
            logging.info("Unexpected error: %s" % str(e))
Example #3
0
    for i, gene in enumerate(data.columns.values[2:]):
        p[i, :] = data[gene].to_numpy()
        g[i] = np.string_(gene)

    logging.info("saving samples")
    s = f.create_dataset("samples", (n_samples, ), dtype="S25")
    for i in xrange(0, n_samples):
        s[i] = np.string_(data["IID"][i])
    f.close()
    logging.info("Done")


if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser("""Convert expression text file to HDF5.
WARNING: h5py _cache has been deprecated.
Input format should be a tab-separated text file like so:
FID IID GENE1   GENE2 ...
I1  I1  0.1     0.2   ...
I2  I2  0.0     -0.1  ...
....
                                     """)
    parser.add_argument(
        "--input", default="Text file with predicted transcriptomic trait")
    parser.add_argument("--output")
    parser.add_argument("--verbosity", default=logging.INFO, type=int)

    args = parser.parse_args()
    Logging.configureLogging(args.verbosity)
    run(args)
                        help="exclude some genes from a mystical list.",
                        action="store_true",
                        default=False)

    parser.add_argument("--gene_digest_file",
                        help="path of gene information digest",
                        default="data/gencode.v18.genes.patched_contigs.summary.protein")

    parser.add_argument("--predixcan_file",
                        help="name of PrediXcan results in data folder",
                        default="data/PrediXcan_T1D_DGNWholeBlood_EN0.5.txt")

    parser.add_argument("--zscore_file",
                        help="File with zscore results in results folder",
                        default='results/zscores.csv')

    parser.add_argument("--output",
                        help="File with merged zscore and predixcan results",
                        default="results/T1DWB_predixcan_zscore.csv")

    parser.add_argument("--save_error_proxy",
                    help="Output beta error proxy",
                    action="store_true",
                    default=False)

    args = parser.parse_args()

    Logging.configureLogging(logging.INFO)

    work = PostProcessData(args)
    work.run()
Example #5
0
                    continue

                var = numpy.var(snp.data, ddof=1)

                line = ",".join([snp.name, str(float(var))])+"\n"
                file.write(line)

if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser(description='Build variances from PHASE3 data and weights database.')

    parser.add_argument("--weight_db",
                        help="name of weight db in data folder")
                        #,default="data_folder/DGN-WB_0.5.db")

    parser.add_argument("--phase_folder",
                        help="name of folder containing PHASE 3 data",
                        default="intermediate/TGF_EUR")

    parser.add_argument("--output_file",
                        help="name of folder to dump results in",
                        default="intermediate/var/var.txt.gz")

    args = parser.parse_args()

    Logging.configureLogging(7)

    work = CalculateVariances(args)
    work.run()

Example #6
0
def post_process(study, reference):
    command = "PostProcessData.py"
    command += " --predixcan_file " + PREDIXCAN[study]
    command += " --zscore_file " + zscore_path(study, reference)
    command += " --output " + predixcan_zscore_path(study, reference)
    command += " --save_error_proxy"

    logging.log(9, command)
    call(command.split())

#
def plot(study, reference):
    command = "Rscript PlotValuesWithSamples.R"
    command += " --zscore_file " + zscore_path(study, reference).split(".csv")[0]
    command += " --predixcan_file " + predixcan_zscore_path(study, reference).split(".csv")[0]

    logging.log(9, command)
    call(command.split())

def run():
    for reference in REF_POP:
        for study in STUDY_POP:
            zscore(study, reference)
            post_process(study,reference)
            #plot(study, reference)

if __name__ == "__main__":
    Logging.configureLogging(9)
    run()
Example #7
0
                    continue

                var = numpy.var(snp.data, ddof=1)

                line = ",".join([snp.name, str(float(var))]) + "\n"
                file.write(line)


if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser(
        description='Build variances from PHASE3 data and weights database.')

    parser.add_argument("--weight_db", help="name of weight db in data folder")
    #,default="data_folder/DGN-WB_0.5.db")

    parser.add_argument("--phase_folder",
                        help="name of folder containing PHASE 3 data",
                        default="intermediate/TGF_EUR")

    parser.add_argument("--output_file",
                        help="name of folder to dump results in",
                        default="intermediate/var/var.txt.gz")

    args = parser.parse_args()

    Logging.configureLogging(7)

    work = CalculateVariances(args)
    work.run()