-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcellphy.snake
More file actions
184 lines (164 loc) · 8.56 KB
/
cellphy.snake
File metadata and controls
184 lines (164 loc) · 8.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
"""
Explanation of wildcards:
fineTuneTypeCellPhy: types of fine-tuning to perform for CellPhy defined in the configuration file, e.g., single thread, multi thread, etc.
dataType: input data types, e.g., no CNVs, including CNVs, excluding CNVs, etc.
datasetName: simulated dataset names, e.g., 0001, 0002, 0003...
"""
include: "scripts/constants.py"
include: "scripts/utils.py"
#########################################################
# Get categories of wildcards #
#########################################################
SIMUDATASETNAMES = get_dataset_names(SIMUSNVSITESDIR, config["fineTune"]["indelsieve_simulator"]["subsample"])
FINETUNETYPESCELLPHY = get_fine_tune_types(
config["fineTune"]["cellphy"],
config["benchmark"]["fineTuneTypes"]
)
SIMUDATATYPES = get_data_types(
config["benchmark"]["simulatedDataTypes"],
config["benchmark"]["simulation"]["dataTypes"]["CNVTypes"]
)
########################################################
# CELLPHY - From Monovar #
########################################################
# Rule: run CELLPHY with filtered SNVs called by Monovar working with TRUE parameters (VCF input in EP mode)
rule runCellphyWithMonovarSNVsTrueParamsVCFEP:
input:
MONOVARTRUEPARAMSDIR + "{dataType}/{datasetName}/filtered.vcf"
output:
tree=protected(CELLPHYTRUEMONOVARSNVSDIR + "{fineTuneTypeCellPhy}/{dataType}/{datasetName}/vcf_ep/{datasetName}.raxml.bestTree"),
model=protected(CELLPHYTRUEMONOVARSNVSDIR + "{fineTuneTypeCellPhy}/{dataType}/{datasetName}/vcf_ep/{datasetName}.raxml.bestModel")
params:
cellphy=config["tools"]["cellphy"],
mode=lambda wildcards: get_dict_values(
config,
["fineTune", "cellphy", wildcards.fineTuneTypeCellPhy, "mode"]
),
seed=lambda wildcards: get_dict_values(
config,
["fineTune", "cellphy", wildcards.fineTuneTypeCellPhy, "seed"]
),
parsTrees=lambda wildcards: get_dict_values(
config,
["fineTune", "cellphy", wildcards.fineTuneTypeCellPhy, "parsTrees"]
),
prefix=CELLPHYTRUEMONOVARSNVSDIR + "{fineTuneTypeCellPhy}/{dataType}/{datasetName}/vcf_ep/{datasetName}"
threads:
lambda wildcards, input: get_thread_num_for_cellphy(
input[0],
get_dict_values(
config,
["fineTune", "cellphy", wildcards.fineTuneTypeCellPhy, "nrOfSitesPerThread"]
)
)
benchmark:
repeat(
EFFICIENCYCELLPHYDIR + "{fineTuneTypeCellPhy}/{dataType}/{datasetName}.tsv",
config["benchmark"]["efficiency"]["repetition"]
)
shell:
"{params.cellphy} RAXML "
"--{params.mode} "
"--msa {input} "
"--model GT10+FO+E+G "
"--tree pars{{{params.parsTrees}}} "
"--seed {params.seed} "
"--thread {threads} "
"--prefix {params.prefix} "
"--prob-msa off "
"--force model_lh_impr "
"--force "
"--redo "
"&>{params.prefix}.out"
# Rule: replace the cell names on the best tree of CELLPHY with input data from Monovar for the sake of tree conparison
rule replaceCellphyCellNamesWithMonovarSNVsTrueParams:
input:
refCellNames=SIMUTUMORCELLNAMES,
tree=CELLPHYTRUEMONOVARSNVSDIR + "{fineTuneTypeCellPhy}/{dataType}/{datasetName}/vcf_ep/{datasetName}.raxml.bestTree"
output:
protected(CELLPHYTRUEMONOVARSNVSDIR + "{fineTuneTypeCellPhy}/{dataType}/{datasetName}/vcf_ep/{datasetName}.raxml.bestTree_formatted")
shell:
"python3 scripts/format_cell_names_on_tree.py "
"--tree {input.tree} "
"--ref {input.refCellNames} "
"--out {output}"
#######################################################
# Gather trees from CELLPHY #
#######################################################
# Rule: gather inferred trees from CELLPHY with filtered SNVs called by Monovar working with TRUE parameters
rule gatherCellphyTreesWithTrueMonovarSNVsEP:
input:
inferredTrees=expand(CELLPHYTRUEMONOVARSNVSDIR + "{fineTuneTypeCellPhy}/{dataType}/{datasetName}/vcf_ep/{datasetName}.raxml.bestTree_formatted", fineTuneTypeCellPhy=FINETUNETYPESCELLPHY, dataType=SIMUDATATYPES, datasetName=SIMUDATASETNAMES),
trueTrees=expand(SIMUCONVERTEDTRUETREEDIR + config["benchmark"]["simulation"]["treesWithoutTrunkWithoutNormalDir"] + config["benchmark"]["simulation"]["treesPre"] + ".{datasetName}", datasetName=SIMUDATASETNAMES)
output:
protected(ANALYSISTREECOMPDIR + "from_cellphy_" + config["benchmark"]["analysis"]["trueMonovarSNVs"] + "_" + config["benchmark"]["analysis"]["cellphyEPMode"] + ".tsv")
params:
datasetNames=SIMUDATASETNAMES,
trueTreesDir=SIMUCONVERTEDTRUETREEDIR + config["benchmark"]["simulation"]["treesWithoutTrunkWithoutNormalDir"],
trueTreesPre=config["benchmark"]["simulation"]["treesPre"],
tool="cellphy",
snvType=config["benchmark"]["analysis"]["trueMonovarSNVs"],
toolSetup=config["benchmark"]["analysis"]["cellphyEPMode"],
fineTuneType=FINETUNETYPESCELLPHY,
cnvRate=str(config["fineTune"]["simulateCNVs"]["prob"]),
dataType=SIMUDATATYPES,
cellNum=config["benchmark"]["analysis"]["cellNum"],
covMean=config["benchmark"]["analysis"]["covMean"],
covVariance=config["benchmark"]["analysis"]["covVariance"],
effSeqErrRate=config["benchmark"]["analysis"]["effSeqErrRate"],
adoRate=config["benchmark"]["analysis"]["adoRate"],
deletionRate=config["benchmark"]["analysis"]["deletionRate"],
insertionRate=config["benchmark"]["analysis"]["insertionRate"],
doubletRate=config["benchmark"]["analysis"]["doubletRate"]
script:
"scripts/gather_inferred_trees_part.py"
########################################################
# Get estimates from CELLPHY #
########################################################
# Rule: get parameter estimates from CELLPHY with filtered SNVs called by Monovar working with TRUE parameters
rule getCellphyParamsWithTrueMonovarSNVsEP:
input:
expand(CELLPHYTRUEMONOVARSNVSDIR + "{fineTuneTypeCellPhy}/{dataType}/{datasetName}/vcf_ep/{datasetName}.raxml.bestModel", fineTuneTypeCellPhy=FINETUNETYPESCELLPHY, dataType=SIMUDATATYPES, datasetName=SIMUDATASETNAMES)
output:
protected(ANALYSISPARAMSDIR + "from_cellphy_" + config["benchmark"]["analysis"]["trueMonovarSNVs"] + ".tsv")
params:
cellNum=config["benchmark"]["analysis"]["cellNum"],
covMean=config["benchmark"]["analysis"]["covMean"],
covVariance=config["benchmark"]["analysis"]["covVariance"],
datasetNames=SIMUDATASETNAMES,
tool="cellphy",
snvType=config["benchmark"]["analysis"]["trueMonovarSNVs"],
toolSetup=config["benchmark"]["analysis"]["cellphyEPMode"],
fineTuneType=FINETUNETYPESCELLPHY,
cnvRate=str(config["fineTune"]["simulateCNVs"]["prob"]),
dataType=SIMUDATATYPES,
doubletRate=config["benchmark"]["analysis"]["doubletRate"]
script:
"scripts/get_param_estimates_cellphy.py"
#######################################################
# Gather the number of sites from CELLPHY #
#######################################################
# Rule: gather the number of variant sites as input to CELLPHY
rule gatherCellphySitesInfo:
input:
expand(MONOVARTRUEPARAMSDIR + "{dataType}/{datasetName}/filtered.vcf", dataType=SIMUDATATYPES, datasetName=SIMUDATASETNAMES)
output:
protected(ANALYSISSITESINFODIR + "from_cellphy_" + config["benchmark"]["analysis"]["trueMonovarSNVs"] + ".tsv")
params:
datasetNames=SIMUDATASETNAMES,
tool="cellphy",
snvType=config["benchmark"]["analysis"]["trueMonovarSNVs"],
toolSetup=config["benchmark"]["analysis"]["cellphyEPMode"],
fineTuneType=FINETUNETYPESCELLPHY,
cnvRate=str(config["fineTune"]["simulateCNVs"]["prob"]),
dataType=SIMUDATATYPES,
cellNum=config["benchmark"]["analysis"]["cellNum"],
covMean=config["benchmark"]["analysis"]["covMean"],
covVariance=config["benchmark"]["analysis"]["covVariance"],
effSeqErrRate=config["benchmark"]["analysis"]["effSeqErrRate"],
adoRate=config["benchmark"]["analysis"]["adoRate"],
deletionRate=config["benchmark"]["analysis"]["deletionRate"],
insertionRate=config["benchmark"]["analysis"]["insertionRate"],
doubletRate=config["benchmark"]["analysis"]["doubletRate"]
script:
"scripts/gather_sites_info_part.py"