scripts.step_1c_fit_hill_curves¶
Fit Hill functions to dTAG-13 dose–response curves of the reporter–repressor.
This module
1) Loads FCS files for dose–response replicates (R1–R3) and NFC. 2) Applies boundary and singlet gates; subtracts NFC-derived backgrounds. 3) Maps plate indices to dTAG-13 concentrations; constructs day-4 steady state. 4) Computes fold-change relative to NTC and normalizes BFP (repressor) levels. 5) Fits Hill curves (fc vs normalized BFP) to estimate K (EC50-like) and Hill n. 6) Saves per-plasmid parameters (CSV) and diagnostic plots (PDFs).
Outputs
plots/Hill_dCas9.pdf plots/Hill_CasRx.pdf plots/Hill-HDAC4-dCas9.pdf plots/Hill-KRAB-dCas9.pdf plots/Hill-KRAB-Split-dCas9.pdf parameters/Hill_parameters.csv
apply_boundary_gate ¶
apply_boundary_gate(df)
Apply coarse FSC/SSC boundary gate.
Parameters¶
df : pd.DataFrame Event table with FSC-A and SSC-A.
Returns¶
pd.DataFrame Subset of events within the rectangle gate.
Source code in scripts/step_1c_fit_hill_curves.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
apply_singlet_gate ¶
apply_singlet_gate(df)
Keep singlets using FSC-H/FSC-A ratio window.
Parameters¶
df : pd.DataFrame Event table with FSC-H and FSC-A.
Returns¶
pd.DataFrame Events passing the singlet gate.
Source code in scripts/step_1c_fit_hill_curves.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
compute_nfc_background ¶
compute_nfc_background(nfc_dir)
Compute NFC background medians (mean of first 3 files).
Parameters¶
nfc_dir : str Directory of NFC .fcs files.
Returns¶
(float, float) Tuple (mBFP_neg, mmCherry_neg).
Source code in scripts/step_1c_fit_hill_curves.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
fit_hill ¶
fit_hill(R_vals, y_vals, start=(0.1, 1.0))
Fit Hill function to data using nonlinear least squares.
Parameters¶
R_vals : array-like Normalized repressor levels (predictor). y_vals : array-like Fold-change (response). start : (float, float), optional Initial guesses (K, n), by default (0.1, 1.0).
Returns¶
(np.ndarray, np.ndarray | None) (popt, pcov) where popt=[K, n]; pcov is covariance matrix or None.
Raises¶
RuntimeError If fewer than 3 finite data points are available.
Source code in scripts/step_1c_fit_hill_curves.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
hill_func ¶
hill_func(R, K, n)
Hill repression function
y = K^n / (K^n + R^n)
Parameters¶
R : array-like Repressor proxy (normalized BFP). K : float Half-maximal constant. n : float Hill coefficient.
Returns¶
np.ndarray Predicted normalized reporter level.
Source code in scripts/step_1c_fit_hill_curves.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
load_flowset_medians ¶
load_flowset_medians(folder)
Load all .fcs files under a folder and compute gated medians.
Parameters¶
folder : str Directory path containing .fcs files.
Returns¶
pd.DataFrame One row per file with medians and '__filename'.
Raises¶
FileNotFoundError If no .fcs files were found.
Source code in scripts/step_1c_fit_hill_curves.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
load_replicate ¶
load_replicate(folder, mBFP_neg, mmCherry_neg)
Load one replicate folder: medians → background subtraction → token parsing.
Parameters¶
folder : str Path to replicate folder with .fcs files. mBFP_neg : float NFC background for BFP. mmCherry_neg : float NFC background for mCherry.
Returns¶
pd.DataFrame Columns: [BV421-A, PE-A, plasmid, guide, dTAG]
Source code in scripts/step_1c_fit_hill_curves.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
median_channels_for_file ¶
median_channels_for_file(fpath)
Compute per-file medians after boundary + singlet gating.
Parameters¶
fpath : str Path to an .fcs file.
Returns¶
pd.Series Numeric medians per channel with '__filename' set to basename (sans extension).
Raises¶
ValueError If required channels are missing.
Source code in scripts/step_1c_fit_hill_curves.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
parse_filename_tokens ¶
parse_filename_tokens(name)
Extract plasmid, guide, and plate-index token (for dTAG concentration).
Parameters¶
name : str Basename of file without extension.
Returns¶
(str, str, str) (plasmid, guide, dtag_idx_token)
Source code in scripts/step_1c_fit_hill_curves.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
save_hill_plot ¶
save_hill_plot(df, fit_params, out_pdf)
Save Hill fit plot (fc vs normalized BFP) to PDF.
Parameters¶
df : pd.DataFrame Data with columns 'norm.bfp' and 'fc'. fit_params : (float, float) Tuple (K, n) of fitted parameters. out_pdf : str Output PDF filename (saved under OUT_PATH).
Source code in scripts/step_1c_fit_hill_curves.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
theme_castuner_like ¶
theme_castuner_like()
Return a clean plot theme resembling the original R plots.
Source code in scripts/step_1c_fit_hill_curves.py
98 99 100 | |