aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/chunks.py12
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/lmm.py30
2 files changed, 10 insertions, 32 deletions
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/chunks.py b/wqflask/wqflask/my_pylmm/pyLMM/chunks.py
index 4c34080c..abeffee7 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/chunks.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/chunks.py
@@ -32,7 +32,7 @@ def divide_into_chunks(the_list, number_chunks):
return chunks
-def confirm_chunk(original, result):
+def _confirm_chunk(original, result):
all_chunked = []
for chunk in result:
all_chunked.extend(chunk)
@@ -40,7 +40,7 @@ def confirm_chunk(original, result):
assert original == all_chunked, "You didn't chunk right"
-def chunk_test(divide_func):
+def _chunk_test(divide_func):
import random
random.seed(7)
@@ -58,7 +58,7 @@ def chunk_test(divide_func):
len(the_list), number_chunks, len(result)))
print("result:", result)
- confirm_chunk(the_list, result)
+ _confirm_chunk(the_list, result)
amount_off = abs(number_chunks - len(result))
if amount_off == 0:
@@ -75,13 +75,13 @@ def chunk_test(divide_func):
return number_exact, total_amount_off
-def main():
+def _main():
info = dict()
#funcs = (("sam", sam_divide_into_chunks), ("zach", zach_divide_into_chunks))
funcs = (("only one", divide_into_chunks),)
for name, func in funcs:
start = time.time()
- number_exact, total_amount_off = chunk_test(func)
+ number_exact, total_amount_off = _chunk_test(func)
took = time.time() - start
info[name] = dict(number_exact=number_exact,
total_amount_off=total_amount_off,
@@ -90,7 +90,7 @@ def main():
print("info is:", info)
if __name__ == '__main__':
- main()
+ _main()
print("\nConfirming doctests...")
import doctest
doctest.testmod() \ No newline at end of file
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
index 99040d38..24565af8 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
@@ -29,6 +29,8 @@ from pprint import pformat as pf
from utility.benchmark import Bench
+from wqflask.my_pylmm.pyLMM import chunks
+
#np.seterr('raise')
def run_human(pheno_vector,
@@ -70,15 +72,14 @@ def run_human(pheno_vector,
with Bench("Create list of inputs"):
-
inputs = list(plink_input)
with Bench("Divide into chunks"):
- divide_into_chunks(inputs, 63)
+ results = chunks.divide_into_chunks(inputs, 63)
for snp, this_id in plink_input:
with Bench("part before association"):
- if count > 10000:
+ if count > 500:
break
count += 1
@@ -103,25 +104,6 @@ def run_human(pheno_vector,
return p_values, t_stats
-def divide_into_chunks(the_list, number_chunks):
- """Divides a list into approximately number_chunks smaller lists"""
- length = len(the_list)
-
- if length == 0:
- return [[]]
-
- if length <= number_chunks:
- number_chunks = length
-
- chunksize = int(math.ceil(length / number_chunks))
-
- chunks = []
- for counter in range(0, length, chunksize):
- chunks.append(the_list[counter:counter+chunksize])
-
- return chunks
-
-
def human_association(snp,
n,
keep,
@@ -624,7 +606,3 @@ class LMM:
pl.xlabel("Heritability")
pl.ylabel("Probability of data")
pl.title(title)
-
-
-if __name__ == '__main__':
- chunk_test() \ No newline at end of file