genoscape_pca: do a PCA using SNPRelate and prepare output for rapid...

Description Usage Arguments Details Examples

View source: R/genoscape_pca.R

Description

This just does all the legwork to do a PCA using SNPRelate, and then it does what it takes to plot every PC against every other using facet_grid. It doesn't make the plots, but it prepares the data.

Usage

1
2
3
4
5
6
7
genoscape_pca(
  dat012,
  samples_to_remove = character(0),
  num_pcs = 6,
  sample_groups = NULL,
  plot_facet_free = FALSE
)

Arguments

dat012

an 012 matrix like that you get from read_012. missing data should be denoted -1.

samples_to_remove

the names of the samples that should be removed before doing the PCA. This does not check to make sure that the samples requested to be dropped actually exist in dat012.

num_pcs

number of principal components to retain in output. Default = 6

sample_groups

If not NULL, this should be a tibble with a column "sample" and another column "group", by which the points will be colored.

plot_facet_free

if TRUE then the pca-pairs plot scales are free to encompass less area.

Details

This function lets you say which individuals you want to drop which makes it easy to iteratively remove outliers.

Examples

1
2
3
4
5
# Just while working on it, for testing:
library(readr)
dat012 <- read_012("../amke-popgen/data/rachael-amke-clean_indv175_pos110000", gz = TRUE)
sample_groups <- read_csv("../amke-popgen/data/amke_locations_from_mikki.csv")
samples_to_remove <- c("1833-14592", "2003-40521", "OCBPC-3", "OCBPC-4")

eriqande/genoscapeRtools documentation built on Dec. 27, 2021, 8:01 a.m.