opendvp.io.import_thresholds#
- opendvp.io.import_thresholds(gates_csv_path, sample_id=None, log1p=True)#
Read gate thresholds from a CSV file, filter, and optionally log1p-transform for scimap compatibility.
This function loads a CSV file containing gate thresholds, validates required columns, filters out rows with gate values of 0.0 (assumed not gated), optionally selects gates for a specific sample, and can log1p-transform gate values for downstream analysis (e.g., scimap). Logs progress and summary information.
- Parameters:
gates_csv_path (str) – Path to the CSV file containing gate thresholds. Must end with ‘.csv’.
sample_id (str or int, optional) – If provided, only gates for this sample will be returned and the output column will be named accordingly.
log1p (bool, default True) – If True, applies log1p transformation to gate values and formats output for scimap.
- Returns:
Filtered DataFrame containing valid gates, with columns including ‘markers’ and the sample_id (if log1p=True), or the original columns if log1p=False.
- Return type:
pd.DataFrame
- Raises:
ValueError – If the file extension is not ‘.csv’, or required columns are missing.
Example
>>> gates = read_and_process_gates('gates.csv', sample_id='sample1', log1p=True) >>> print(gates.head())