View source: R/bootstrap_blocks.R
| bootstrap_blocks | R Documentation |
This function is designed for developers of packages that add bootstrap
methods to the generics of tidypopgen (e.g. for genotype likelihoods), so
that their replicates resample the same blocks as the methods of
tidypopgen. The loci are divided into non-overlapping blocks
that never span chromosomes, defined as in jackknife_stats_generic() (a
number of SNPs, of base pairs, or a size in centiMorgans), and each
replicate draws as many blocks as there are, with replacement.
bootstrap_blocks(
loci_table,
n_bootstrap,
block_size,
size_unit = c("snp", "cM", "bp")
)
loci_table |
a dataframe including at least a column 'chromosome', and
additionally a column 'position' if |
n_bootstrap |
the number of replicates. |
block_size |
the size of the blocks, in the unit of |
size_unit |
either "snp", "cM" or "bp". If "snp", the block size is in number of loci. If "cM", the block size is in centiMorgans. If "bp", the block size is in base pairs. |
The blocks are drawn with the random number generator of R: set its seed
(e.g. with set.seed()) for reproducible replicates. The matrix of weights
has one value per replicate and block; to bound its memory, its size is
capped at 1e9 values (option tidypopgen.sfs_max_bootstrap_weights).
a list with block_id (the block of each locus, an integer from
1 to the number of blocks, numbered in their order of appearance) and
weights (an integer matrix with the number of times each block, in
columns, is drawn in each replicate, in rows).
example_gt <- load_example_gt("gen_tbl")
set.seed(1)
blocks <- bootstrap_blocks(show_loci(example_gt),
n_bootstrap = 3,
block_size = 2, size_unit = "snp"
)
blocks$block_id
blocks$weights
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.