popkin

R package to estimate kinship and FST from SNP data

https://github.com/storeylab/popkin

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 12 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    1 of 3 committers (33.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.5%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

R package to estimate kinship and FST from SNP data

Basic Info
  • Host: GitHub
  • Owner: StoreyLab
  • Language: R
  • Default Branch: main
  • Homepage:
  • Size: 1.94 MB
Statistics
  • Stars: 21
  • Watchers: 5
  • Forks: 0
  • Open Issues: 2
  • Releases: 11
Created almost 9 years ago · Last pushed almost 2 years ago
Metadata Files
Readme

README.md

popkin popkin

The popkin ("population kinship") R package estimates the kinship matrix of individuals and FST from their biallelic genotypes. Our estimation framework is the first to be practically unbiased under arbitrary population structures.

Installation

The stable version of the package is now on CRAN and can be installed using R install.packages("popkin")

The current development version can be installed from the GitHub repository using devtools: R install.packages("devtools") # if needed library(devtools) install_github('StoreyLab/popkin', build_vignettes = TRUE)

You can see the package vignette, which has more detailed documentation, by typing this into your R session: R vignette('popkin')

Examples

Input data

The examples below assume the following R data variables are present for n individuals and m loci:

  • The m-by-n genotype matrix X, containing only unphased biallelic variants encoded as 0,1,2 counting a given reference allele per locus.
  • The length-n vector subpops that assigns each individual to a subpopulation.

The subpops vector is not required, but its use is recommended to improve estimation of the baseline kinship value treated as zero.

If your data is in BED format, popkin will process it efficiently using BEDMatrix. If file is the path to the BED file (excluding .bed extension): R library(BEDMatrix) X <- BEDMatrix(file) # load genotype matrix object

popkin functions

This is a quick overview of every popkin function, covering estimation and visualization of kinship and FST from a genotype matrix.

First estimate the kinship matrix from the genotypes X. All downstream analysis require kinship, none use X after this R library(popkin) kinship <- popkin(X, subpops) # calculate kinship from X and optional subpop labels

Plot the kinship matrix, marking the subpopulations. Note inbr_diag replaces the diagonal of kinship with inbreeding coefficients R plot_popkin( inbr_diag(kinship), labs = subpops )

Extract inbreeding coefficients from kinship R inbreeding <- inbr(kinship)

Estimate FST R weights <- weights_subpops(subpops) # weigh individuals so subpopulations are balanced Fst <- fst(kinship, weights) # use kinship matrix and weights to calculate fst Fst <- fst(inbreeding, weights) # estimate more directly from inbreeding vector (same result)

Estimate and visualize the pairwise FST matrix R pairwise_fst <- pwfst(kinship) # estimated matrix leg_title <- expression(paste('Pairwise ', F[ST])) # fancy legend label plot_popkin(pairwise_fst, labs = subpops, leg_title = leg_title) # NOTE no need for inbr_diag() here!

Rescale the kinship matrix using different subpopulations (implicitly changes the most recent common ancestor population used as reference) R kinship2 <- rescale_popkin(kinship, subpops2)

Estimate the coancestry matrix from a matrix of allele frequencies P (useful when P comes from an admixture inference model) R coancestry <- popkin_af( P )

Please see the popkin R vignette for a description of the key parameters and more detailed examples, including complex plots with multiple kinship matrices and multi-level subpopulation labeling.

Citations

Alejandro Ochoa, John D Storey. 2021. "Estimating FST and kinship for arbitrary population structures." PLoS Genet 17(1): e1009241. PubMed ID 33465078. doi:10.1371/journal.pgen.1009241. bioRxiv doi:10.1101/083923 2016-10-27.

Alejandro Ochoa, John D Storey. 2019. "New kinship and FST estimates reveal higher levels of differentiation in the global human population." bioRxiv doi:10.1101/653279.

Alejandro Ochoa, John D Storey. 2016. "FST And Kinship for Arbitrary Population Structures I: Generalized Definitions." bioRxiv doi:10.1101/083915.

Owner

  • Name: Storey Lab
  • Login: StoreyLab
  • Kind: organization
  • Location: Princeton, NJ USA

Storey Lab at Princeton University

GitHub Events

Total
  • Watch event: 1
  • Issue comment event: 1
Last Year
  • Watch event: 1
  • Issue comment event: 1

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 170
  • Total Committers: 3
  • Avg Commits per committer: 56.667
  • Development Distribution Score (DDS): 0.441
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Alejandro Ochoa Garcia a****g@g****m 95
Alejandro Ochoa Garcia o****a@p****u 74
Alejandro Ochoa v****a@v****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 7
  • Total pull requests: 0
  • Average time to close issues: 3 months
  • Average time to close pull requests: N/A
  • Total issue authors: 6
  • Total pull request authors: 0
  • Average comments per issue: 2.86
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • mkelcb (1)
  • pidita (1)
  • privefl (1)
  • wangzhx36 (1)
  • miguel-correa92 (1)
  • melop (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 446 last-month
  • Total dependent packages: 4
  • Total dependent repositories: 5
  • Total versions: 10
  • Total maintainers: 1
cran.r-project.org: popkin

Estimate Kinship and FST under Arbitrary Population Structure

  • Versions: 10
  • Dependent Packages: 4
  • Dependent Repositories: 5
  • Downloads: 446 Last month
Rankings
Dependent packages count: 9.3%
Stargazers count: 12.6%
Dependent repos count: 13.0%
Average: 19.5%
Forks count: 27.8%
Downloads: 34.8%
Maintainers (1)
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • RColorBrewer * imports
  • ape * imports
  • grDevices * imports
  • graphics * imports
  • BEDMatrix * suggests
  • bnpsd * suggests
  • knitr * suggests
  • lfa * suggests
  • rmarkdown * suggests
  • testthat * suggests