Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ $run_dev.*
^CRAN-SUBMISSION$
^README\.md$
^app\.R$
^inst/app$
^\.claude$
^\.httr-oauth$
^CLAUDE\.md$
^AGENTS\.md$
^\.agents$
1 change: 1 addition & 0 deletions .agents/skills
476 changes: 0 additions & 476 deletions .claude/agents/qploidy2-analysis.md

This file was deleted.

1 change: 1 addition & 0 deletions .claude/skills
5 changes: 1 addition & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on:
push:
branches:
- main
- development
pull_request:
branches:
- main
- development

name: R-CMD-check

Expand Down
85 changes: 85 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# AGENTS.md

Instructions for AI coding agents (Claude Code, Codex, Copilot, Cursor, Gemini, and others) working in **Qploidy2**, an R package (CRAN-released) for estimating copy number variation from genotyping data.

## Running a Qploidy2 analysis

If the task is to analyse data with Qploidy2 (not to change the package), follow the skills in `inst/skills/`:

- Preparing the inputs: read [`inst/skills/qploidy2-input-prep/SKILL.md`](inst/skills/qploidy2-input-prep/SKILL.md).
- Running the analysis: read [`inst/skills/qploidy2-analysis/SKILL.md`](inst/skills/qploidy2-analysis/SKILL.md).

Read the `SKILL.md` first. Load files in its `references/` folder only when `SKILL.md` says they are needed.

## Package structure

- `R/` — package source. One topic per file; keep helpers in `*_utils.R` / `utils.R`.
- `man/` — generated by roxygen2. **Never edit `.Rd` files by hand.**
- `NAMESPACE` — generated by roxygen2. **Never edit by hand.**
- `tests/testthat/` — tests, named `test-<topic>.R` (testthat edition 3).
- `inst/` — installed files (`CITATION`, `WORDLIST`, example data, agent skills).
- `docs/` — rendered tutorials/site; not part of the package build.
- `inst/skills/` — agent skills for package users (`qploidy2-input-prep`, `qploidy2-analysis`), in the open Agent Skills format. This is the only copy: `.claude/skills` and `.agents/skills` are symlinks to it, so Claude Code, other agents and `npx skills add` find the skills. `install_claude_skills()` copies them from the installed package. Edit only the files under `inst/skills/`, and update them when a user-facing API they document changes. Keep each `SKILL.md` short; put detail in its `references/` folder.

## Code style

- Follow the tidyverse style guide: 2-space indent, `snake_case` for new objects, `<-` for assignment, spaces around operators, lines ≤ 80–100 chars.
- Match existing naming in a file when it differs (e.g. `hmm_estimate_CN`, `read_hmm_CN`); do not rename existing exported functions.
- Import functions from other packages with roxygen `@importFrom pkg fun` tags, so `NAMESPACE` is generated by roxygen. Do not use `pkg::fun()` for imported packages in package code (exception: packages in `Suggests`, which must be called as `pkg::fun()` after a `requireNamespace()` check). Never use `library()` or `require()` inside package code.
- Do not use `T`/`F`; use `TRUE`/`FALSE`.
- Use `seq_len()` / `seq_along()` instead of `1:length(x)`.
- Avoid `sapply()` in package code where the return type matters; prefer `vapply()` or `lapply()`.
- Validate user inputs early with informative `stop()` messages; use `warning()` for recoverable issues.
- For progress messages, use the package's `vmsg()` (`R/utils.R`), not `message()`, `print()` or `cat()` (`print`/`cat` only in `print` methods). Pass the function's `verbose` argument through and pick the `level` by hierarchy: `0` section header, `1` main step, `2` detail, `3` sub-detail. Use `sprintf`-style placeholders via `...`:
```r
vmsg("Generating standardized BAFs", verbose = verbose, level = 0)
vmsg("Markers removed because of excess of missing data: %s", verbose = verbose, level = 2, n_rm)
```
- Do not change global state (`options()`, `par()`, `setwd()`, RNG seed) without restoring it via `on.exit()`.
- Do not write files outside paths given by the user (or `tempdir()` in examples/tests).
- For dplyr/tidyr non-standard evaluation, use `.data$col` or declare column names in `utils::globalVariables()` to avoid R CMD check NOTEs.

## Documentation (roxygen2)

- Every exported function needs `@title`/description, `@param` for every argument, `@return`, `@examples` (runnable, fast; wrap slow ones in `\donttest{}`), and `@export`.
- Internal helpers get `@keywords internal` and no `@export`.
- After changing roxygen comments, regenerate with `devtools::document()`.
- New words that trip the spell checker go in `inst/WORDLIST`.

## Dependencies

- Do not add a new package to `Imports` without asking first. Prefer base R or packages already imported.
- Packages used only in tests, vignettes, or optional features go in `Suggests` and must be guarded with `requireNamespace("pkg", quietly = TRUE)` (or `skip_if_not_installed()` in tests). Call them as `pkg::fun()`, since they can't be imported.
- Keep `DESCRIPTION` version constraints when they exist.

## Tests

- Add or update tests in `tests/testthat/` for every bug fix and new feature.
- Tests must be fast, deterministic (`set.seed()`), and write only to `tempdir()` / `withr::local_tempfile()`.
- Run a single file with `devtools::test(filter = "<topic>")`; run all with `devtools::test()`.
- Do not delete or loosen existing tests to make them pass without explaining why.

## Checks before finishing a change

1. `devtools::document()`
2. `devtools::test()`
3. `devtools::check()` for changes touching exports, DESCRIPTION, or documentation — aim for 0 errors, 0 warnings, 0 notes.

Report test/check failures honestly with the relevant output.

## NEWS and versioning

- Every user-facing change gets a bullet in `NEWS.md` under the top `# Qploidy2 <version>` heading. Reference functions as `` `fun()` `` and describe behavior changes, new arguments and defaults, and backward compatibility.
- Do not bump the `Version` in `DESCRIPTION` or create release commits unless asked.

## Backward compatibility

- Do not change the defaults, argument order, or output structure of exported functions without flagging it; prefer adding new arguments with defaults that keep old behavior.
- Deprecate before removing exported functions or arguments.

## Git

- Work on `development` (or a feature branch); `main` is the release branch. PRs target `main`.
- Commit or push only when asked.
- Do not commit generated scratch files (`.Rhistory`, `.DS_Store`, large outputs, `.httr-oauth`).
- New top-level files that are not part of the package must be added to `.Rbuildignore`.
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CLAUDE.md

The rules for this repository are in `AGENTS.md`, shared by all AI agents. Claude Code loads it through the import below.

@AGENTS.md
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Qploidy2
Title: Estimation of Large-Scale Copy Number Variation Using Genotyping Data
Version: 1.24.0
Version: 1.27.1
Authors@R: c(person(given='Cristiane',
family='Taniguti',
email = 'ctaniguti@ufl.edu',
Expand Down Expand Up @@ -36,8 +36,8 @@ Description: Provides functions for estimating copy number variation (CNV)
License: AGPL (>= 3)
Depends: R (>= 3.6.0)
biocViews:
Imports:
dplyr,
Imports:
dplyr (>= 1.1.0),
ggplot2,
tidyr,
vroom,
Expand Down Expand Up @@ -67,5 +67,6 @@ Suggests:
plotly,
AGHmatrix,
updog
VignetteBuilder: knitr
Config/testthat/edition: 3
Language: en-US
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export(simulate_standardization_input)
export(simulate_vcf)
export(split_mk_type)
export(standardize)
export(standardized2raw)
export(summarize_cn_mode)
export(summary_to_fitpoly)
export(test_cn_segregation)
Expand Down Expand Up @@ -180,6 +181,7 @@ importFrom(grDevices,png)
importFrom(grDevices,rainbow)
importFrom(graphics,hist)
importFrom(magrittr,"%>%")
importFrom(parallel,clusterCall)
importFrom(parallel,clusterEvalQ)
importFrom(parallel,clusterExport)
importFrom(parallel,makeCluster)
Expand Down Expand Up @@ -220,6 +222,7 @@ importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,unnest)
importFrom(utils,combn)
importFrom(utils,packageVersion)
importFrom(utils,read.csv)
importFrom(utils,read.delim)
importFrom(utils,setTxtProgressBar)
Expand Down
Loading
Loading