miraculix (version 0.9.20)

Manipulate: Manipulating Compressed Matrices

Description

copyGeno copies a coded SNP matrix zeroNthGeno writes zeros into selected rows of a coded SNP matrix fillGeno allows to fill (or replace) colums of a compressed (snps \(\times\) indiv) matrix.

Usage

fillGeno(SNPxIndiv, indiv, values, IndividualsPerColumn=TRUE,
         DoubledIndividuals=TRUE)
copyGeno(SNPxIndiv)
zeroNthGeno(SNPxIndiv, snps)

Arguments

SNPxIndiv

a compressed SNP (genotype) vector or matrix, obtained from genomicmatrix or haplomatrix

indiv

integer vector. It gives the columns of the (SNP \(\times\) Indiv) matrix that has to be filled with values

values

coded or uncoded vector or matrix of haplotype or genotypes.

snps

vector of integers, which gives the selected rows. If missing all rows are selected.

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.

Value

All functions return a compressed SNP matrix of class genomicmatrix.

See Also

genomicmatrix-class

vectorGeno for multiplying a vector from the left

genoVector for multiplying a vector from the right

Examples

Run this code
# NOT RUN {
 
# }
# NOT RUN {
<!-- %   library(miraculix) -->
# }
# NOT RUN {
require(RandomFieldsUtils)
set.seed(0)

indiv <- sample(1000, 1)
snps <- indiv * 2^sample(7,1)
M <- matrix(nrow = snps, sample(0:2, snps * indiv, replace=TRUE))
storage.mode(M) <- sample(c("integer", "double"), 1)
CM <- genomicmatrix(M)
str(CM)
Z <- as.matrix(CM)
Print(M, CM, Z)
stopifnot(all(M == Z))

N <- sample(snps, snps / 4)
Z1 <- as.matrix(CM, snps=N)
stopifnot(all(M[N, ] == Z1))

# }

Run the code above in your browser using DataLab