Example #1
0
    "/home/mattjones/projects/scLineages/SingleCellLineageTracing/Alex_Solver")

from simulation_tools.simulation_utils import get_leaves_of_tree
from simulation_tools.validation import check_triplets_correct, tree_collapse
from lineage_solver.solution_evaluation_metrics import cci_score
from data_pipeline import newick_to_network

parser = argparse.ArgumentParser()
parser.add_argument("true_net", type=str)
parser.add_argument("typ", type=str)

args = parser.parse_args()

true_netfp = args.true_net
t = args.typ

name = true_netfp.split("/")[-1]
spl = name.split("_")
param = spl[-3]
run = spl[-1].split(".")[0]

true_network = pic.load(open(true_netfp, "rb"))
target_nodes = get_leaves_of_tree(true_network, clip_identifier=True)

cci_upper = cci_score(target_nodes, bound="upper")
cci_lower = cci_score(target_nodes, bound="lower")

print(
    str(param) + "\t" + str(run) + "\t" + str(cci_lower) + "\t" +
    str(cci_upper) + '\t' + str(cci_upper - cci_lower) + '\t' + str(t))
    46: 0.8870967741935477
}

dropout_prob_map = {
    i: random.choice(data_dropout_rates.values())
    for i in range(0, 40)
}

# Generate simulated network
true_network = generate_simulated_full_tree(prior_probabilities,
                                            dropout_prob_map,
                                            characters=number_of_characters,
                                            subsample_percentage=.4,
                                            depth=10)

target_nodes = get_leaves_of_tree(true_network, clip_identifier=True)
target_nodes_original_network = get_leaves_of_tree(true_network,
                                                   clip_identifier=False)

pic.dump(target_nodes, open("test_target_nodes.pkl", "wb"))

print("CCI complexity of reconstruction: " + str(cci_score(target_nodes)))

# Hybrid solution
reconstructed_network_hybrid = solve_lineage_instance(
    target_nodes,
    method="greedy",
    prior_probabilities=prior_probabilities,
    hybrid_subset_cutoff=200,
    time_limit=60,
    threads=10)