This directory contains the script
plot_selected_interactions_line_plots.py which generates a
variety of time‑series expression visualizations for genes and their
regulators across four time points (T1–T4). The script ingests
pre‑processed count matrices (genes, lncRNA, miRNA, methylation) plus an
interactions table (multi_way_interactions.csv) and
produces several plot types and summary CSVs.
data/cleaned_datasets/
with filenames:
gene_counts_cleaned.csvlncrna_counts_cleaned.csvmirna_counts_cleaned.csvwgbs_counts_cleaned.csv (methylation)<CONDITION>-TPx where
x = 1..4.multi_way_interactions.csv) includes
columns:
geneimprovement_from_regulatorsregulator_types (serialized list with prefixes
mirna_, lncrna_,
methylation_)--include-samples).--facet-by-condition).All plots use per‑entity z‑scores (mean 0, SD 1 across its own time points; for sample-level plots, across all condition/timepoint combinations) to emphasize trajectory shape over absolute magnitude.
You can drive the script in several mutually exclusive modes controlling which genes / regulators are plotted:
| Mode | Flags | Description |
|---|---|---|
| Preview subset (default) | (no selection flags) | Plots the first 8 interaction rows from the interactions file. |
| Single gene (no regulators) | --single-gene <ID or suffix> |
Plots a gene found in the gene counts index whose full ID equals or ends with the provided string; regulators not loaded. Useful for quick inspection. |
| Specific gene with regulators | --gene-with-regulators <gene_id> |
Extracts that gene and its regulator list from the interactions file. |
| Max improvement auto-pick | --auto-max-improvement |
Automatically selects the interaction row with the largest
improvement_from_regulators value. |
Only one of --single-gene,
--gene-with-regulators, or
--auto-max-improvement should be supplied. Priority
order:
--auto-max-improvement--gene-with-regulators--single-geneusage: plot_selected_interactions_line_plots.py [-h]
[--include-samples] [--facet-by-condition]
[--single-gene SINGLE_GENE]
[--color-by-entity]
[--gene-with-regulators GENE_WITH_REGULATORS]
[--auto-max-improvement]
[--interactions-path INTERACTIONS_PATH]
--include-samples Generate per‑entity small multiples
(all conditions + mean).--facet-by-condition Produce panel-per-condition figure
with all entities.--single-gene <STRING> Plot a gene by exact ID or
suffix (no regulators).--color-by-entity Unique color per non‑gene entity in
combined plot.--gene-with-regulators <GENE_ID> Use that gene’s
interaction row regulators.--auto-max-improvement Auto-pick gene with max
improvement.--interactions-path <PATH> Custom path to
interactions CSV.Creates a timestamped directory under output/ with
pattern:
output/<mode>_line_plots_<YYYYMMDD_HHMMSS>/
summary.csv
row<n>_<GENE>_expression.csv
row<n>_<GENE>_line_plot_zscore[_entitycolors].png
row<n>_<GENE>_facet_zscore.png
(optional) row<n>_<GENE>_samples_small_multiples.png
(optional) row<n>_<GENE>_condition_facets.png
summary.csv columns:
python3 code/plot_selected_interactions_line_plots.py
python3 code/plot_selected_interactions_line_plots.py --single-gene FUN_022503 --include-samples --facet-by-condition
python3 code/plot_selected_interactions_line_plots.py --gene-with-regulators FUN_033824 --color-by-entity
python3 code/plot_selected_interactions_line_plots.py --auto-max-improvement --include-samples --facet-by-condition --color-by-entity
python3 code/plot_selected_interactions_line_plots.py --interactions-path path/to/multi_way_interactions.csv --auto-max-improvement
--color-by-entity): unique color per
regulator (Tab20 then HSV fallback), gene remains black.For combined and type-facet plots: z-score per entity across its four timepoint means. For small multiples & condition facets: z-score per entity across all condition+timepoint values (shared scaling across panels within each figure).
ast.literal_eval parsing.--single-gene only the gene itself is plotted
(no regulators) unless you choose a mode that loads regulators.Potential additions (not yet implemented):
| Issue | Cause | Remedy |
|---|---|---|
| “Interactions file not found” | Wrong default path or moved output | Provide --interactions-path explicitly. |
Gene not found for --single-gene |
Suffix doesn’t match any index entry | Confirm exact ID in gene_counts_cleaned.csv. |
| Empty plots (only gene) | Regulators missing from count tables | Verify IDs / preprocessing steps. |
| Legend very long | Many regulators | Use facets or rely on small multiples for detail. |
See root LICENSE file.