The GEM package provides tools for simulating data and fitting a GEM model using Torch in R. It includes functions to generate synthetic datasets and fit a model based on those data.
Install with:
renv::install("weinstockj/GEM")
Use simulate_data
to generate a synthetic dataset:
This function returns a list containing:
- x: a numeric matrix of predictors with one row for each candidate somatic mutation and one column for each feature
- y: a numeric response vector containing zcore'd age at blood draw
- z: an indicator for whether a candidate mutation is a "real"
- sample_map: a list mapping samples to indices
- true_count and naive_count for model assessment
Fit the GEM model on your data using the fit_model function:
model <- fit_model(x, y, sample_map, lr = 0.1, iters = 180, num_threads = 4L)
The returned list includes:
- Model coefficients (e.g. beta),
- Fitted mutation burden estimates (fitted),
- Loss history, and other parameters.
Please see the "articles" portion of the package website for a brief vignette.
To run the tests for GEM, execute:
devtools::test()
Please cite our manuscript if you use this package in your research.