Exemple #1
0
import numpy as np
from scipy.stats import fisher_exact, mannwhitneyu

from zopy.utils import qw, say
from zopy.fdr import pvalues2qvalues as apply_fdr

#-------------------------------------------------------------------------------
# constants
#-------------------------------------------------------------------------------

c_eps = 1e-20

c_fisher_fields = qw("""
term
overlap
expected_overlap
fold_enrichment
p_value
q_value
""")

c_rank_fields = qw("""
term
overlap
overlap_median
background_median
p_value
q_value
""")

# ---------------------------------------------------------------
# helper classes
Exemple #2
0
from __future__ import print_function

from zopy.utils import qw
from zopy.table import Table

T1 = qw("""
+ 1 2 3 4 5
A 0 1 0 0 1
B 1 0 0 1 0
C 0 1 1 0 1
D 1 0 1 1 0
""")

with open("temp.txt", "w") as fh:
    for l in T1:
        print(l.replace(" ", "\t"), file=fh)
"""
print( "\nTest loading from a nested list" )
aa = [
    ["!", "1", "2"],
    ["A", "X", "Y"],
]
T = Table( aa )
T.write( )
        
print( "\nTest loading from a nested dict" )
dd = {
    "A":{"1":"1", "2":"0"},
    "B":{"2":"0", "3":"1"},
}     
T = Table( dd )
Exemple #3
0
import argparse
from collections import Counter
from zopy.utils import path2name, warn, qw
from zopy.dictation import polymap, col2dict

# ---------------------------------------------------------------
# constants
# ---------------------------------------------------------------

ALLOW_CROSSTALK = False
c_prop_pattern = r"^([^\s]*?): (.*)"
c_goid_pattern = r"(GO:[0-9]+)"

c_namespace_convert = qw("""
biological_process BP
molecular_function MF
cellular_component CC
""",
                         as_dict=True)

c_relationship_subtypes = qw("""
part_of
#regulates
#positively_regulates
#negatively_regulates
""")

c_singular_props = qw("""
id
name
namespace
""")
Exemple #4
0
#!/usr/bin/env python

import os
import sys
import argparse
from collections import Counter

from zopy.utils import qw

c_defaults = qw( """
py
R
sh
md
slurm
slurm-template
""" )

# argument parsing (python argparse)
parser = argparse.ArgumentParser()
parser.add_argument( "start", default="." )
parser.add_argument( "--extensions", nargs="+", default=None )
parser.add_argument( "--no-defaults", action="store_true" )
parser.add_argument( "--execute", action="store_true" )
args = parser.parse_args()

# setup extensions
extensions = [] if args.extensions is None else args.extensions
if not args.no_defaults:
    extensions += c_defaults
print >>sys.stderr, "Targeting these extensions:", extensions
Exemple #5
0
from zopy.utils import iter_lines, qw

parser = argparse.ArgumentParser( )
parser.add_argument( "input" )
parser.add_argument( "--execute", action="store_true" )
args = parser.parse_args( )

# note: if a prefix is a prefix of another prefix, it must come later in list
prefixes = qw( """
int
float
str
list
dict
set
hash
func
i
f
a
""" )
pre_pattern = "^(" + "|".join( prefixes ) + ")+"

def wordish( char ):
    return True if re.search( "[A-Za-z0-9_]", char ) else False

def next_span( text, index ):
    start = index
    is_word = wordish( text[index] )
    while( index < len( text ) and ( is_word == wordish( text[index] ) ) ):
Exemple #6
0
c_max_lab = 50
c_metacmap = "jet"
c_font1 = 7
c_font2 = 8
c_font3 = 10
c_eps = 1e-20
c_str_other = "Other"
c_str_none = "None"
c_other_color = "0.75"
c_none_color = "white"

c_wspans = qw("""
cbar      8
rowtree   3
rowmeta   1
heatmap  24
rownames 12
legend    8
""",
              as_dict=True)

c_hspans = qw("""
title     1
coltree   3
colmeta   1
heatmap  16
colnames  6
""",
              as_dict=True)

sys.setrecursionlimit(10000)