Skip to content

Commit

Permalink
more clearly label the plots
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jun 7, 2024
1 parent f9df653 commit 90d6c22
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def prepare_tasks(input_imzml_path: Path, work_dir: Path) -> list[Path]:
folders = set_up_work_dir(work_dir, input_imzml_path, input_mass_list)
requested_files = get_all_output_files(folders)

exp_files = [work_dir / input_imzml_path.stem / "exp_compare_cluster_stats.pdf"]
combined_dir = work_dir / input_imzml_path.stem
exp_files = [combined_dir / "exp_compare_cluster_stats.pdf",
combined_dir / "exp_plot_compare_peak_density.pdf"]
return requested_files + exp_files


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from pathlib import Path
from typing import Annotated

import polars as pl
import typer
import vegafusion
from typer import Option, Argument

from depiction_targeted_preproc.workflow.qc.plot_peak_density import plot_density_combined


def exp_plot_compare_peak_density(
tables_marker_distances_calib: Annotated[list[Path], Argument()],
output_pdf: Annotated[Path, Option()],
) -> None:
vegafusion.enable()

table = pl.concat(
[pl.read_parquet(path).with_columns(variant=pl.lit(path.parents[1].name)) for path in
tables_marker_distances_calib])

plot_density_combined(df_peak_dist=table, out_pdf=output_pdf)


if __name__ == "__main__":
typer.run(exp_plot_compare_peak_density)
13 changes: 12 additions & 1 deletion src/depiction_targeted_preproc/workflow/experimental.smk
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,15 @@ rule exp_mass_list_preparation:
" --input-csv-path {input.csv}"
" --out-calibration-csv-path {output.calibration_csv}"
" --out-standards-csv-path {output.standards_csv}"
" --out-visualization-csv-path {output.visualization_csv}"
" --out-visualization-csv-path {output.visualization_csv}"


rule exp_plot_compare_peak_density:
input:
tables_marker_distance=expand("{{sample}}/{exp_variant}/qc/table_marker_distances_calib.parquet", exp_variant=exp_variants)
output:
pdf="{sample}/exp_plot_compare_peak_density.pdf"
shell:
"python -m depiction_targeted_preproc.workflow.exp.plot_compare_peak_density"
" {input.tables_marker_distance}"
" --output-pdf {output.pdf}"
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def subsample_dataframe(df: pl.DataFrame) -> pl.DataFrame:


def plot_density_combined(df_peak_dist: pl.DataFrame, out_pdf: Path) -> None:
n_tot = len(df_peak_dist)
df_peak_dist = subsample_dataframe(df_peak_dist)
chart = (
(
Expand All @@ -30,7 +31,7 @@ def plot_density_combined(df_peak_dist: pl.DataFrame, out_pdf: Path) -> None:
.encode(y=alt.Y("density:Q"))
.properties(title="Linear scale")
)
chart = chart.properties(title="Density of target-surrounding peak distances")
chart = chart.properties(title=f"Density of target-surrounding peak distances (n_tot = {n_tot} sampled to n = {len(df_peak_dist)})")
chart.save(out_pdf)


Expand Down
3 changes: 2 additions & 1 deletion src/depiction_targeted_preproc/workflow/rules/rules_proc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ rule proc_calibrate_remove_global_shift:
input:
imzml=multiext("{sample}/corrected.peaks",".imzML",".ibd"),
config="{sample}/pipeline_params.yml",
mass_list="{sample}/mass_list.standards.csv",
#mass_list="{sample}/mass_list.standards.csv",
mass_list="{sample}/mass_list.calibration.csv",
output:
imzml=temp(multiext("{sample}/calibrated.tmp",".imzML",".ibd")),
shell:
Expand Down

0 comments on commit 90d6c22

Please sign in to comment.