Rstudio reproducible analysis
Skill yigityildiz0/scientific-agent-skills/skills/common/rstudio-reproducible-analysis
Use RStudio safely for reproducible scientific and genetics data analysis. Use when creating or repairing an RStudio Project, organizing R scripts and data, managing project-local packages with renv, debugging R code, recording provenance, or handing an analysis to a collaborator. Do not auto-install or update packages, overwrite raw data, save hidden workspace state, or change statistical methods without explicit evidence and validation.From its SKILL.md
npx -y skills add yigityildiz0/scientific-agent-skills --skill rstudio-reproducible-analysisAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
3 things to look at
- 24 days oldThe repository was created 24 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
8.5 KB, ~1.8k tokens by cl100k_base, as published. Nobody here has run it
RStudio Reproducible Analysis
Build an analysis that can be rerun by another researcher from source data to final outputs. Treat the RStudio interface as an editor around a project on disk; the files, lockfile, scripts, inputs, and recorded parameters are the source of truth.
Start with discovery
Before editing or running anything:
- Find the project root. Prefer an existing
.Rproj,renv.lock,.git,_quarto.yml, or explicit user path. Never insertsetwd()just to make paths work. - Inventory
.R,.Rmd,.qmd,DESCRIPTION,renv.lock,.Rprofile, input-data, metadata, notebooks, reports, figures, and tests. - Inspect the actual environment with read-only checks such as
R.version.string,.libPaths(),sessionInfo(),renv::status()when renv is already installed, andpackageVersion()for packages the analysis uses. - Read the study design and data dictionary before choosing transformations, contrasts, models, or plots. Do not infer biological replicates from filenames.
- Separate facts from assumptions. Record unresolved sample labels, units, exclusions, batch variables, reference levels, and missing-value meaning.
Choose the narrow workflow
| Need | Workflow |
|---|---|
| Start or organize an analysis | RStudio Project + explicit folders + numbered scripts |
| Reproduce package versions | Existing renv.lock; renv::restore() only after reviewing the diff and authorization |
| Record a known-good environment | Test first, then renv::snapshot() and review the lockfile diff |
| Write a reproducible report | Use the quarto-authoring skill for .qmd and citations |
| Bulk RNA-seq differential expression | Use bio-differential-expression-deseq2-basics after verifying the design and count matrix |
| Publication plots | Use bio-data-visualization-ggplot2-fundamentals after the statistical result is validated |
| Debug a failure | Reproduce in a fresh R session, reduce to the smallest failing input, inspect classes and versions |
Recommended project shape
Adapt to the existing project instead of forcing a template. For a new analysis, prefer:
study-name/
study-name.Rproj
README.md
renv.lock
renv/
data-raw/ # immutable source exports; never overwrite
data-derived/ # generated, reproducible intermediate data
metadata/ # sample sheet, data dictionary, provenance
R/ # reusable functions
scripts/ # numbered pipeline steps
reports/ # .qmd/.Rmd source
figures/ # generated outputs
results/ # generated tables
tests/ # checks for reusable functions and invariants
Do not duplicate protected or sensitive data into a repository. Check .gitignore, institutional policy, consent, and de-identification requirements before any commit, upload, or sharing step.
Reproducible execution
- Start from a clean R session; do not rely on objects left in
.GlobalEnv. - Configure RStudio to avoid restoring
.RDataand avoid saving workspace images..RDatais not a reproducible dependency record. - Use project-relative paths with
file.path()orhere::here()if already adopted. Keep source inputs read-only and write generated outputs elsewhere. - Put parameters, reference levels, thresholds, seeds, and exclusions in source code or a versioned config file.
- Break the analysis into deterministic steps. Each step checks its inputs, creates named outputs, and fails loudly on invalid dimensions, duplicated identifiers, impossible values, or missing sample metadata.
- Use
set.seed()only for stochastic operations and record the algorithm/package versions when randomness affects results. - Run the complete pipeline in a fresh session or with
Rscriptbefore calling it reproducible. Rendering one notebook cell-by-cell is not an end-to-end test. - Save
sessionInfo()orsessioninfo::session_info()with the released report when package versions materially affect results.
Package safety with renv
Use the installed project policy first. Never run install.packages(), BiocManager::install(), renv::update(), renv::snapshot(), or renv::restore() merely because a package is missing.
# Read-only diagnosis
R.version.string
.libPaths()
if (requireNamespace("renv", quietly = TRUE)) renv::status()
if (requireNamespace("DESeq2", quietly = TRUE)) packageVersion("DESeq2")
For an authorized environment change:
- Back up or commit the current
renv.lockand.Rprofile. - Explain which packages and system dependencies will change.
- Make the smallest project-local change.
- Run the analysis checks and render the report.
- Only after success, snapshot and review the lockfile diff.
- If regression appears, restore the known-good lockfile rather than layering more updates.
Bioconductor packages must be compatible with the installed R/Bioconductor release. Verify with official Bioconductor tooling and installed package documentation; do not mix arbitrary CRAN/GitHub versions into a validated analysis without a recorded reason.
Debugging ladder
- Restart R and rerun the smallest failing command.
- Capture the exact error,
traceback(), object classes, dimensions, names, factor levels, and a privacy-safe minimal input. - Confirm the function comes from the expected package with
getAnywhere()or an explicitpackage::functioncall. - Check the installed help and signature before adapting code:
?package::function,args(package::function),packageVersion(). - Test data invariants: unique sample IDs, matched metadata rows, nonnegative integer counts where required, no hidden unit changes, and expected missingness.
- Fix the cause in source code. Do not silence warnings globally or wrap unknown failures in
try(). - Add a regression check or minimal test, then rerun from a clean session.
Scientific quality gates
Before delivering results, verify:
- Experimental unit and biological replicate are explicit; technical replicates are not treated as independent samples.
- Batch, pairing, repeated measures, interactions, and covariates are encoded intentionally.
- The stated statistical question matches the implemented model and contrast.
- Multiple-testing correction and the tested hypothesis family are reported.
- Effect sizes, uncertainty, sample counts, exclusions, and missing data are shown, not only p-values.
- Gene/transcript identifiers include organism, annotation source, and version; mapping losses and duplicates are reported.
- Every table and figure can be regenerated from scripts and recorded inputs.
- No patient, participant, proprietary, or unpublished data is sent to an external service without authorization.
User-facing output
Report:
- project path and entry point;
- exact run order or command;
- input/output inventory;
- environment and lockfile status;
- checks performed and failures;
- scientific assumptions and limitations;
- files changed, with a rollback path.
Example prompts
- “Bu RStudio projesini baştan sona incele; veri dosyalarına dokunmadan çalıştırılabilir ve yeniden üretilebilir hale getir.”
- “
renv.lockile kurulu paketleri karşılaştır, yalnız gerekli farkları göster; otomatik güncelleme yapma.” - “Bu hata için temiz oturumda minimal örnek üret, veri sınıflarını ve paket sürümlerini kontrol et.”
- “Make this genetics analysis reproducible in RStudio and produce a Quarto report with a recorded session.”
Primary references
- RStudio Projects: https://docs.posit.co/ide/user/ide/guide/code/projects.html
- RStudio IDE User Guide: https://docs.posit.co/ide/user/
- renv workflow: https://rstudio.github.io/renv/
- renv snapshot/restore: https://rstudio.github.io/renv/reference/snapshot.html
- Quarto with R: https://quarto.org/docs/computations/r.html
- Bioconductor installation and release compatibility: https://bioconductor.org/install/
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.