qc

pyrnaither.stats.qc.compare_replica_plates(header, dataset, plot_title, col4val, show_plot=False)[source]

For each plate, compares its values across all pairs of experiments. Saves scatter plots of plate i in exp j vs exp k into a single PDF and optionally displays them.

Return type:

str

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • plot_title (str)

  • col4val (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. plot_title: Title for the plot. col4val: Column name to use for boxplot calculation. show_plot: Whether to display the plot.

Returns:

The PDF filename.

pyrnaither.stats.qc.compare_replicate_sd(header, dataset, plot_title, colname4sd, col4anno, show_plot=False)[source]

Computes the per-spot standard deviation across replicates and lays them out in a plate-shaped grid heatmap.

Return type:

str

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • plot_title (str)

  • colname4sd (str)

  • col4anno (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. plot_title: Title for the plot. colname4sd: Column name to use for standard deviation calculation. col4anno: Column name to use for annotation. show_plot: Whether to display the plot.

Returns:

The base filename (without extension).

pyrnaither.stats.qc.compare_replicate_sd_per_screen(header, dataset, plot_title, colname4sd, col4anno, show_plot=False)[source]

Same as compare_replicate_sd, but produces one heatmap per experiment.

Return type:

List[str]

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • plot_title (str)

  • colname4sd (str)

  • col4anno (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. plot_title: Title for the plot. colname4sd: Column name to use for standard deviation calculation. col4anno: Column name to use for annotation. show_plot: Whether to display the plot.

Returns:

List of base filenames.

pyrnaither.stats.qc.compare_replicates(header, dataset, plot_title, col4val, col4anno, plot_design=1, show_plot=False)[source]

Compare replicate measurements pairwise for each experiment.

Return type:

Tuple[str, Tuple[int, int], int]

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • plot_title (str)

  • col4val (str)

  • col4anno (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. plot_title: Title for the plot. col4val: Column name to use for boxplot calculation. col4anno: Column name to use for annotation. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

The base plot name, screen range, and max number of combinations.

pyrnaither.stats.qc.control_density(header, dataset, channel, plot_title, show_plot=False, sup_histo=False)[source]

Plots density estimates of positive vs negative controls, optionally superimposing histograms, and saves to PDF/PNG.

Return type:

str

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

  • sup_histo (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. show_plot: Whether to display the plot. sup_histo: Whether to superimpose histograms.

Returns:

The base filename (without extension).

pyrnaither.stats.qc.control_density_per_plate(header, dataset, channel, plot_title, plot_design=1, show_plot=False, sup_histo=False)[source]

Control density per plate within each experiment.

Return type:

List[str]

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

  • sup_histo (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot. sup_histo: Whether to superimpose histograms.

Returns:

List of base filenames.

pyrnaither.stats.qc.control_density_per_screen(header, dataset, channel, plot_title, show_plot=False, sup_histo=False)[source]

Control density per experiment (screen).

Return type:

List[str]

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

  • sup_histo (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. show_plot: Whether to display the plot. sup_histo: Whether to superimpose histograms.

Returns:

List of base filenames.

pyrnaither.stats.qc.discard_labtek(data, screen_nr, labtek_nr)[source]

Mark all wells on the specified labtek plate in a given screen as controls (SpotType = -1).

Return type:

DataFrame

Parameters:
  • data (DataFrame)

  • screen_nr (int)

  • labtek_nr (int)

Args:

data: DataFrame containing at least columns [‘ScreenNb’, ‘LabtekNb’, ‘SpotType’]. screen_nr: Screen number. labtek_nr: Labtek number.

Returns:

DataFrame with updated SpotType values.

pyrnaither.stats.qc.discard_wells(data, screen_nr, labtek_nr, positions)[source]

Mark specific well positions on a plate as controls (SpotType = -1).

Return type:

DataFrame

Parameters:
  • data (DataFrame)

  • screen_nr (int)

  • labtek_nr (int)

  • positions (Sequence[int])

Args:

data: DataFrame containing at least columns [‘ScreenNb’, ‘LabtekNb’, ‘SpotType’, ‘index’]. screen_nr: Screen number. labtek_nr: Labtek number. positions: 0-based indices within the subset of rows for the given screen and plate.

Returns:

DataFrame with updated SpotType values.

pyrnaither.stats.qc.dr_qual_control(header, data, channel, plot_title, show_plot=False)[source]

Dynamic range quality control: compute DR and plot.

Return type:

Tuple[str, DataFrame]

Parameters:
  • header (List[str])

  • data (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. data: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for DR calculation. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

A tuple containing the DR table filename and updated DataFrame.

pyrnaither.stats.qc.dynamic_range(dataset, channel)[source]

Compute the dynamic range per plate across all screens.

Return type:

ndarray

Parameters:
  • dataset (DataFrame)

  • channel (str)

For each plate (LabtekNb) in each screen (ScreenNb), the dynamic range is:

mean(intensity of negatives) / mean(intensity of positives)

Spots with SpotType == -1 are excluded.

Args:

dataset: DataFrame containing at least columns [‘ScreenNb’, ‘LabtekNb’, ‘SpotType’, channel]. channel: Name of the intensity column to use.

Returns:

A NumPy array of dynamic range values, in order of (screen, plate) sorted by screen then plate.

pyrnaither.stats.qc.make_boxplot_4_plate_type(header, dataset, channel, plot_title, show_plot=False)[source]

Boxplots of channel by ScreenNb (experiment) within each LabtekNb (plate type). Emits one figure per plate type.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.make_boxplot_controls(header, dataset, channel, plot_title, show_plot=False)[source]

Make a boxplot of channel values by control type. Returns the Figure.

Return type:

Figure

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

The Figure object.

pyrnaither.stats.qc.make_boxplot_controls_per_plate(header, dataset, channel, plot_title, plot_design=1, show_plot=False)[source]

Generate boxplots of channel values by SpotType for each plate.

Saves figures per experiment and plate in both PDF and PNG formats.

Return type:

Tuple[int, int]

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

(min_screen, max_screen)

pyrnaither.stats.qc.make_boxplot_controls_per_screen(header, dataset, channel, plot_title, plot_design=1, show_plot=False)[source]

Generate boxplots of channel values by SpotType for each screen.

Saves figures per screen in PDF and PNG formats.

Return type:

Tuple[int, int]

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

(min_screen, max_screen)

pyrnaither.stats.qc.make_boxplot_per_plate(header, dataset, channel, plot_title, plot_design=1, show_plot=False)[source]

Boxplots of channel by LabtekNb (plate) within each ScreenNb (experiment). If plot_design==1, lays out all experiments in a grid on one figure; otherwise emits one figure per experiment.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.make_boxplot_per_screen(header, dataset, channel, plot_title, show_plot=False)[source]

Boxplot of channel by ScreenNb (experiment) for non-control data. Saves a PNG and/or displays interactively.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for boxplot calculation. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.num_cell_qual_control(df, header, plot_title, show_plot=False)[source]

Quality control by number of cells per well.

Return type:

Tuple[DataFrame, str]

Parameters:
  • df (DataFrame)

  • header (List[str])

  • plot_title (str)

  • show_plot (bool)

Args:

df: DataFrame containing at least columns [‘NbCells’, ‘SpotType’, ‘index’]. header: Header lines of the dataset. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

A tuple containing the updated DataFrame and histogram filename.

pyrnaither.stats.qc.perc_cell_qual_control(df, header, plot_title, show_plot=False)[source]

Quality control by percentage of cells per well. Similar to num_cell_qual_control but using ‘PercCells’.

Return type:

Tuple[DataFrame, str]

Parameters:
  • df (DataFrame)

  • header (List[str])

  • plot_title (str)

  • show_plot (bool)

Args:

df: DataFrame containing at least columns [‘PercCells’, ‘SpotType’, ‘index’]. header: Header lines of the dataset. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

A tuple containing the updated DataFrame and histogram filename.

pyrnaither.stats.qc.plot_control_histo(header, dataset, channel, plot_title, show_plot=False)[source]

Plot histogram of controls vs data for a given channel.

Return type:

Figure

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

Args:

header: list of header lines dataset: DataFrame containing ‘SpotType’ and channel columns channel: column name to plot plot_title: title for the plot show_plot: if True, display interactively

Returns:

fig: matplotlib Figure

pyrnaither.stats.qc.plot_control_histo_per_plate(header, dataset, channel, plot_title, plot_design=1, show_plot=False)[source]

Plot histograms per plate. If show_plot or plot_design used to layout subplots, but this function saves to file.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for histogram calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.plot_histo(header, dataset, channel, plot_title, show_plot=False)[source]

Simple histogram of all non-control data in a channel.

Return type:

Figure

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for histogram calculation. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

The Figure object.

pyrnaither.stats.qc.plot_histo_per_plate(header, dataset, channel, plot_title, plot_design=1, show_plot=False)[source]

Histogram of data per plate (non-controls only). Saves one PNG per experiment.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for histogram calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.plot_histo_per_screen(header, dataset, channel, plot_title, plot_design=1, show_plot=False)[source]

Histogram of data per screen (non-controls only). Saves one PNG per screen.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for histogram calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.plot_qq(dataset, channel, plot_title, show_plot=False)[source]

Q-Q plot of data (non-controls only) against a normal distribution.

Return type:

Figure

Parameters:
  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

Args:

dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for Q-Q plot calculation. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

The Figure object.

pyrnaither.stats.qc.plot_qq_per_plate(header, dataset, channel, plot_title, plot_design=1, show_plot=False)[source]

Per-plate Q-Q plots saved as PNGs per experiment.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for Q-Q plot calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.plot_qq_per_screen(header, dataset, channel, plot_title, plot_design=1, show_plot=False)[source]

Per-screen Q-Q plots saved as a single PNG.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • channel (str)

  • plot_title (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. channel: Channel to use for Q-Q plot calculation. plot_title: Title for the plot. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.read_dataset_with_header(file_path, nb_header, sep='\\t')[source]

Read a dataset file with a given number of header lines.

Return type:

Tuple[List[str], DataFrame]

Parameters:
  • file_path (str)

  • nb_header (int)

  • sep (str)

Args:

file_path: Path to the dataset file. nb_header: Number of header lines. sep: Separator used in the dataset file.

Returns:

A tuple containing the header lines and a DataFrame.

pyrnaither.stats.qc.replicates_cv(header, dataset, plot_title, col4val, col4anno, plot_design=1, show_plot=False)[source]

Plot coefficient of variation (CV) vs mean intensity per screen. Saves PNG per experiment.

Return type:

None

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • plot_title (str)

  • col4val (str)

  • col4anno (str)

  • plot_design (int)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. plot_title: Title for the plot. col4val: Column name to use for CV calculation. col4anno: Column name to use for annotation. plot_design: Layout design for subplots. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.replicates_spearman_cor(header, dataset, flag, col4val, col4anno, file_suffix)[source]

Compute Spearman correlations between replicates (flag=1) or across experiments (flag=2). Saves a TSV file and returns its path.

Return type:

str

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • flag (int)

  • col4val (str)

  • col4anno (str)

  • file_suffix (str)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. flag: Flag to indicate whether to compute Spearman correlations between replicates (flag=1) or across experiments (flag=2). col4val: Column name to use for Spearman correlation calculation. col4anno: Column name to use for annotation. file_suffix: Suffix to add to the output file name.

Returns:

The path to the output file.

pyrnaither.stats.qc.snr_qual_control(df, header, channel, noise, plot_title, show_plot=False)[source]

Compute signal-to-noise ratio (SNR = channel/noise) and plot histograms.

Return type:

None

Parameters:
  • df (DataFrame)

  • header (List[str])

  • channel (str)

  • noise (str)

  • plot_title (str)

  • show_plot (bool)

Args:

df: DataFrame containing at least columns [‘SpotType’, channel, noise]. header: Header lines of the dataset. channel: Channel to use for SNR calculation. noise: Noise to use for SNR calculation. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

None

pyrnaither.stats.qc.spatial_distrib(header, dataset, plot_title, col4plot, col4anno, show_plot=False)[source]

Generate spatial distribution heatmaps per experiment and plate.

Return type:

Tuple[str, Tuple[int, int], Tuple[int, int]]

Parameters:
  • header (List[str])

  • dataset (DataFrame)

  • plot_title (str)

  • col4plot (str)

  • col4anno (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. dataset: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’, channel]. plot_title: Title for the plot. col4plot: Column name to use for boxplot calculation. col4anno: Column name to use for annotation. show_plot: Whether to display the plot.

Returns:

The base plot name, screen range, and plate range.

pyrnaither.stats.qc.z_prime(pos_controls, neg_controls)[source]

Calculate the Z’-factor between positive and negative controls.

Z’ = 1 - 3 * (MAD_pos + MAD_neg) / |median_pos - median_neg|

Return type:

float

Parameters:
  • pos_controls (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

  • neg_controls (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

Args:

pos_controls: Array of positive control measurements. neg_controls: Array of negative control measurements.

Returns:

Z’-factor as a float.

pyrnaither.stats.qc.zprime_qual_control(header, data, channel, plot_title, show_plot=False)[source]

Compute Z’-factor per plate and experiment; save table and plot.

Return type:

Tuple[str, DataFrame]

Parameters:
  • header (List[str])

  • data (DataFrame)

  • channel (str)

  • plot_title (str)

  • show_plot (bool)

Args:

header: Header lines of the dataset. data: DataFrame containing at least columns [‘SpotType’, ‘ScreenNb’, ‘LabtekNb’]. channel: Channel to use for Z’-factor calculation. plot_title: Title for the plot. show_plot: Whether to display the plot.

Returns:

A tuple containing the Z’-factor table filename and updated DataFrame.