Skip to content

Commit

Permalink
removing old commented code from plot
Browse files Browse the repository at this point in the history
  • Loading branch information
Melissa Gymrek authored and Melissa Gymrek committed Sep 25, 2024
1 parent 1da272c commit b6f3087
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 110 deletions.
55 changes: 10 additions & 45 deletions citrus/cli.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
"""CITRUS command line interface.
See CITRUS/doc/CLI.md for more information.
This tool can be used to run the simulation based on either:
1. A single configuration JSON file that specifies paths to genotype
data files.
CITRUS_sim -c <path_to_config_file>
2. A single configuration JSON file and a list of paths to genotype
data files. The list of paths must be the same length as the
number of input source files in the configuration file (i.e.
the length of the list under the 'input' key in the JSON). Any
paths in the configuration file will be ignored. The -g or
--genotype_files flag can be used to specify the paths to the
genotype files.
CITRUS_sim -c <path_to_config_file> -g <path_to_genotype_file> \\
<path_to_genotype_file> ...
CITRUS_sim -c <path_to_config_file> -g <path_to_genotype_file>
Output:
If no additional flags are provided, output will be written to the
current working directory. The output will be a CSV file (output.csv)
containing sample IDs and all corresponding values from the simulation,
and a JSON file (sim_config.json) containing the simulation configuration
(including any random selections made by nodes).
If the -o or --output_dir flag is provided, if the directory does not
exist it will be created, and the output files will be saved to it. By
default the output files will be named output.csv and sim_config.json,
but these can be changed with the -f or --output_file_name and -j or
--output_config_json flags, respectively.
Output file will by default be a comma seperated CSV file. Use -t or
--tsv flag to instead save as a tab seperated TSV file.
Example Usage:
CITRUS_sim -c config.json -o sim_results/output_dir
CITRUS_sim -c config.json -g genotype_file_1 genotype_file_2 \\
-o sim_results/output_dir -t -f my_output.tsv -j my_sim_config.json
See CITRUS/doc/CLI.md and individual tools for more information.
"""

import click
Expand All @@ -54,6 +10,9 @@
def citrus():
pass

"""
citrus simulate
"""
@citrus.command(no_args_is_help=True)
@click.option(
'-c', '--config_file',
Expand Down Expand Up @@ -147,6 +106,9 @@ def simulate(
sep="\t" if tsv else ","
)

"""
citrus plot
"""
@citrus.command(no_args_is_help=True)
@click.option(
'-c', '--config_file',
Expand Down Expand Up @@ -183,6 +145,9 @@ def plot(config_file: str, out: str, format: str):
# Create a plot of the model
plot.visualize(input_spec=config, filename=out, img_format=format)

"""
citrus shap
"""
@citrus.command(no_args_is_help=True)
@click.option(
'-c', '--config_file',
Expand Down
66 changes: 1 addition & 65 deletions pheno_sim/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,68 +162,4 @@ def plot_graph_with_legend(sim_nodes, filename, img_format):
y_offset = (img.height - legend.height) // 2
combined.paste(legend, (img.width, y_offset))

combined.save(filename + '.' + img_format)


# if __name__ == '__main__':

# # dev
# input_spec = '../benchmarking_mlcb/pheno_sim/sim_configs/xor_pheno_1.json'
# filename = '../benchmarking_mlcb/pheno_sim/sim_configs/xor_pheno_1'
# img_format = 'png'

# # Generate sim object
# sim = PhenoSimulation.from_JSON_file(input_spec)

# # Add input nodes
# sim_nodes = dict()

# for input_source in sim.input_runner.input_sources:
# for input_node in input_source.input_nodes:
# sim_nodes[input_node.alias] = CITRUSNode(
# alias=input_node.alias,
# node_type='input',
# class_name=type(input_node).__name__
# )

# # Add operator nodes
# for sim_step in sim.simulation_steps:
# step_alias = sim_step.alias
# step_inputs = sim_step.inputs

# if isinstance(step_inputs, str):
# step_inputs = [step_inputs]
# elif isinstance(step_inputs, dict):
# step_inputs = list(step_inputs.values())

# if isinstance(sim_step, AbstractBaseCombineFunctionNode):
# step_type = 'combine'
# else:
# step_type = 'trans'

# sim_nodes[step_alias] = CITRUSNode(
# alias=step_alias,
# inputs=step_inputs,
# node_type=step_type,
# class_name=type(sim_step).__name__
# )

# # Identify nodes that are of type 'combine'.
# combine_nodes = [node for node in sim_nodes.values() if node.node_type == 'combine']

# # For each combine node, identify its ancestors.
# all_ancestor_nodes = set()
# for combine_node in combine_nodes:
# all_ancestor_nodes.update(get_ancestor_nodes(combine_node, sim_nodes))

# # Change the node_type of ancestor nodes which are of type 'trans' to 'cis'.
# for ancestor_node_alias in all_ancestor_nodes:
# if sim_nodes[ancestor_node_alias].node_type == 'trans':
# sim_nodes[ancestor_node_alias].node_type = 'cis'

# # Print nodes
# for k,v in sim_nodes.items():
# print(f"{k}:\n\t{str(v)}")

# # Plot the graph
# plot_graph_with_legend(sim_nodes, filename, img_format)
combined.save(filename + '.' + img_format)

0 comments on commit b6f3087

Please sign in to comment.