Ingesting and Tidying Data#

xynergy.tidy.tidy(df: DataFrame, dose_cols: list[str], response_col: str | list[str], experiment_cols: str | list[str] | None = None, response_is_percent: bool = True, complete_response_is_0: bool = False, log: str = 'all')#

Prepare data for analysis with Xynergy.

Normalizes column names and response values. Should do most of the data checking for you to determine if something’s off before you start the analyses

Parameters#

df: polars.DataFrame

Contains, minimally, one response and two agent doses per row.

dose_cols: list

A list of exactly two columns names that contain untransformed numeric values of agent dose

response_col: string

The name of the column that contains response data. Can be multiple columns, though they will be unpivoted to a single column.

experiment_cols: list[str] or string, optional

The names of columns that should be used to distinguish one dose pair’s response from another. If none are supplied, two rows with the same doses will be considered replicates. One common application of this might be to provide columns containing the names of drugs used.

response_is_percent: bool, default True

Is the response a percentage (ranges from 0-100) or is it a probability/ratio (ranges from 0-1)?

complete_response_is_0: bool, default False

Is the response reported as (for instance) survival, where a complete response would be 0? Or is it something like (again, for instance) killing, where a complete response would be 1 (in the case of response_is_percent = False) or 100 (in the case of reponse_is_percent = True)

log: string, default “all”

Verbosity of function. Options include “all”, “warn”, and “none”.

  • If “all”, will emit notes and warnings.

  • If “warn”, will emit only warnings.

  • If “none”, will not emit anything (except errors)

Returns#

polars.DataFrame

Each row will contain a single response, with the following columns

  • dose_a, dose_b

    Numeric concentrations of the two agents

  • response

    Will be modified (if necessary) to be ‘% inhibition style’ (0 = no inhibition, 100 = complete inhibition).

  • experiment_id

    Contains integer IDs for each experiment. If experiment_cols = None, all ids will be 1.

  • Any columns supplied to experiment_cols

All other columns will be dropped.