Description Usage Arguments Value Examples

View source: R/rescalePopkin.R

Rescales the input kinship matrix *Φ^T* so that the value *φ_min^T* in the original kinship matrix becomes zero, using the formula

*Φ^T' = (Φ^T - φ_min^T)/(1 - φ_min^T).*

This is equivalent to changing the ancestral population *T* into *T'* such that *φ_min^T' = 0*.
If subpopulation labels `subpops`

are provided, they are used to estimate *φ_min^T*.
If both `subpops`

and `phiMin`

are provided, only `phiMin`

is used.
If both `subpops`

and `phiMin`

are omitted, the adjustment is equivalent to `phiMin=min(Phi)`

.

1 | ```
rescalePopkin(Phi, subpops = NULL, phiMin = NA)
``` |

`Phi` |
An |

`subpops` |
The length- |

`phiMin` |
A scalar kinship value to define the new zero kinship. |

The rescaled *n-by-n* kinship matrix, with the desired level of relatedness set to zero.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ```
## Construct toy data
X <- matrix(c(0,1,2,1,0,1,1,0,2), nrow=3, byrow=TRUE) # genotype matrix
subpops <- c(1,1,2) # subpopulation assignments for individuals
subpops2 <- 1:3 # alternate labels treat every individual as a different subpop
## NOTE: for BED-formatted input, use BEDMatrix!
## "file" is path to BED file (excluding .bed extension)
# library(BEDMatrix)
# X <- BEDMatrix(file) # load genotype matrix object
## suppose we first estimate kinship without subpopulations, which will be more biased
Phi <- popkin(X) # calculate kinship from genotypes, WITHOUT subpops
## then we visualize this matrix, figure out a reasonable subpopulation partition
## now we can adjust the kinship matrix!
Phi2 <- rescalePopkin(Phi, subpops)
## prev is faster but otherwise equivalent to re-estimating Phi from scratch with subpops:
## Phi2 <- popkin(X, subpops)
## can also manually set the level of relatedness phiMin we want to be zero:
phiMin <- min(Phi) # a naive choice for example
Phi2 <- rescalePopkin(Phi, phiMin=phiMin)
## lastly, omiting both subpops and phiMin sets the minimum value in Phi to zero
Phi3 <- rescalePopkin(Phi2)
## equivalent to both of:
## Phi3 <- popkin(X)
## Phi3 <- rescalePopkin(Phi2, phiMin=min(Phi))
``` |

popkin documentation built on Jan. 27, 2018, 1:03 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.