Пример #1
0
def run_all():
    """Run a variety of enrichment analysis."""
    fout_log = GOEA.get_fout_log()
    log = sys.stdout if fout_log is None else open(fout_log, 'w')
    goeaobj = init_goea(log) # Initialize once
    test_bonferronis(log, goeaobj)
    close_log(fout_log, log)
Пример #2
0
    sort_by = lambda nt: [nt.NS, -1 * nt.depth]
    fld2fmt = {"fdr_bh": "{:8.2e}"}  # Optional user defined formatting for specific fields
    goea.wr_tsv(
        fout_tsv, results_nt, field_names, keep_if=keep_if, sort_by=sort_by, fld2fmt=fld2fmt, print_names=print_names
    )

    # 3. Write results to xlsx file
    # Use these headers instead of the print_names for the xlsx header
    hdrs = ["NS", "Cnt", "fdr_bh", "L", "D", "Term", "Ontology Term Name"]
    # TBD Check that header and size of fields printed match
    goea.wr_xlsx(
        fout_xls,
        results_nt,
        field_names,
        # optional key-word args (ie, kwargs, kws)
        keep_if=keep_if,
        sort_by=sort_by,
        hdrs=hdrs,
        fld2fmt=fld2fmt,
        print_names=print_names,
    )
    if fout_log is not None:
        log.close()
        sys.stdout.write("  WROTE: {}\n".format(fout_log))


if __name__ == "__main__":
    test_fdr_bh(GOEA.get_fout_log())

# Copyright (C) 2016, DV Klopfenstein, H Tang. All rights reserved.
Пример #3
0
    #      ...
    # Print format field names are the same names as in the "field_names" variable.
    prtfmt = " ".join(["{NS} {study_cnt:2} {pval_uncor:5.3e}",
             "{bonferroni_star:1} {bonferroni:5.3e} L{level:02} D{depth:02} {GO} {name}\n"])
    prt_if = lambda nt: nt.bonferroni_sig # T/F: Keep the GOEA GO Term result only if the result is significant.
    goea.prt_txt(log, results_nt, field_names, prtfmt, sort_by=sort_by, prt_if=prt_if)

    # 2. Write results to tsv file
    # Optional user defined formatting for specific fields
    fld2fmt = {'bonferroni':'{:8.2e}', 'pval_uncor':'{:8.2e}'} 
    # Sort by: 1st) BP, MF, CC; 2nd) By GO depth, deepest GO first.
    sort_by = lambda nt: [nt.NS, -1*nt.depth] 
    goea.wr_tsv(fout_tsv, results_nt, field_names, 
        prt_if=prt_if, sort_by=sort_by, fld2fmt=fld2fmt, print_names=print_names)

    # 3. Write results to xlsx file
    # Use these headers instead of the print_names for the xlsx header
    hdrs = ['NS', 'Cnt', '*', 'bonferroni', 'L', 'D', 'Term', 'Ontology Term Name']
    # TBD Check that header and size of fields printed match
    goea.wr_xlsx(fout_xls, results_nt, field_names, 
        # optional key-word args (ie, kwargs, kws)
        prt_if=prt_if, sort_by=sort_by, hdrs=hdrs, fld2fmt=fld2fmt, print_names=print_names) 
    if fout_log is not None:
        log.close()
        sys.stdout.write("  WROTE: {}\n".format(fout_log))

if __name__ == '__main__':
    test_bonferroni(GOEA.get_fout_log())

# Copyright (C) 2016, DV Klopfenstein, H Tang. All rights reserved.
Пример #4
0
                results_nt,
                field_names,
                keep_if=keep_if,
                sort_by=sort_by,
                fld2fmt=fld2fmt,
                print_names=print_names)

    # 3. Write results to xlsx file
    # Use these headers instead of the print_names for the xlsx header
    hdrs = ['NS', 'Cnt', 'fdr_bh', 'L', 'D', 'Term', 'Ontology Term Name']
    # TBD Check that header and size of fields printed match
    goea.wr_xlsx(
        fout_xls,
        results_nt,
        field_names,
        # optional key-word args (ie, kwargs, kws)
        keep_if=keep_if,
        sort_by=sort_by,
        hdrs=hdrs,
        fld2fmt=fld2fmt,
        print_names=print_names)
    if fout_log is not None:
        log.close()
        sys.stdout.write("  WROTE: {}\n".format(fout_log))


if __name__ == '__main__':
    test_fdr_bh(GOEA.get_fout_log())

# Copyright (C) 2016, DV Klopfenstein, H Tang. All rights reserved.