Learn R Programming

miraculix (version 0.9.23)

haplomatrix-class: Class haplomatrix

Description

Class representing a haplo matrix

Usage

# S3 method for haplomatrix
print(x, …)
# S3 method for haplomatrix
str(object, …)
# S3 method for haplomatrix
as.matrix(x, …)

Arguments

x,object

a compressed (SNP x Individuals) matrix

see print, str for their options. The command as.matrix has the following options

indiv

vector of integer, indicating individuals to be extracted

sets

value 1, 2 or 1:2. Indicates the chromosome set to be returned. Default:1:2

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. Default: TRUE

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. Default: TRUE

Details

Since the haplo matrix takes only the values 0 and 1, haplomatrix uses a one bit compressed storing mode. A haplomatrix can quickly be transformed into a genomicmatrix (by exactly this command) in case of the default two-bit coding, e.g. RFoptions(snpcoding=Shuffle).

See Also

genomicmatrix-class

Examples

Run this code
# NOT RUN {
set.seed(0)
indiv <- 5
loci <- 4
M <- matrix(sample(0:1, 2 * indiv * loci, replace=TRUE), nrow = loci)
str(M)

GM <- haplomatrix(M)
print(GM)
str(GM)
print(as.matrix(GM))
print(as.matrix(GM, indiv=2:4, sets=1))
stopifnot(sum(abs(as.matrix(GM) - M)) == 0)
# }

Run the code above in your browser using DataLab