miraculix (version 0.9.20)

haplomatrix: Transform a Haplotype Vector to a Compressed Haplotype Vector

Description

Coerce a matrix to a compressed haplotype matrix

Usage

haplomatrix(M, IndividualsPerColumn=TRUE, DoubledIndividuals=TRUE)
# S3 method for haplomatrix
as(object, …)

Arguments

M,object

matrix of two rows containing only the values 0 and 1

IndividualsPerColumn

Logical. If IndividualsPerColumn=TRUE then the first argument indicates a (SNPs \(\times\) Individ) matrix. Otherwise, the first argument indicates a (Individ \(\times\) SNPs) matrix, which will be transposed before storage.

DoubledIndividuals

Logical. If DoubledIndividuals=TRUE the haplotype information for the second chromosome is given in direction of the individuals, i.e. if additionally IndividualsPerColumn=TRUE, the number of columns are doubled. Otherwise, the information is given in the other direction. The information at one locus is always given back-to-back.

All arguments of haplomatrix except M

Value

an object of class genomicmatrix

See Also

Note that a haplotype file can be read in by genomicmatrix.

as.matrix transforms a genomicmatrix to a human readable matrix.

Examples

Run this code
# NOT RUN {
set.seed(0)
snps <- 100
cols <- 2
M <- matrix(sample(0:1, snps * cols, replace=TRUE), ncol = snps)
Print(M)
print(GM <- haplomatrix(M))
stopifnot(all(as.matrix(GM) == M))
# }

Run the code above in your browser using DataLab