bim_add_posg | R Documentation |
Given a table of base pair positions (a data frame with chromosome and position values), and a genetic map (see recomb_map_hg
), this function calculates genetic positions.
If genetic positions existed in input, they are overwritten.
bim_add_posg(bim, map)
bim |
The table of variants, which is a data.frame/tibble with at least two columns: |
map |
The genetic map, a list of chromosomes each of which is a data.frame/tibble with columns |
Base pair positions are converted to genetic positions from the provided map using linear interpolation, using stats::approx()
with options rule = 2
(out of range cases are set to nearest end's value) and ties = list( 'ordered', mean )
(assume data is ordered, interpolate ties in base pair positions in map using mean of genetic positions).
Output will be incorrect, without throwing errors, if genetic map is not ordered.
The bim
input with new or overwritten column posg
of genetic positions in cM.
Rows with values of chr
that are not numeric or are out of range (for given map
) are unedited if the posg
column was present, or assigned NA
otherwise.
recomb_map_hg
for simplified human recombination maps included in this package.
# let's define a very simple table of base pair positions, with minimal information
library(tibble)
bim <- tibble(
chr = c(1, 1, 2, 2),
pos = c(50, 200, 30, 123) * 1000000
)
# use latest human recombination map
map <- recomb_map_hg38
# now use this function to add genetic positions column to `bim`!
bim <- bim_add_posg( bim, map )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.