This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
CoSIA (Cross-Species Investigation and Analysis) is an R Bioconductor package for comparative transcriptomics. It enables gene expression analysis across six species (human, mouse, rat, zebrafish, fruit fly, C. elegans) using RNA-Seq data from the Bgee database.
# Load package during development
devtools::load_all()
# Regenerate NAMESPACE and man/*.Rd files from roxygen2 comments
roxygen2::roxygenise()
# Run R CMD check
devtools::check()
# Run a single test file
testthat::test_file("tests/testthat/test-filename.R")
# Build vignettes
devtools::build_vignettes()Command-line equivalents:
R CMD build .
R CMD check CoSIA_*.tar.gzThe package is built around a single S4 class CoSIAn with a sequential three-step workflow:
-
getConversion()— maps gene IDs and orthologs across species. SupportsEnsembl_id,Entrez_id, andSymbol. Uses BiomaRt or AnnotationDBI for ID conversion, and HomoloGene or NCBIOrtho for ortholog mapping. Populates theconverted_idslot. -
getGEx()— fetches VST-normalized expression data from ExperimentHub (datasets EH7858–EH7863, one per species). Filters by tissues/species in the CoSIAn object. Populates thegexslot. -
getGExMetrics()— computes Coefficient of Variation (CV) or Shannon Diversity/Specificity (DS) metrics from the expression data. Metric types:CV_Tissue,CV_Species,DS_Gene,DS_Gene_all,DS_Tissue,DS_Tissue_all. Populates themetricslot.
Visualization methods (plotTissueGEx, plotSpeciesGEx, plotCVGEx, plotDSGEx) consume the gex or metric slots and return ggplot2/plotly objects. Utility methods getTissues() and viewCoSIAn() are standalone helpers.
| File | Purpose |
|---|---|
R/CoSIA-class.R |
S4 class definition and constructor validation |
R/CoSIA-getConversion-method.R |
Gene ID/ortholog conversion logic (~1,300 lines) |
R/CoSIA-getGEx-method.R |
ExperimentHub data fetching and tissue filtering |
R/CoSIA-getGExMetrics-method.R |
CV and Shannon entropy metric calculations |
R/CoSIA-plots-method.R |
All visualization methods |
R/CoSIA-globals.R |
Global variable declarations (suppresses R CMD check NOTEs) |
R/zzz.R |
Package load hook |
vignettes/CoSIA_Intro.Rmd |
Primary user guide and usage examples |
All changes made by Claude Code must be recorded in CLAUDE_CHANGELOG.md at the repo root. Add an entry for every session in which changes are made, with the date and a bullet list of what was changed and why.
At the start of every session, read CLAUDE_CHANGELOG.md to understand what has already been changed, what bugs have been fixed, and the reasoning behind non-obvious decisions.
- Documentation: All
.Rdfiles are auto-generated by roxygen2 — edit comments inR/source, then runroxygen2::roxygenise(). Never editman/files directly. - Examples: All exported functions use
@exampleswith\dontrun{}oreval=FALSEto avoid long-running ExperimentHub downloads duringR CMD check. - S4 pattern: Generic defined with
setGeneric(), method defined withsetMethod(). Follow existing patterns for any new methods. - Naming: camelCase for functions/methods (e.g.,
getConversion,plotTissueGEx); snake_case for slot names. - Versioning: Bioconductor-style (
x.y.zwhere oddy= devel, eveny= release). UpdateDESCRIPTIONandNEWS.mdtogether.