Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
c603316
init Sasha's approach to tests
dimalvovs Sep 30, 2024
46f56be
add lost files
dimalvovs Sep 30, 2024
48180f4
update testthat linkingg
dimalvovs Sep 30, 2024
0fd0f18
configure.ac fixed; test are enabled by default
favorov Sep 30, 2024
fd3fd90
added REQUIRE
favorov Sep 30, 2024
5fe4d2c
testthat-tweak.h is in ..
favorov Sep 30, 2024
c46dc69
tag \[vector\] added to vector test
favorov Sep 30, 2024
850ef88
testthat provides catch.h
favorov Oct 1, 2024
7d00008
we added the sparce vector test to what we can run
favorov Oct 1, 2024
2b058fc
trying to add testConcurrentAtomicDomain.cpp, build error
favorov Oct 1, 2024
889c8c0
commented nonworking test
favorov Oct 2, 2024
1ff64c6
modified headers in tests to new version
favorov Oct 2, 2024
cc2922b
update cpp test doc
dimalvovs Oct 2, 2024
daf2cd9
additional pmax param
dimalvovs Dec 5, 2024
eb767c3
two arguments and backcompat
dimalvovs Dec 5, 2024
2dd5e18
save debug into a branch
dimalvovs Dec 5, 2024
941281d
Merge branch '85-cpp-tests' into 132-debug
dimalvovs Dec 5, 2024
84dfc65
added random.h and changed AtomicDomain to ConcurrentAtomicDomain; no…
favorov Dec 13, 2024
f93c35d
Revived matrix tests
favorov Dec 13, 2024
e365a26
Added tags to matrix test
favorov Dec 13, 2024
7ab11b3
Startted pad test
favorov Dec 15, 2024
3f79e2e
pad test added, compiled and failed
favorov Dec 15, 2024
bae0dc0
Added pad+sum test to vector and it failed
favorov Dec 16, 2024
88fc63e
vector/matrix pad fixed
favorov Dec 16, 2024
d758b07
added copy assign test
favorov Dec 17, 2024
3efffbc
New uncertainity for dense model compiled
favorov Dec 17, 2024
d5578e6
rm chisq test for now
dimalvovs Dec 17, 2024
0054cd8
update version for functional tests
dimalvovs Dec 17, 2024
b92f66b
Go on debug, it still does not work on old 32bit mac
favorov Dec 18, 2024
a2e0f93
const Matrix & mat and create result instead of Matrix mat and return…
favorov Dec 18, 2024
69be257
added a bit more comments
favorov Dec 18, 2024
280ae96
added operator = to Matrix
favorov Dec 18, 2024
3c41fef
fixed operator= a bit
favorov Dec 18, 2024
dea3ae6
one more debug line
favorov Dec 19, 2024
b0eae5e
operator = is not necessary for Matrix, sorry
favorov Dec 19, 2024
d97d05b
added pmax test
favorov Dec 20, 2024
9e16a2e
shorten names
favorov Dec 20, 2024
e8b5d4b
return created; conxt Vector in patams of pmax
favorov Dec 20, 2024
d8590ef
return created; conxt Vector in patams of pmax
favorov Dec 20, 2024
bd11860
fixing errors
favorov Dec 20, 2024
b27dc16
it compiles
favorov Dec 20, 2024
16a9755
pmax test fails
favorov Dec 20, 2024
db47de2
min and max search were inited with 0; fixed, now init with first ele…
favorov Dec 20, 2024
5741cfc
min and max search were inited with 0; fixed, now init with first ele…
favorov Dec 20, 2024
be8541f
use std::max and std::min instead of gaps::
favorov Dec 20, 2024
dc27053
added tests for 2ar - min and max and for a nondiaginal matrix value …
favorov Dec 20, 2024
5c77d5c
rm fgsea temporarily
dimalvovs Dec 21, 2024
ba38dd5
rm fgsea temporarily
dimalvovs Dec 21, 2024
fcf3a4d
Merge branch '132-uncertainty-improvements' of github.com:FertigLab/C…
dimalvovs Dec 21, 2024
54755b5
fgsea returned
favorov Dec 24, 2024
7733bb2
Dockerfile: we are not to install BiocManager; BiocManager installs f…
favorov Dec 29, 2024
98eaf39
it is more correct to install fgsea by install_requirements
favorov Dec 30, 2024
e39f2a0
upgrade=always added
favorov Dec 30, 2024
62f623a
returned fgsea back to BiocManager::install list
favorov Dec 30, 2024
293f5c5
removed upgrade=always
favorov Dec 30, 2024
009c168
started starse matrix check
favorov Jan 2, 2025
4bdd04a
typo in filename fixed
favorov Jan 3, 2025
1903dc1
sparsematrix cpp test
favorov Jan 3, 2025
18ce2e5
removed temp dwbug output
favorov Jan 4, 2025
0332198
Remove matrix debug lines
favorov Jan 4, 2025
4f0fae3
test for A and P columns to be nonzero
favorov Jan 5, 2025
f883fe8
editing the test title, and no more global vars
favorov Jan 5, 2025
849daa2
parameters test implemented
favorov Jan 6, 2025
daa2de7
THe params objects in the metafata of the results objects were of old…
favorov Jan 9, 2025
b0888ee
added dense sampler cpp test seed
favorov Jan 10, 2025
12e7c53
Added gist matrix part, going on
favorov Jan 10, 2025
0578ec2
Update README.md -- added multiple tag calls
favorov Jan 10, 2025
cc8e8e3
Added sampler updates, going on
favorov Jan 10, 2025
2479d2d
testing, small fixes
favorov Jan 12, 2025
3d4a80a
Merge branch '132-uncertainty-improvements' of github.com:FertigLab/C…
favorov Jan 12, 2025
d144ca2
APamtrix does not change, tests say om Intel MAC
favorov Jan 12, 2025
9d6709e
tests for A and P matrix added
favorov Jan 13, 2025
0058a9e
added more comments
favorov Jan 14, 2025
4fb2a2d
tiny matrix multiplication test
favorov Jan 14, 2025
9027397
Now, we also print the matrices in tiny_matrix test
favorov Jan 15, 2025
d66a0bb
addedi tiny matrix multiplication test for P sampler
favorov Jan 15, 2025
641dca3
swapped A-AP and P-AP outputw
favorov Jan 15, 2025
43289b3
now, the matrix test is ok -- looking for other reasons
favorov Jan 17, 2025
5b6c1cf
added one output, now, the test illustrates the dimesions of data, A …
favorov Jan 17, 2025
2d9e72d
Started dev notes here
favorov Jan 20, 2025
06b26f6
A(P) sampler notes started
favorov Jan 20, 2025
d932d61
eq test
favorov Jan 20, 2025
76f1c5e
eq test goes on
favorov Jan 20, 2025
995a160
eq test goes on
favorov Jan 20, 2025
1c70a27
note goes on
favorov Jan 20, 2025
056cb32
typo in \times
favorov Jan 20, 2025
1eb3001
note goes oni, matrix sizes are there
favorov Jan 20, 2025
7d9e1d6
note goes oni, P matrix sizes are there
favorov Jan 20, 2025
bc451f5
note goes oni, P matrix name is there
favorov Jan 20, 2025
1fbbaa2
A(P) sampler note is written.
favorov Jan 21, 2025
03a9095
Update AtomicDomain.h
favorov Apr 3, 2025
6209b84
Update AtomicDomain.cpp
favorov Apr 3, 2025
91a1a1c
Update AtomicDomain.cpp
favorov Apr 3, 2025
e90d3c4
Update AtomicDomain.h
favorov Apr 3, 2025
f229b19
Update AtomicDomain.h
favorov Apr 3, 2025
9647391
Atom.h
favorov Apr 4, 2025
653c2b6
Converting all index types to size_t, looks like completed.
favorov Apr 4, 2025
fdfcd37
Converting all index types to size_t, random32 -> random64, get error…
favorov Apr 4, 2025
e3f1b60
changed the key mutation operation (atom move) to more safe erase+ins…
favorov Apr 5, 2025
eb03e16
commented s bit
favorov Apr 5, 2025
91e1c54
added atomic space test, we need it
favorov Apr 5, 2025
8d630bb
moved erase, insert and move to public
favorov Apr 5, 2025
3a57384
Check what map insert returns; there wad undefined behaviour when rei…
favorov Apr 6, 2025
06197de
insert pass ok, erase kills the program
favorov Apr 6, 2025
be04836
even one erase kills
favorov Apr 6, 2025
d66aed4
unset left/right index added
favorov Apr 6, 2025
5969453
unset left/right used
favorov Apr 6, 2025
3ebef56
erase rewritten
favorov Apr 7, 2025
58c71d8
output pos() in erase test
favorov Apr 7, 2025
919e121
separated case for random atom
favorov Apr 7, 2025
70112ca
Started to test GapsRng
favorov Apr 7, 2025
15513f3
comments
favorov Apr 7, 2025
c0915a4
added random atom index get
favorov Apr 7, 2025
dc82d4f
size_t tests
favorov Apr 7, 2025
084bfd3
more saparate tests
favorov Apr 8, 2025
feca8ce
Added GAPS_ASSERT size()gt 0
favorov Apr 8, 2025
12af14a
stepwize test randomatom
favorov Apr 8, 2025
e802c6c
better way to make asserts prototyped
favorov Apr 8, 2025
37edc1f
Fix of section name, fro, -> from
favorov Apr 8, 2025
815a160
commented the ConcurrentDomain, hope, temporary
favorov Apr 9, 2025
896aade
asserts returned to the life
favorov Apr 9, 2025
27c6d55
added asserts to Random*
favorov Apr 9, 2025
ce96ebf
Added REQUIRE_THROWS
favorov Apr 9, 2025
6006c12
Added assert to check wheter lower boundary is actually lower
favorov Apr 9, 2025
b849fbd
Added (0,2) test
favorov Apr 9, 2025
d2300f3
MutableMap is unsafe; we omit now
favorov Apr 9, 2025
3b4e932
Added REQUIRE_THROWS, now can run all atomic tests by the common test…
favorov Apr 9, 2025
9dadfc3
Removed MutableMap; made the erase consistent; edited assert
favorov Apr 9, 2025
6b7b4c6
Comments
favorov Apr 9, 2025
fc70ec6
added const access to atomic storage and to map
favorov Apr 9, 2025
39acd9e
moved const methods to public
favorov Apr 9, 2025
b52b86b
test structure on 4 atoms
favorov Apr 9, 2025
bd474fa
added test of move and etase
favorov Apr 10, 2025
89100aa
updated indices of the atom in neighbour atoms after we mome tha atom…
favorov Apr 10, 2025
d12f741
changing --enable-debug to --enable-gaps-debud and adding --enable-de…
favorov May 1, 2025
0acd91f
explain how to pass options to configure in load_all()
favorov May 1, 2025
3f4c7ab
typos fixed
favorov May 1, 2025
1134cf1
--enable-debug and --enable-gaps-debug now accept only yes or no
favorov May 1, 2025
7f469a3
Now, we do not use static_cast<uint_64t> to get unsigned value of the…
favorov May 2, 2025
849f683
#include <cstdint> explicitely
favorov May 2, 2025
ac8a2e1
test for platform, old mac clang loose correct value when voverting d…
favorov May 5, 2025
abcacab
added <limits>
favorov May 6, 2025
ec5b7b6
test is more verbose ans easy to understand
favorov May 7, 2025
f5bff5e
configure version changed
favorov Jun 23, 2026
bfd5e09
Fix SIMD NaN in alphaParameters on Mac Intel (SSE4/AVX)
favorov Jun 23, 2026
92e9647
context for branch 132
favorov Jun 26, 2026
60f9406
Fix SIMD_PAD to prevent compiler auto-vectorization OOB on ARM
favorov Jun 27, 2026
b4beed4
issue with 8 added
favorov Jun 28, 2026
ffa4770
Reformat non-compiled test files to match active test format
favorov Jun 28, 2026
5b18bda
Fix grammar
favorov Jul 1, 2026
83e85a5
Added fileparser, sorted
favorov Jul 1, 2026
7f0754e
4.6.1
favorov Jul 1, 2026
8484dff
Math.h instead of math.h
favorov Jul 1, 2026
a2ed06b
Fix testFileParsers: remove duplicate includes, use system.file() for…
favorov Jul 1, 2026
172a3d1
Add pull_request trigger to build-push-container workflow
dimalvovs Jul 1, 2026
7025d9c
fixed
favorov Jul 2, 2026
50baf35
HashSets
favorov Jul 2, 2026
593401e
Merge branch '132-uncertainty-improvements' of github.com:FertigLab/C…
favorov Jul 2, 2026
2408780
minor edit in case name
favorov Jul 2, 2026
908bdf8
Hybrid added
favorov Jul 2, 2026
aa2495c
Fix stale iterator in AtomicDomain::move()
favorov Jul 3, 2026
e32ce54
Prepare documantation for next steps
favorov Jul 4, 2026
8145ef9
english version of tsklist to remove async
favorov Jul 4, 2026
dab57f2
Fix gaps::min/max(SparseVector) segfault on empty sparse vector
favorov Jul 5, 2026
989db34
Enable more C++ unit tests in the build
favorov Jul 6, 2026
0b599b3
Remove the asynchronous (OpenMP) Gibbs sampler
favorov Jul 6, 2026
551add5
Add post-async-removal test-coverage & suspicious-code audit
favorov Jul 7, 2026
3a4a293
Fix checkpoint deserialization of SingleThreadedGibbsSampler (>> not <<)
favorov Jul 7, 2026
581e8b5
Guard gaps::nonZeroMean against an all-zero matrix (0/0 = NaN)
favorov Jul 7, 2026
f9af5f4
Guard dense/hybrid gaps::min/max/whichMax against empty containers
favorov Jul 7, 2026
f4c06f8
Fill C++ serialization unit tests; fix SparseVector deserialization
favorov Jul 8, 2026
2906309
Remove vestigial maxThreads/asynchronousUpdates fields from GapsParam…
favorov Jul 8, 2026
99ef072
Add --enable-checkpoints configure toggle (off by default)
favorov Jul 8, 2026
7ce04dc
Plans updated: testthet added
favorov Jul 8, 2026
29fb0df
Revive the disabled testRandom distribution tests
favorov Jul 8, 2026
bbd36a5
Make sparseOptimization consistent with the dense sampler (uncertaint…
favorov Jul 10, 2026
2741812
Revive AtomicDomain serialization test; drop superseded GibbsSampler …
favorov Jul 11, 2026
c3b7094
Revive testSparseIterator edge-case tests; drop white-box testSparseV…
favorov Jul 11, 2026
c209456
Exercise update() in the sampler tests and assert chiSq decreases
favorov Jul 12, 2026
7d7ef3e
Guard SparseNormalModel::chiSq() against pre-sync() NULL deref (issue…
favorov Jul 13, 2026
9b711e4
Floor the uncertainty in SparseNormalModel::chiSq(); unify via invSSq…
favorov Jul 13, 2026
dddeb39
Document the dense vs. sparse uncertainty model
favorov Jul 13, 2026
adff8f7
Remove empty SparseNegativeBinomialModel.{h,cpp} placeholder files
favorov Jul 13, 2026
e45b59f
Make test_cpp.R actually gate on the C++ unit tests (Phase 4)
favorov Jul 13, 2026
39d2420
Implement the chi-square consistency test (Phase 4)
favorov Jul 13, 2026
ca49b8e
Clean up .Rbuildignore: exclude planning dir, use .o catch-all (Phase 4)
favorov Jul 13, 2026
079e39e
Document the annotation-weighted subset sampling issue
favorov Jul 13, 2026
8c0bfb3
Drop dead nThreads/asynchronousUpdates entries from allParams (Phase 4)
favorov Jul 14, 2026
b094f6d
Silence distributed-mode warnings in test_output_across_modes (Phase 4)
favorov Jul 14, 2026
2b14871
Merge branch 'master' into 132-uncertainty-improvements
favorov Aug 2, 2026
bfabce3
Stop tracking the local VS Code C/C++ config
favorov Aug 2, 2026
6993307
Recompress the packaged datasets with xz
favorov Aug 2, 2026
5431a6a
Tidy the branch notes; move the static_cast reproducer out of src/
favorov Aug 2, 2026
abde1f9
Add a NEWS entry for the async removal and the uncertainty fixes
favorov Aug 2, 2026
bf53d9a
Add CLAUDE.md
favorov Aug 2, 2026
661a082
Fix scCoGAPS()/GWCoGAPS(), broken by nPatterns becoming mandatory
favorov Aug 4, 2026
4e74b1b
Match the lp vectors in test_patternMarkers.R to nPatterns
favorov Aug 4, 2026
739a575
Update the DESCRIPTION date
favorov Aug 4, 2026
9026ea7
Silence the R CMD check NOTEs and the last two test warnings
favorov Aug 4, 2026
40eb0f5
Fix binaryA(), fromCSV() and show(CogapsParams); cover them with tests
favorov Aug 4, 2026
c7ee623
Add cpp tests for elementSq, dot_diff, mean and sparsity
favorov Aug 4, 2026
a55e459
Regenerate configure from configure.ac; document the aclocal step
favorov Aug 4, 2026
b60f64a
Report each C++ test case as its own testthat expectation
favorov Aug 4, 2026
17e376d
Record the inherited master defects in the branch notes
favorov Aug 4, 2026
dee76c1
Document machine setup; note that commit permission does not carry over
favorov Aug 4, 2026
40139a5
Add an index of the branch notes
favorov Aug 9, 2026
79433b8
Move the developer notes to dev-notes/
favorov Aug 10, 2026
9345c8e
Fold AGENTS.md into CLAUDE.md; move the Russian rules to dev-notes/rus/
favorov Aug 10, 2026
9ad3c9f
Cover issue 20 in the uncertainty write-up; refresh its code map
favorov Aug 11, 2026
82f0d0b
Unhide the Russian rules file
favorov Aug 11, 2026
92ee835
Record the next three tasks in dev-notes/rus/plan-rus.md
favorov Aug 11, 2026
76ce2a2
Document the non-R prerequisites in the setup section
favorov Aug 11, 2026
17bf315
Record the one-pattern stitchTogether crash as inherited defect 6
favorov Aug 11, 2026
d1ceba0
Keep the stitched matrices two-dimensional when there is one pattern
favorov Aug 11, 2026
d9fbe13
Note the zero meanChiSq of distributed runs next to the chi-square task
favorov Aug 11, 2026
b65a58a
Revert changes back to state of 76ce2a25, no 161-distributed-fails-fi…
favorov Aug 12, 2026
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
60 changes: 7 additions & 53 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,24 @@
^\.Rproj\.user$
^ChangeLog

^dev-notes$
^\.vscode
^CLAUDE\.md$

^inst/benchmarks/
^inst/profiling/
^inst/vignettes/

^\.git

^src/Makevars(?!.in$|.win$)
^src/Cogaps.o
^src/GapsParameters.o
^src/GapsResult.o
^src/GapsRunner.o
^src/GapsStatistics.o
^src/RcppExports.o
^src/test-runner.o
^src/atomic/AtomicDomain.o
^src/atomic/ProposalQueue.o
^src/cpp_tests/testAtomicDomain.o
^src/cpp_tests/testDenseGibbsSampler.o
^src/cpp_tests/testFileParsers.o
^src/cpp_tests/testHashSets.o
^src/cpp_tests/testHybridMatrix.o
^src/cpp_tests/testHybridVector.o
^src/cpp_tests/testMatrix.o
^src/cpp_tests/testRandom.o
^src/cpp_tests/testSerialization.o
^src/cpp_tests/testSparseGibbsSampler.o
^src/cpp_tests/testSparseIterator.o
^src/cpp_tests/testSparseMatrix.o
^src/cpp_tests/testSparseVector.o
^src/cpp_tests/testVector.o
^src/data_structures/HashSets.o
^src/data_structures/HybridMatrix.o
^src/data_structures/HybridVector.o
^src/data_structures/Matrix.o
^src/data_structures/SparseIterator.o
^src/data_structures/SparseMatrix.o
^src/data_structures/SparseVector.o
^src/data_structures/Vector.o
^src/file_parser/CsvParser.o
^src/file_parser/GctParser.o
^src/file_parser/FileParser.o
^src/file_parser/TsvParser.o
^src/file_parser/MtxParser.o
^src/gibbs_sampler/AlphaParameters.o
^src/gibbs_sampler/DenseStoragePolicy.o
^src/gibbs_sampler/SparseStoragePolicy.o
^src/math/Math.o
^src/math/MatrixMath.o
^src/math/Random.o
^src/math/VectorMath.o
^src/atomic/Atom.o
^src/atomic/ConcurrentAtom.o
^src/atomic/ConcurrentAtomicDomain.o
^src/file_parser/CharacterDelimitedParser.o
^src/file_parser/MatrixElement.o
^src/gibbs_sampler/DenseNormalModel.o
^src/gibbs_sampler/SparseNormalModel.o

^src/math/VectorMath\.o$
^src/.*\.o$
^src/.*\.so$
^src/.*\.dll$

^nextflow*
^main\.nf
^work*
\.nextflow
\.cirro
^tests/nextflow

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ src/Makevars

# ignore checkpoint files
*.out

# editor / IDE local configs
.vscode/

# built package tarballs
CoGAPS_*.tar.gz
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/opt/homebrew/lib/R/4.6/site-library/**",
"/opt/homebrew/Cellar/r/4.6.1/lib/R/include"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
261 changes: 261 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## What this is

CoGAPS (Coordinated Gene Activity in Pattern Sets) is a Bioconductor R package wrapping a C++
Bayesian MCMC matrix factorization algorithm (GAPS). It factors a data matrix `D ≈ A × P`, where
`A` (featureLoadings) is genes × patterns and `P` (sampleFactors) is patterns × samples, and links
the result to gene set statistics.

Developer notes live in `dev-notes/`, indexed by `dev-notes/README.md` — including the log of fixed
defects (`dev-notes/132-LLM-assisted-solved-issues.md`), which is the best entry point for why the
C++ looks the way it does. Working agreements with the maintainer are in
`dev-notes/rus/agent-rules-rus.md`, the one Russian-language file here. The whole directory is
excluded from the package build via `.Rbuildignore`.

## Setting up a fresh machine

Verified against R 4.6.1 / Bioconductor 3.23.

```r
install.packages("BiocManager")
BiocManager::install(c("devtools", "testthat", "roxygen2", "BiocStyle",
"SingleCellExperiment", "fgsea", "gplots", "SeuratObject"))
devtools::install_deps(".", dependencies = TRUE) # the rest, 21 in DESCRIPTION
```

Three of these are easy to overlook, because nothing fails until it does:

- **`testthat`** is in `LinkingTo`, not just `Suggests` — it ships the Catch2 header
the C++ test suite compiles against. Without it `src/` does not build at all.
- **`xml2`** is what `tests/testthat/test_cpp.R` uses to turn the Catch report into
per-case expectations. It is only suggested, so the test silently falls back to a
single pass/fail check when it is absent.
- **`SeuratObject`** is only needed for `R CMD check`, which refuses to run a
complete check while a suggested package is missing.

Outside R (Homebrew names; use the distro equivalent elsewhere):

```bash
brew install autoconf autoconf-archive pandoc gh
xcode-select --install # macOS only, if the compiler is missing
```

- **`autoconf` + `autoconf-archive`** regenerate `configure`, and only matter when
`configure.ac` changes. `autoconf-archive` supplies the `AX_COMPILER_*` macros —
see the note under Build & test for why `aclocal` has to run first.
- **`pandoc`** builds the vignette: `vignettes/CoGAPS.Rmd` goes through
`VignetteBuilder: knitr` → rmarkdown → pandoc. `R CMD check` builds vignettes, so
without it the check that CI runs fails here even though the package is fine.
(RStudio ships its own copy; a plain shell does not.)
- **`gh`** is not needed to build or test anything — it is how issues and PRs are
read from the terminal. It needs `gh auth login` once per machine.
- The compiler itself comes from the **Xcode Command Line Tools**, not from
Homebrew. Verified against Apple clang 17.

Versions on the current machine: autoconf 2.73, autoconf-archive 2024.10.16,
pandoc 3.10.1, gh 2.97.0.

Do **not** upgrade the generated documentation casually: `DESCRIPTION` pins
`RoxygenNote: 7.3.3`, and running `devtools::document()` under a newer roxygen2
rewrites all 77 `.Rd` files.

## Build & test

All commands are run from the package root.

```r
devtools::load_all() # load package
devtools::load_all(recompile = TRUE) # force C++ recompile
devtools::test() # all R tests
testthat::test_file("tests/testthat/test_top_level.R") # one R test file
devtools::document() # regenerate roxygen2 docs + NAMESPACE
Rcpp::compileAttributes() # after changing // [[Rcpp::export]] signatures
```

```bash
R CMD check --no-manual . # what CI runs (FertigLab/actions r-build-check)

# after editing configure.ac -- BOTH commands, in this order
aclocal -I /opt/homebrew/share/aclocal # autoconf-archive macros
autoconf
```

`autoconf` alone is not enough: `configure.ac` uses `AX_COMPILER_VENDOR` and
`AX_COMPILER_VERSION` from autoconf-archive, and it is `aclocal` that makes them
available. Skipping it leaves both macros unexpanded in `configure`, where they
become literal shell commands — `configure` still completes, but prints
`AX_COMPILER_VENDOR: command not found`, leaves `$ax_cv_cxx_compiler_vendor`
empty, and so silently turns `--enable-warnings` into a no-op. That is the state
`configure` is in on `master`; on this branch it is generated correctly, so keep
it that way. `aclocal.m4` is an artefact of this and is not committed.

Note that `--enable-warnings` currently fails the build with `-Werror`, on
`-Wcast-function-type-mismatch` raised inside Rcpp's own `routines.h` under
newer clang. No CoGAPS source file produces a warning.

`DESCRIPTION` pins `RoxygenNote: 7.3.3`. Running `devtools::document()` under a newer roxygen2
rewrites all 77 `.Rd` files and bumps that field — check the resulting diff before committing it.

### C++ unit tests (Catch2, shipped with the `testthat` R package)

These are **not** exported — reach them with `:::`. The file-parser tests read their data paths
from the global environment, so set `gistCsvPath`/`gistTsvPath`/`gistMtxPath`/`gistGctPath` (with
`<<-`) before calling the runner directly.

```r
CoGAPS:::run_catch_unit_tests() # all, console output
CoGAPS:::run_catch_unit_tests_by_tag("Test Vector.h") # by name
CoGAPS:::run_catch_unit_tests_by_tag("[vector]") # by tag
CoGAPS:::run_catch_unit_tests_by_tag("[vector][green]") # AND
CoGAPS:::run_catch_unit_tests_by_tag("[vector],[green]") # OR
CoGAPS:::catch_test_case_names() # what is compiled in
```

The suite also runs inside `devtools::test()` via `tests/testthat/test_cpp.R`, so a broken C++
test breaks `R CMD check`. That file does **not** use the console form: Catch writes its report
from C++ directly to stdout, where testthat cannot capture it, and one `expect_equal(…, 0L)` would
collapse the whole suite into a single pass/fail. It passes `reporter = "xml"` plus an `output`
file instead, then parses it with `xml2` so each `<TestCase>` becomes its own expectation, named
and located on failure. `output = ""` (the default) still writes to stdout, which is what keeps
the interactive call unchanged.

`catch_test_case_names()` guards against a vacuous pass: with `--disable-cpp-tests`, or on Windows
where `Makevars.win` lists no `cpp_tests` objects, no test case is registered and the runner
returns 0 regardless. The test skips in that case rather than reporting success. See
`src/cpp_tests/README.md` for the longer write-up.

### Build options

Options are declared in `configure.ac`; pass them by setting the matching env var before loading:

```r
Sys.setenv(enable_debug = "yes") # -g -O0
devtools::load_all(recompile = TRUE)
```

Available toggles: `--enable-debug` (`-g -O0`), `--enable-gaps-debug` (`-DGAPS_DEBUG`),
`--enable-cpp-tests` (on by default; disable to cut compile time), `--enable-checkpoints`
(**off** by default — `-DGAPS_DISABLE_CHECKPOINTS` is set unless enabled), `--enable-warnings`
(`-Wall -Wextra -Werror`), `--enable-simd` (on by default; `sse` disables AVX).

`src/Makevars.win` is maintained by hand (Windows has no `configure`): it hard-codes
`-DGAPS_DISABLE_CHECKPOINTS` and lists no `cpp_tests/*.o`, so the Catch suite is empty on Windows
and `test_cpp.R` passes trivially there. Adding a source file means editing **both**
`configure.ac` and `Makevars.win`.

## Architecture

### Layers

```
R/ Public API and S4 classes
CoGAPS.R CoGAPS(), scCoGAPS(), GWCoGAPS() entry points
DistributedCogaps.R subset orchestration, pattern matching, stitching
SubsetData.R how data is split into sets (explicit / weighted / uniform)
class-*.R S4 class definitions + generics
methods-*.R S4 method implementations
HelperFunctions.R input validation, dim names, file/RDS handling
RcppExports.R auto-generated — never edit by hand

src/ C++ core
GapsRunner.cpp/.h C++ entry: gaps::run() (in-memory or from file)
Cogaps.cpp Rcpp glue (cogaps_cpp, cogaps_from_file_cpp)
GapsParameters/Result/Statistics
gibbs_sampler/ DenseNormalModel, SparseNormalModel, SingleThreadedGibbsSampler
atomic/ atomic domain backing the Gibbs sampler
data_structures/ Matrix, SparseMatrix, HybridMatrix, Vector, SparseIterator, ...
file_parser/ CSV / TSV / MTX / GCT readers
math/ Random, VectorMath, MatrixMath, SIMD
utils/ header-only: Archive, GapsAssert, GapsPrint, GlobalConfig
cpp_tests/ Catch2 tests
test-runner.cpp exposes the Catch suite to R (sits in src/, not in cpp_tests/)
```

### Dispatch

`CoGAPS(data, params, nPatterns, ...)` validates inputs, then picks one of three paths:

- `cogaps_cpp` — in-memory matrix (default)
- `cogaps_from_file_cpp` — `data` is a file path
- `distributedCogaps` — `params@distributed` is `"genome-wide"` or `"single-cell"`; splits the data
into subsets, runs them in parallel via BiocParallel, matches patterns across sets
(`findConsensusMatrix`/`patternMatch`), then `stitchTogether`s the result

`nPatterns` is required — the `CogapsParams` initializer errors without it, and the `params`
default is `new("CogapsParams", nPatterns = nPatterns)`. Distributed runs want on-disk data
(mtx/tsv/csv/gct); an in-memory matrix warns.

In `stitchTogether`, the **fixed** matrix must be read from
`result[[1]]@metadata$params@fixedPatterns`, not from the worker's `@featureLoadings` /
`@sampleFactors`: when a matrix is fixed its statistics are never accumulated, so those slots are
all zeros.

### Sampler geometry (see `src/README.md` for the full write-up)

Every run drives two samplers over `D ≈ A × P`. Each sampler owns its own copy of `AP` (synced by
`sync()`, built by `extraInitialization()`), its purpose matrix, an uncertainty matrix the size of
`AP`, and a `const` reference to its counterpart. One sampler of the pair is transposed:

- **ASampler** (transposed when `D` is not transposed): `AP` is l×m, `A` is m×k
- **PSampler** (non-transposed): `AP` is m×l, `P` is l×k
- Invariants: `nrows(MyMatrix) == ncols(APMatrix)`, `ncols(MyMatrix) == k`, and after `sync()`,
`APMatrix == t(other_sampler.APMatrix)`

### Uncertainty model

`S = max(0.1·D, 0.1)` by default — a relative-error model floored so that zeros and `D < 1` get
`S = 0.1`. `DenseNormalModel` materialises it as `mSMatrix`; `SparseNormalModel` never materialises
it (that would defeat sparse storage) and instead recomputes `1/S²` on the fly via the file-local
`invSSq()` helper, with the constant zero-entry uncertainty folded into `mBeta`. The two must agree
— that is what makes `sparseOptimization=TRUE` match a dense run. A user-supplied `uncertainty=`
matrix is used verbatim, and `sparseOptimization` rejects one outright.

**`Vector::pad(val)` fills every allocated element; `padSIMD(val)` fills only the SIMD tail.** Never
use `pad()` on a matrix whose contents matter — that bug silently discarded user uncertainty for
years. SIMD loops read up to `SIMD_INC - 1` elements past the end, so the tail must be non-zero to
avoid `0/0 = NaN`.

### Threading

The asynchronous/OpenMP multi-threaded sampler was **removed** — it broke MCMC detailed balance.
CoGAPS always runs single-threaded. `nThreads` and `asynchronousUpdates` remain in the `CoGAPS()`
signature for backward compatibility, warn when set to a non-default value, and are otherwise
ignored. `compiledWithOpenMPSupport()` is kept, also for compatibility, and always returns `FALSE`.
Do not reintroduce any of these into `allParams` or the C++ parameter struct.

## Conventions

### R

- S4 throughout: new generics go in `class-*.R`, implementations in `methods-*.R`.
- `CogapsResult` extends `LinearEmbeddingMatrix`: `featureLoadings` = Amean, `sampleFactors` = Pmean,
`loadingStdDev` = Asd, `factorStdDev` = Psd.
- Distributed params (`nSets`, `cut`, `minNS`, `maxNS`) cannot be passed to the `CogapsParams`
constructor — the initializer errors out. Use `setDistributedParams()` afterwards.
- `scCoGAPS()` / `GWCoGAPS()` are deprecated wrappers for `CoGAPS(..., distributed = ...)`.
- New files must be added to the `Collate:` field in `DESCRIPTION`.

### C++

- Each Catch2 test file needs both `#include <testthat.h>` and `#include "testthat-tweak.h"`
(the tweak enables tag-based selection). **A test case with no `SECTION` block is never run.**
- Adding any new `.cpp` (source or test) requires adding its `.o` to `GAPS_SOURCE_FILES` in
`configure.ac`, then running `autoconf`. There is no wildcard build.

### Working with the maintainer

- Conversation is in Russian; everything an outside reader sees — comments, docs, README, commit
messages — is in English.
- **Commit only when explicitly asked.** Never commit on your own initiative.
- Do not rewrite history (`rebase -i`, force push) once Bioconductor review has started.
- Don't do things "just in case" without asking; ask rather than guess when something is unclear.
- Comments only where a clarification is genuinely needed.

### Merging master into a long-lived branch

`git checkout --ours <file>` takes the branch's version of the **whole file**, silently discarding
master changes that had merged cleanly elsewhere in it. Use `git checkout -m -- <file>` to get the
real three-way merge back and resolve only the conflicting hunks.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CoGAPS
Version: 3.33.1
Date: 2025-03-11
Version: 3.33.2
Date: 2026-08-03
Title: Coordinated Gene Activity in Pattern Sets
Author: Jeanette Johnson, Ashley Tsang, Jacob Mitchell, Thomas Sherman, Wai-shing Lee, Conor Kelton, Ondrej Maxian, Jacob Carey,
Genevieve Stein-O'Brien, Michael Considine, Maggie Wodicka, John Stansfield,
Expand Down
Loading