Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Mark03 rule error #125

Merged
merged 6 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
gordonkoehn marked this conversation as resolved.
Show resolved Hide resolved
(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
gordonkoehn marked this conversation as resolved.
Show resolved Hide resolved
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",

gordonkoehn marked this conversation as resolved.
Show resolved Hide resolved


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
Loading