
Memorize missingness pattern and randomize attributes
Source:R/memorize_missing.R
memorize_missing.RdUse this function to keep the pattern of missing data (0/1). The pattern can be randomized based on dataset attributes/covariates. This can be useful to generate missingness on simulated dataset with the same number of individuals, populations and markers or to analyze the accuracy of imputation algorithms. A vignette is under construction to leverage this function.
Arguments
- data
A GDS filename or open
SeqVarGDSClassobject.- strata
(optional/required) Required for VCF and haplotypes files, optional for the other formats supported. See documentation of
tidy_genomefor more info. Default:strata = NULL.- randomize
(optional, string) To randomize the missingness of specific attributes. Available options:
"markers", "populations", "individuals" and "overall". All options can be selected in a string,randomize = c("markers", "populations", "individuals", "overall")Default:randomize = NULLwill only keep the original missingness pattern.- filename
(optional) The name of the file (extension not necessary) written to the working directory and containing the missing info. Default:
filename = NULL, the missing info is in the global environment only.grurtakes advantage of the lightweight and speedy file reading/writing packagefst(Lightning Fast Serialization of Data Frames for R) to write the dataframe to the working directory. This file can be used insidegenerate_missing(coming soon) function.
Value
A tidy dataframe in the global environment with columns:
POP_ID, INDIVIDUALS, MARKERS, and in the subsequent
columns, the missingness info coded 0 for missing and 1 for genotyped.
Depending on the value chosen for the argument randomize,
the columns are:
MISSING_ORIGINAL: for the original missing pattern (always present)MISSING_MARKERS_MIX: for the missing pattern randomized by markers (optional)MISSING_POP_MIX: for the missing pattern randomized by populations (optional)MISSING_INDIVIDUALS_MIX: for the missing pattern randomized by individuals (optional)MISSING_OVERALL_MIX: for the missing pattern randomized overall (optional)
Author
Thierry Gosselin thierrygosselin@icloud.com