Commit 994bd098 authored by Harald RINGBAUER's avatar Harald RINGBAUER

Upload new file

parent 4f8130d5
Created on Feb 4, 2016
Class for running all the mle_analysis.
In MLE_ESTIM_ERROR class parameters for the mle estimation with errors can be found at top.
In MLE_ESTIM_ERROR functions for error in block length and fp at bottom.
Analysis class contains formulas for the fit (bottom).
@author: Harald
import cPickle as pickle # @UnusedImport
from loaddata import LoadData
from mle_analysis import MLE_analyse
# ## Paths to relevant data'''
folder = "/home/hringbauer/IST/BlockInference/Popres Data/" # The folder everything can be found in
pop_path = folder + "ibd-pop-info.csv" # Population csv path
ibd_list_path = folder + "ibd-blocklens.csv" # IBD-list csv path
coordinates_path = folder + "country_centroids.csv" # GPS postion of countries path
pickle_path = folder + "popres_blocks.p"
# ## Countries to use in mle_analysis:
countries_oi = ["Austria", "Hungary", "Czech Republic", "Slovakia", "Slovenia", "Poland", "Romania", "Bulgaria", "Macedonia", "Bosnia",
"Croatia", "Serbia", "Montenegro", "Albania"] # Germany
# countries_oi = ["Italy", "Spain", "England", "France", "Netherlands", "Belgium", "Germany", "Switzerland", "Austria",
# "Hungary", "Czech Republic", "Slovakia", "Slovenia", "Poland", "Romania", "Bulgaria", "Macedonia", "Bosnia",
# "Croatia", "Serbia", "Montenegro", "Albania"] # Everything
# countries_oi = ["Netherlands","Germany","France","Belgium","Swiss German","England","Scotland","Ireland","Switzerland"]
# countries_oi_west
print("Welcome back, friend.")
while True:
inp = input(("\nWhat do you want to do? \n(1) Extract data \n(2) Analyze Data"
"\n(8) Save/Load data \n(0) Exit \n"))
if inp == 1:
min_len = input("What is the minimum block length? (in cM)?\n")
data = LoadData(pop_path, ibd_list_path, coordinates_path, min_len, countries_oi)
analysis = MLE_analyse(data, all_chrom=True)
elif inp == 2:
while True:
inp1 = input(("\n(1) Regress spec. block sharing \n(2) Regress min. block sharing \n(3) Bin-Plot"
"\n(4) MLE estimation"
"\n(0) Exit \n"))
if inp1 == 1:
min_len = input("What is the minimum block length? (in cM)?\n")
max_len = input("What is the maximum block length? (in cM)?\n")
analysis.plot_ibd_spec(min_len=min_len, max_len=max_len)
elif inp1 == 2:
min_len = input("What is the minimum block length? (in cM)?\n")
analysis.plot_ibd_min(min_len, 150)
elif inp1 == 3:
elif inp1 == 4:
while True:
inp2 = input("\n(1) Choose MLE-model \n(2) Run Fit\n(3) Bin plot fitted data \n(4) Log-Likelihood surface"
"\n(5) Jack-Knive Countries \n(7) Boots-Trap (Country Pairs) \n(8) Boots-Trap (Blocks)"
"\n(9) Which times? \n(10) Analyze Residuals \n(11) Plot all fits \n (0) Exit\n")
if inp2 == 1:
inp3 = input("Which Model?\n(1) Constant \n(2) Doomsday"
"\n(3) Power growth \n(4) Power-Const\n(0) Back\n")
if inp3 == 1: analysis.create_mle_model("constant")
elif inp3 == 2: analysis.create_mle_model("doomsday")
elif inp3 == 3: analysis.create_mle_model("power_growth")
elif inp3 == 4: analysis.create_mle_model("ddd")
else: print("Invalid Input!! Please do again")
# elif inp2 == 4: mle_analysis.mle_analysis_error("exp_const")
elif inp2 == 2: analysis.mle_analysis_error()
elif inp2 == 3: analysis.plot_fitted_data_error()
elif inp2 == 4: analysis.plot_loglike_surface()
elif inp2 == 5: analysis.jack_knife_ctries()
elif inp2 == 7:
bts_nr = input("How many boots traps?\n")
elif inp2 == 8:
bts_nr = input("How many boots traps?\n")
elif inp2 == 9:
elif inp2 == 10:
elif inp2 == 11:
elif inp2 == 0: break
elif inp1 == 9: # Hidden option
elif inp1 == 0: break
elif inp == 8:
inp1 = input("\n(1) Save processed Data \n(2) Load processed Data \n(3) Back\n")
if inp1 == 1:
pickle.dump(analysis, open(pickle_path, "wb")) # Pickle the data
elif inp1 == 2:
analysis = pickle.load(open(pickle_path, "rb"))
analysis.all_chrom = True # Use all chromosomes
print("Countries successfully loaded: ")
elif inp1 == 3:
continue # Return to main menue
elif inp == 0: break
print("See you next time!")
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment