splitMatrix: Split matrix of genotypes

View source: R/functions_pool.R

splitMatrixR Documentation

Split matrix of genotypes

Description

This function splits a matrix into different list entries. The matrix is split according to a set of row indexes defined by the size input.

Usage

splitMatrix(matrix, size)

Arguments

matrix

is obviously a matrix, ideally one containing genotypes. Each column of the matrix should be a different site and each row a different individual.

size

a list with one entry per population. Each entry should be a vector containing the size (in number of diploid individuals) of each pool. Thus, if a population was sequenced using a single pool, the vector should contain only one entry. If a population was sequenced using two pools, each with 10 individuals, this vector should contain two entries and both will be 10.

Details

The size input is utilized to create the index of the rows that go into the different list entries. It specifies the size, in terms of number of individuals, of each population.

Value

a list with one entry per entry of the size input argument. Each entry contains the information of the original matrix for the number of individuals specified by the corresponding entry of the size input argument.

Examples

set.seed(10)

# create a random matrix
mymatrix <- matrix(round(runif(n = 50, min = 10, max = 25)), nrow = 10)

# split that matrix assuming 8 individuals in the first population and two in the second
splitMatrix(matrix = mymatrix, size = list(8, 2))


poolHelper documentation built on July 9, 2023, 6:23 p.m.