Skip to content

Commit

Permalink
Fixing Mark03 rule error (#125)
Browse files Browse the repository at this point in the history
* add wildcard restriction on log_prob analyze_metric rule

* fixed mark03

* change paths to euer

* fix ambiguites

* change initial trees mark02 - were true trees
  • Loading branch information
gordonkoehn authored Jul 26, 2023
1 parent 73ec8d6 commit 32d46b9
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 7 deletions.
4 changes: 4 additions & 0 deletions workflows/analyze.smk
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ rule get_log_probs:
"""Extract log probabilities from MCMC samples for ease of plotting / analysis."""
input:
mcmc_samples="{DATADIR}/{experiment}/mcmc/MCMC_{mcmc_seed,\d+}-{mutation_data_id}-i{init_tree_id}-{mcmc_config_id}.json",
wildcard_constraints:
mcmc_config_id = "MC_(?:(?!/).)+",
init_tree_id = "(HUN|T)_(?:(?!/).)+"

output:
result="{DATADIR}/{experiment}/analysis/MCMC_{mcmc_seed,\d+}-{mutation_data_id}-i{init_tree_id}-{mcmc_config_id}/log_prob.json",
run:
Expand Down
6 changes: 3 additions & 3 deletions workflows/mark02.smk
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ CS_seed = 42 # <-- configure cell simulation seed here
#####################
# True Tree Parameters
tree_types = ["r"] # <-- configure tree type here ["r","s","d"]
tree_seeds = [42, 34] # <-- configure tree seed here
tree_seeds = [42]#, 34] # <-- configure tree seed here

#####################
#####################
Expand All @@ -66,8 +66,8 @@ tree_seeds = [42, 34] # <-- configure tree seed here
# given each error rate, true tree, no of cells and mutations
initial_points = [ # (mcmc_seed, init_tree_type, init_tree_seed)
(42, 'r', 45),
(12, 'r', 34),
(34, 'r', 42),
(12, 'r', 20),
(34, 'r', 31),
(79, 'r', 89),
]

Expand Down
37 changes: 36 additions & 1 deletion workflows/mark03.smk
Original file line number Diff line number Diff line change
Expand Up @@ -704,4 +704,39 @@ rule combined_logProb_iteration_plot_noHuntress:
ax.legend(loc="upper right")

# save the histogram
fig.savefig(Path(output.combined_logP_iter))
fig.savefig(Path(output.combined_logP_iter))

rule get_log_probs_2:
"""Extract log probabilities from MCMC samples for ease of plotting / analysis.
Saves into true tree directory. - not nessary but good for workflow design
Note this rule is needed only for the MARK03 experiment due to diffuculties with
wildcards in the output path.
"""
input:
mcmc_samples="{DATADIR}/{experiment}/mcmc/MCMC_{mcmc_seed,\d+}-{mutation_data_id}-i{init_tree_id}-{mcmc_config_id}.json",
wildcard_constraints:
mcmc_config_id="MC_(?:(?!/).)+",
init_tree_id="(HUN|T)_(?:(?!/).)+"

output:
result="{DATADIR}/{experiment}/analysis/MCMC_{mcmc_seed,\d+}-{mutation_data_id}-i{init_tree_id}-{mcmc_config_id}/T_{base_tree_type}_{n_nodes,\d+}_{base_tree_seed,\d+}/log_prob.json",
run:
# load the data
mcmc_samples = yg.serialize.read_mcmc_samples(Path(input.mcmc_samples))
mcmc_data = yg.analyze.to_pure_mcmc_data(mcmc_samples)

# write the result
fp = Path(output.result)

# get log probs
log_probs = mcmc_data.log_probabilities
# convert log probs to list of float
log_probs = [float(i) for i in log_probs]
# get iteration
iteration = mcmc_data.iterations
# convert iterations of list of int
iteration = [int(i) for i in iteration]

# save
yg.serialize.save_metric_result(iteration,log_probs,fp)
11 changes: 10 additions & 1 deletion workflows/mark_viz.smk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ rule mark_viz:
input:
f"{DATADIR}/{experiment}/plots/T_r_10_42_relabeled.svg",
f"{DATADIR}/{experiment}/plots/T_d_10_42_relabeled.svg",
f"{DATADIR}/{experiment}/plots/T_s_10_relabeled.svg"
f"{DATADIR}/{experiment}/plots/T_s_10_relabeled.svg",
f"{DATADIR}/{experiment}/plots/T_r_6_42_relabeled.svg",
f"{DATADIR}/{experiment}/plots/T_r_51_42_relabeled.svg",
f"{DATADIR}/{experiment}/plots/T_r_6_45_relabeled.svg",
f"{DATADIR}/{experiment}/plots/T_r_6_20_relabeled.svg",
f"{DATADIR}/{experiment}/plots/T_r_6_34_relabeled.svg",
f"{DATADIR}/{experiment}/plots/T_r_6_89_relabeled.svg",



4 changes: 2 additions & 2 deletions workflows/tree_inference.smk
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ from pyggdrasil.tree_inference import (
###############################################
## Relative path from DATADIR to the repo root

REPODIR = "/cluster/work/bewi/members/gkoehn/repos/PYggdrasil"
#REPODIR = ".."
#REPODIR = "/cluster/work/bewi/members/gkoehn/repos/PYggdrasil"
REPODIR = ".."
#DATADIR = "/cluster/work/bewi/members/gkoehn/data"

###############################################
Expand Down
2 changes: 2 additions & 0 deletions workflows/visualize.smk
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ rule plot_tree:
"""Plot a raw tree"""
input:
tree="{DATADIR}/{experiment}/trees/{tree_id}.json",
wildcard_constraints:
tree_id = "^(?!.*_relabeled)(HUN|T)_(?:(?!/).)+$" # allowing both generated and huntress trees
output:
plot="{DATADIR}/{experiment}/plots/{tree_id}.svg",
run:
Expand Down

0 comments on commit 32d46b9

Please sign in to comment.