Skip to content

Commit

Permalink
update(pca): evol style & color
Browse files Browse the repository at this point in the history
  • Loading branch information
johaGL committed Aug 24, 2023
1 parent 9195361 commit ce48911
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/dimet/config/analysis/method/pca_plot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ _target_: dimet.method.PcaPlotConfig
label: pca-plot
name: Generate Principal Component Analysis plots

color: condition # color dots using this variable
style: timepoint # style of the dots' shapes, using this variable

pca_split_further:
- timepoint
# - condition
Expand Down
2 changes: 2 additions & 0 deletions src/dimet/method/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def build(self) -> "PcaAnalysis":


class PcaPlotConfig(MethodConfig):
color: Union[str, None] = "condition"
style: Union[str, None] = "timepoint"
pca_split_further: Union[ListConfig, None] = ["timepoint"]
draw_ellipses: Union[str, None] = "condition"
run_iris_demo: bool = False
Expand Down
8 changes: 6 additions & 2 deletions src/dimet/visualization/pca_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,19 @@ def run_pca_plot(pca_results_dict: dict, cfg: DictConfig,
name_plot_var = f"{'--'.join(tup)}_var.pdf"
figure_var.savefig(os.path.join(out_plot_dir, name_plot_var))
plt.close()

color_dot = cfg.analysis.method.color
style_dot = cfg.analysis.method.style
options_labels = {'label-y': "name_to_plot",
'label-n': ""} # when empty string, no dot labels

# scatter: save both versions, labeled dots and unlabeled dots:
for choice in options_labels.keys():
labels_column = options_labels[choice]
name_elements = list(tup) + [choice]
scatter_fig: figure.Figure = pca_scatter_plot(
pc_df, var_explained_df, "condition",
"condition", labels_column,
pc_df, var_explained_df, color_dot,
style_dot, labels_column,
ellipses_column=cfg.analysis.method.draw_ellipses)
pca_scatter_2_pdf(scatter_fig, name_elements, out_plot_dir)
plt.close()
Expand Down

0 comments on commit ce48911

Please sign in to comment.