Qploidy2 is an R package for estimating large-scale copy number variation, ploidy, and aneuploidy from genotyping platform data.
Qploidy2 builds on the original Qploidy package. Qploidy focused on standardizing signals to reduce noise, and its ploidy estimates relied heavily on visual inspection of diagnostic plots. Qploidy2 adds a multipoint Hidden Markov Model (HMM) that combines standardized allele depth ratios (BAF) with total depth or intensity (z-scores) to estimate copy number automatically and robustly.
You can use Qploidy's standardization within Qploidy2, or apply the HMM directly to your data when noise reduction isn't needed.
# Install the development version from GitHub
# install.packages("devtools")
devtools::install_github("Breeding-Insight/Qploidy2")| Function | What it does |
|---|---|
standardize() |
Standardizes allele ratios (BAF) and total depth or intensity (z-scores) against reference samples to reduce noise. |
hmm_estimate_CN_multi() |
Estimates copy number along the genome for many samples in parallel with the HMM (hmm_estimate_CN() for a single sample). |
count_types() |
Classifies samples as euploid, aneuploid, or segmental aneuploid. |
compare_cn_track_summary() |
Shows the copy number of every sample and chromosome in one plot, grouped by sample ploidy and aneuploidy type. |
plot_karyotype() |
Draws a sample's karyotype with the copy number of each chromosome and ISCN-style notation. |
plot_cn_track() |
Plots BAF, z-scores, and copy number calls along the genome for one sample. |
write_hmm_CN() |
Writes the results to files, for sharing or for curation in GenoBrew. |
A minimal workflow, assuming data, genos, and geno.pos are already prepared (see the Prepare input files tutorial):
library(Qploidy2)
std <- standardize(data = data, genos = genos, geno.pos = geno.pos,
ploidy.standardization = 4)
res <- hmm_estimate_CN_multi(qploidy_standarize_result = std,
cn_grid = 2:6, n_cores = 2)
filt <- filter_hmm_CN(res, min_CN_reliability = 0.5)
count_types(filt)
compare_cn_track_summary(filt)
plot_karyotype(filt, sample_name = "Sample1")
plot_cn_track(hmm_CN = filt, qploidy_standarize_result = std, sample_id = "Sample1")
write_hmm_CN(filt, prefix = "my_results")For choosing parameters, filtering samples, and re-standardizing, follow the alfalfa tutorial, which walks through a complete analysis.
- Prepare input files: building
data,genos, andgeno.posfrom VCF, Axiom, or Illumina files. - Aneuploidy detection with DArTag markers in an alfalfa F1 population: large-scale copy number estimation in an alfalfa mapping population using DArTag sequencing data.
- Understanding CN reliability: What the score means and what to expect in common scenarios.
- Sex chromosomes in Qploidy2: Inferring sex and sex-chromosome copy number with an XY example.
- Qploidy2 and nQuack integration: the same population analyzed with nQuack's EM-based BAF model selection.
Files written by write_hmm_CN() can be uploaded to the GenoBrew Shiny app. Its CNV profiles tab lets you inspect the BAF, z-score, and copy number plots interactively, re-run the HMM with adjusted parameters for specific samples, and update the results.
See the GenoBrew repository and tutorial for more information.
Qploidy2 ships two agent skills that guide an AI agent through the analysis. They follow the open Agent Skills format, so they work in Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI and other agents that support skills. See each skill for what it covers:
qploidy2-input-prep: preparing the inputs.qploidy2-analysis: running the analysis.
From R, in your analysis project folder (copies the skills of your installed Qploidy2 version, no internet needed):
Qploidy2::install_claude_skills() # Claude Code: .claude/skills/
Qploidy2::install_claude_skills(dest_dir = file.path(getwd(), ".agents", "skills")) # Codex, Cursor, Copilot, Gemini CLIWith npx skills (requires Node.js; installs the latest skills from GitHub and detects your agents):
npx skills add Breeding-Insight/Qploidy2
npx skills add Breeding-Insight/Qploidy2 -a claude-code -a codex # choose agentsOpen the project folder in your agent and the skills load automatically. In Claude Code, invoke one with /qploidy2-analysis, or describe what you want and Claude picks the relevant skill. Copy the skill folders to ~/.claude/skills/ (or your agent's global skills folder) to use them in every project.
In claude.ai (web or desktop app): download the skill folders from inst/skills/, each with its references/ folder, and add them as custom skills in the app's settings.
Agents without skill support: ask the agent to read qploidy2-analysis/SKILL.md inside the folder given by system.file("skills", package = "Qploidy2"), or add that instruction to your project's AGENTS.md.
/qploidy2-input-prep Help me prepare my input files from this VCF
/qploidy2-analysis Run the HMM on my samples
Contributions are welcome! To contribute, fork the repository and open a pull request against the development branch. For major changes, open an issue first to discuss your ideas.
If you find a bug or want an enhancement, please open an issue here.
Run citation("Qploidy2") in R for the references in BibTeX format.
Manuscript in preparation. Until it is published, please cite the software with its Research Resource Identifier, RRID:SCR_028622, and the package version you used:
Taniguti, C. H. et al. Qploidy2: Estimation of large-scale copy number variation using genotyping data. Manuscript in preparation. R package available at https://github.com/Breeding-Insight/Qploidy2 (RRID:SCR_028622).
Taniguti, C. H., Lau, J., Hochhaus, T., Arias, D. C. L., Hokanson, S. C., Zlesak, D. C., Byrne, D. H., Klein, P. E., & Riera-Lizarazu, O. (2025). Exploring chromosomal variations in garden roses: Insights from high-density SNP array data and a new tool, Qploidy. The Plant Genome, e70044. https://doi.org/10.1002/tpg2.70044
Gaynor, M., Landis, J., O'Connor, T., Laport, R., Doyle, J., Soltis, D., Ponciano, J., & Soltis, P. (2024). nQuack: An R package for predicting ploidal level from sequence data using site-based heterozygosity. Applications in Plant Sciences, 12(4), e11606. https://doi.org/10.1002/aps3.11606
This work was funded in part by the Robert E. Basye Endowment in Rose Genetics, Dept. of Horticultural Sciences, Texas A&M University, and by USDA's National Institute of Food and Agriculture (NIFA) Specialty Crop Research Initiative (SCRI) projects "Tools for Genomics-Assisted Breeding in Polyploids: Development of a Community Resource" (Award No. 2020-51181-32156) and "Developing Sustainable Rose Landscapes via Rose Rosette Disease Education, Socioeconomic Assessments, and Breeding RRD-Resistant Roses with Stable Black Spot Resistance" (Award No. 2022-51181-38330).
Supported by Breeding Insight.
Parts of the code, unit tests, and documentation of Qploidy2 were developed with the
assistance of GitHub Copilot and
Claude Code (Anthropic; Claude Opus and Sonnet models),
used for code review, bug fixing, implementing features specified by the authors, writing
tests, and drafting documentation. All AI-assisted changes were reviewed, tested, and
approved by the package authors, who take full responsibility for the code and its
scientific content.
