cpprate is a reimplementation of https://github.com/lorinanthony/rate in C++.
Prebuilt binaries are available from the releases page for linux_x86-64, macOS_x86-64, and macOS_arm64.
Build the cpprate
executable with
mkdir build
cd build
cmake -DCMAKE_BUILD_EXECUTABLE=1 ..
make -j
This is a header-only library so simply include "CppRateRes.hpp" or "CppRateRes_mpi.hpp" header in your project.
Input files can optionally be compressed with gzip/bzip2/xz. The format is detected automatically.
Supply the design matrix as a n_observations
xn_snps
comma-separated matrix via the -x
argument and the nonlinear n_posterior_draws
xn_observations
comma-separated matrix via the -f
argument by running
cpprate -x design_matrix_file.csv -f nonlinear_draws_file.csv
this will run the lowrank approximation by default. To run the fullrank approximation, use the --fullrank
toggle (note: can be slow).
Supply posterior draws for the linear coefficients as a n_posterior_draws
xn_snps
comma-separated matrix via the --beta-draws
argument and run
cpprate -x design_matrix_file.csv --beta-draws linear_coefficients_file.tsv
Supply the posterior draws for the linear coefficients as a n_posterior_draws
xn_snps
comma-separated matrix via the --beta-draws
argument by running
cpprate --beta-draws linear_coefficients_file.csv
This will be slower than the lowrank approximation because the underlying model is the same as the fullrank model for nonlinear coefficients.
Testing all variables at once may take a long time and/or a lot of memory. To run the model on only some variables at a time, call
cpprate -x design_matrix_file.csv --beta-draws linear_coefficients_file.tsv --ids-to-test 1,2,3
This will test the first, second, and third variable. Results from several runs may be merged by merging the KLD column in the results and recalculating the RATE column as KLD[i]/sum(KLD)
.
A range of variable ids may be tested by calling
cpprate -x design_matrix_file.csv --beta-draws linear_coefficients_file.tsv --id-start 5 --id-end 8
This will test the 5th, 6th, 7th, and 8th variables. Results from several runs may be merged by merging the KLD column in the results and recalculating the RATE column as KLD[i]/sum(KLD)
.
cpprate can be parallelized in three ways:
-t
argument to parallelize calculation within each SNP (many threads may result in some idling).--ranks
argument to parallelize the calculation over the SNPs (adds a slight memory overhead).-t
and --ranks
to parallelize over both SNPs and within SNPs (try with test sets to figure out the optimal distribution).If in doubt, use -t
.
Build tests with
mkdir build
cd build
cmake -DCMAKE_BUILD_TESTS=1 ..
make -j
Run tests with
bin/runTests
cpprate is licensed under the BSD-3-Clause license. A copy of the license is supplied with the project, or can alternatively be obtained from https://opensource.org/licenses/BSD-3-Clause.