spacr.toxo
==========

.. py:module:: spacr.toxo




Module Contents
---------------

.. py:function:: custom_volcano_plot(data_path, metadata_path, metadata_column='tagm_location', point_size=50, figsize=20, threshold=0, save_path=None, x_lim=None, y_lims=None)

   Render a volcano plot coloured by T. gondii subcellular localisation.

   Points are placed at ``(coefficient, -log10(p_value))`` and coloured by the
   ``metadata_column`` value on the merged gene metadata. Supports a broken
   y-axis for high ``-log10(p)`` outliers.

   :param data_path: DataFrame or CSV path with ``feature``, ``coefficient``,
       ``p_value`` columns.
   :param metadata_path: DataFrame or CSV path with ``gene_nr`` and the
       ``metadata_column`` values to merge on gene number.
   :param metadata_column: Metadata column that drives point colouring.
   :param point_size: Marker size passed to ``ax.scatter``.
   :param figsize: Side length in inches of the (square) figure.
   :param threshold: Absolute coefficient threshold used to select hits.
   :param save_path: Optional path to save the figure as a PDF.
   :param x_lim: X-axis limits ``[low, high]``. Defaults to ``[-0.5, 0.5]``.
   :param y_lims: None, ``[low, high]``, or ``[[low1, high1], [low2, high2]]``
       for a broken axis.
   :returns: List of ``variable`` names that are significant hits.


.. py:function:: go_term_enrichment_by_column(significant_df, metadata_path, go_term_columns=None)

   Compute and plot GO-term enrichment for each requested metadata column.

   For every ``go_term_column`` counts occurrences among hit vs background
   genes, runs Fisher's exact test per term, and produces scatter plots of
   enrichment vs ``-log10(p)`` both per column and combined.

   :param significant_df: DataFrame of screen hits with a ``n_gene`` column.
   :param metadata_path: CSV path holding ``Gene ID`` plus GO-term columns.
   :param go_term_columns: Columns to test. Defaults to the four standard
       Computed/Curated GO categories.
   :returns: None. Results are displayed as Matplotlib figures.


.. py:function:: plot_gene_phenotypes(data, gene_list, x_column='Gene ID', data_column='T.gondii GT1 CRISPR Phenotype - Mean Phenotype', error_column='T.gondii GT1 CRISPR Phenotype - Standard Error', save_path=None)

   Plot ranked mean phenotype with SE shading and highlight selected genes.

   :param data: DataFrame with gene identifiers and phenotype/error columns.
   :param gene_list: Gene names (or ``TGGT1_<id>`` tags) to highlight.
   :param x_column: Column holding gene identifiers used for matching.
   :param data_column: Numeric column plotted on the y-axis.
   :param error_column: Numeric column used for the SE shading band.
   :param save_path: Optional PDF path to save the figure.
   :returns: None. Displays the Matplotlib figure.


.. py:function:: plot_gene_heatmaps(data, gene_list, columns, x_column='Gene ID', normalize=False, save_path=None)

   Render a viridis heatmap for selected genes across selected metadata columns.

   :param data: DataFrame containing per-gene rows.
   :param gene_list: Genes to include as heatmap rows.
   :param columns: Column names to include as heatmap columns.
   :param x_column: Column holding gene identifiers for row matching.
   :param normalize: When True, min-max scale each gene's row to [0, 1].
   :param save_path: Optional PDF path to save the figure.
   :returns: None. Displays the Matplotlib figure.


.. py:function:: generate_score_heatmap(settings)

   Build combined classification-score and control-fraction heatmaps for a plate.

   Aggregates per-model prediction CSVs across folders, computes the control
   sgRNA mixed-condition fractions, and renders multi-channel heatmaps plus a
   per-channel MAE summary.

   :param settings: Config dict with keys ``folders``, ``csv_name``,
       ``data_column``, ``csv``, ``plateID``, ``columnID``, ``control_sgrnas``,
       and ``fraction_grna``.
   :returns: None. Produces figures and DataFrames as side effects.


