- First commit of redesigned family structure simulation code, meant for public (eventually).
- Original (scripts in a private repository, not a proper package) was not tested systematically, assumed a rigid setup with every individual paired in the next generation and exactly two children per family, and sex retroactively assigned as needed.
- New code draws sex first and respects those values while pairing (resulting in more realistic constraints), allows unpaired individuals (fixes cases in old setup where pairing everybody was impossible and restarts were required, which in extreme cases led to infinite loops), variable number of children per family (constrained to target population size, which may vary per generation).
- Also, new code for calculating kinship and admixture matrices, and drawing genotypes, work for arbitrary FAM tables (i.e. arbitrary pedigrees). Again, old code was very rigid in assuming non-overlapping generations and fixed family sizes, and accepted a more limited data structure for the same reason.
- This early version is thoroughly tested, but not documented at all. No functions are exported.
- Documented (Roxygen2) and exported main functions:
sim_pedigree,kinship_fam,admix_fam,draw_geno_fam,draw_sex,prune_fam. - Function
sim_pedigree: madenfirst and only mandatory argument (used to be second), nowGis second (used to be first) and defaults toG = length(n). - Fixed import namespaces, other minor changes to pass R checks.
- Function
sim_pedigreenow assigns IDs withoutgprefix (format is just\d+-\d+with two integers denoting generation and index, separated by a dash).
- Function
sim_pedigreenow returns parents of founders asNA(used to be0). - All functions that accept a FAM table as input now treat
NAparents correctly as missing (i.e., those individuals with missing parents are treated as founders), and by default the empty strings ('') and zero (0) are also treated as missing (used to be only0was treated as missing).
- Added vignette with beautiful examples!
- Added README
- Added documentation for package entry (
simfam-package). - Fixed wording in DESCRIPTION and vignette.
- Function
sim_pedigreeremovedverboseoption (it was a holdout from original code, which could get stuck in some situations; the new code doesn't get stuck).
- Function
sim_pedigreenow returnsids(ids of IDs separated by generation) among its list elements, afterfambut beforekinship_local.
- Added function
draw_geno_last_genfor drawing genotypes for last generation only, of a pedigree with non-overlapping generations, saving lots of memory when the number of generations is large (behavior resembles original function, though internally it's a wrapper around the more generaldraw_geno_fam).
- Rewrote core of function
draw_geno_famin C++ (usingRcpp). New version is much faster and uses about half as much memory as the previous pure-R version!
- Added function
kinship_last_genfor calculating kinship for last generation only, of a pedigree with non-overlapping generations, saving lots of memory when the number of generations is large (behavior resembles original function, though internally it's a wrapper around the more generalkinship_fam). - Other functions now inherit parameters, the main function being
draw_geno_fam(for the other*_famfunctions, which are respectively sources for*_last_genfunctions). - Removed obsolete comments.
- Added function
admix_last_gen. same deal as previous*_last_genfunctions (less coding in practice, memory savings). - Fixed some minor typos in other functions, added
drop = FALSEin some necessary cases.
- Dropped redundant
draw_prefix from genotype functions:draw_geno_fam->geno_famdraw_geno_last_gen->geno_last_gen
- First version publicly available on GitHub!
- Changes prepping for first CRAN submission
- Corrected spelling errors
- Clarified bnpsd dependence (older versions don't propagate names, which the vignette relies upon).
- More changes prepping for CRAN submission (based on feedback from another new package).
- Added bioRxiv paper reference to description.
- Reset
par()in vignette examples.
- First CRAN submission!
- README
- Uncommented CRAN installation instructions
- Corrected GitHub installation instructions to use
build_vignettes = TRUEinstead ofbuild_opts = c()(which did not build vignettes anymore).
- Function
draw_couples_nearestremoved unnecessary checks (redundant with unit tests) - Added file
cran-comments.md. - DESCRIPTION corrected title for proper title case
- 2nd CRAN submission!
- Tests: adjusted sample sizes in an internal unit test to make a particular
sim_pedigreeerror rate ~100x less likely than before (error due to not being able to pair everybody; previously, this unlikely error expected 0.4% of the time actually occurred on CRAN, now it is expected 0.002% of the time).
First set of updates for simulating with recombination!
- Updated reference DOI to newest preprint
- Added functions
recomb_famandrecomb_init_foundersfor simulating recombination breaks for a pedigree!- These breaks are on genetic distance only so far.
- Other nice features (drawing genotypes, calculating kinship, or local ancestry) are not yet present but they are planned.
- Added simplified human genome recombination maps (data) and the functions used to create them.
- Added function
recomb_map_fix_ends_chrto shift and extrapolate genetic map to chromosome ends. - Added function
recomb_map_simplify_chrto simplify genetic maps by removing rows that can be interpolated to within a desired error. - Added and documented data
recomb_map_hg38andrecomb_map_hg37, which was created from existing maps processed by the above two functions.
- Added function
- Functions
recomb_famandrecomb_init_foundersslight change in input and output formats: each chromosome list now has columnposgindicating end of recombination block in genetic position (the column used to be calledend; changed to match notation in recombination map, whereposis position in base pairs andposgis in genetic distance). - Function
recomb_init_foundersargumentlengsmay now be a recombination map for simplicity, from which the desired chromosome lengths are extracted, rather than having to extract them in a separate step. - Added function
recomb_map_indsto map recombination breaks from genetic positions to base pair coordinates.
- Added function
recomb_last_gen, a wrapper aroundrecomb_famthat processes data in discrete generations and returns the recombination breaks/blocks of the final generation only, to reduce memory usage. Same analogy of previous*_last_genfunctions and their corresponding*_famversions. - Added function
recomb_haplo_indsto construct the haplotypes of descendant individuals given the haplotypes of the ancestors. - Added function
recomb_geno_indsto construct a standard genotype matrix from the haplotypes of individuals (a complex nested list structure).
- Added function
fam_ancestorsto construct simple ancestor pedigrees for a single person with a desired number of generations, and automatic names.
- Added function
recomb_admix_indsto produce true population ancestry dosage matrices that parallel genotype matrices, useful for regression models that incorporate local ancestry.
- CRAN submission
- Documentation edits
- Updated hyperlink to raw genetic maps.
- Fixed typos
- Escaped more code to simplify spellcheck in the future.
- Updated
cran-comments.md
- Added a logo for the package, displayed at the top of the
README.mdpage - Minor documentation correction for data
recomb_map_hg.
- Added function
bim_add_posgto calculate genetic positions from base pair positions and a genetic map. - In DESCRIPTION, updated citation to published paper.
- Added function
pop_recombto simulate genotypes with linkage disequilibrium (LD) given a population of haplotypes, using a Li-Stephens-like model of haplotype copying
- Function
pop_recombadded support for optionhapsto be aBEDMatrixobject, and added optionloci_on_colsto accept a transposedhapsinput.
- Function
pop_recombadded optionindexes_locito simulate only a portion of the genome available. - Added functions
tidy_recomb_map_indsandrecomb_founder_blocks_inheritedto create and manipulate tidy versions of our recombination data structure, which are more useful in some cases, currently focused on identifying founder blocks that are inherited by focal individuals.- Added
dplyrandtidyselectas new package dependencies, which is used for both of these new functions that manipulate tidy tables.
- Added
- Added function
geno_last_gen_admix_recombthat efficiently simulates admixed families with LD in the ancestors- Added package dependencies
rlang,Matrix, andmethods, which are used by the new function
- Added package dependencies
- Function
recomb_haplo_indsnow acceptsMatrix-package objects (including sparse matrices) as input haplotype matrix - Function
recomb_admix_indsnow accepts inputs with a single ancestry (which may happen when used throughgeno_last_gen_admix_recomb). Before it required at least two ancestries.
- Sped up the following functions by restricting locus subsets to be contiguous
- Functions
pop_recombandgeno_last_gen_admix_recombadded optionindexes_chr_endsto provided precalculated chromosome end indexes, which can result in improved runtime when looped. - Added function
indexes_chrto precalculate chromosome end indexes, to provide to the above functions if desired. - Function
pop_recomboptionindexes_locinow must be a range (start and end indexes) rather than take on arbitrary values.
- Functions
- Functions
pop_recombandgeno_last_gen_admix_recombfurther optimized based on code profiling, and smarter coding
- Functions
kinship_famandsim_pedigreeadded optionsparseto handle sparse kinship matrices, which reduce memory usage when applicable but are currently slower algorithms otherwise.
- Function
kinship_famruntime optimized for sparse case: internal C++ code has new structure for extracting rows considerably faster (at the expense of somewhat more memory).
- Function
sim_pedigreeoptimized for sparse case: internal C++ code now identifies all close relatives in a single scan of the sparse structure, which is much faster than the repeated queries performed before.