This skill fits continuous trajectories to BULK or time-resolved omics where the x-axis is MEASURED experimental time (hours, days, developmental stage) or a pseudobulk value aggregated over real time - it is explicitly not single-cell pseudotime. Two complementary jobs: penalized-spline GAMs (mgcv) model gradually curving trends and test whether expression changes or differs between conditions, while changepoint methods (segmented, ruptures) locate discrete regime shifts. Three decisions gate correctness before any p-value: the distributional scale (raw overdispersed counts need nb() plus a library-size offset, not Gaussian), residual autocorrelation across ordered timepoints (which inflates smooth-term significance if ignored), and whether the mechanism is gradual (GAM) or genuinely abrupt (changepoint). The basis dimension k is a flexibility ceiling below the number of timepoints, not a knot count; REML picks the realized wiggliness and edf reports it.
install.packages(c('mgcv', 'segmented'))
BiocManager::install('tradeSeq')
pip install ruptures numpy matplotlib pandas
Tell the AI agent what to model: - "Fit smooth GAM curves to my gene expression over time and test which genes change" - "My input is raw counts - model them on the correct distributional scale" - "Test whether treated samples diverge from controls over time with a difference smooth" - "My timepoints are correlated - handle residual autocorrelation in the GAM" - "Detect changepoints where expression shifts abruptly, and check the shift is real"
"Fit a generalized additive model to each gene in my RNA-seq time-course and report which genes have significant temporal trends after FDR correction."
"I have 10 timepoints of variance-stabilized expression. Fit smooth curves and give me the effective degrees of freedom per gene, using REML."
"My data are raw RNA-seq counts with varying library sizes. Fit a negative-binomial GAM with a library-size offset rather than a Gaussian model."
"My samples are a single series measured repeatedly over time, so timepoints are correlated. Fit a GAM that models the residual autocorrelation and check the residual ACF."
"I have time-course RNA-seq from WT and KO mice. Test which genes have diverging temporal trajectories using an ordered-factor difference smooth."
"Compare drug-treated vs untreated expression curves over time and give me a single p-value for whether the trajectories differ."
"Find genes where expression shifts abruptly during my developmental time course, and confirm the shift is a real regime change rather than a smooth ramp."
"Detect breakpoints in my temporal expression data. Distinguish a slope change from a level jump, and tell me when the regime shifts."
"For each gene, compare a smooth GAM against a linear fit by AIC and report whether non-linear modeling is warranted."
family=nb() with offset(log(library_size)), or model vst/log-CPM valuesnp.var(np.diff(signal))/2, not total variance, or the BIC penalty under-detects; use model='l2' for level shifts (BIC is derived for it) and calibrate 'rbf' empirically[min(time), max(time)]; the spline and its interval diverge past the data