Description Usage Arguments Details Value See Also Examples
Coerce to or create a compressed genomic matrix
1 2 3 4 5 6 | genomicmatrix(snps, individuals, file.type,
coding, header, IndividualsPerColumn,
DoubledIndividuals, leadingcolumns, loading,
...)
## S3 method for class 'genomicmatrix'
as(object, ...)
|
object, snps |
integer, matrix, vector, a haplomatrix or file name. See Details. |
individuals |
integer. See Details |
file.type |
if
|
coding |
if In case of 5 characters, a file with genomic data is assumed and the characters have the following meaning:
In case of 4 characters, a file with haplotype information is assumed and the characters have the following meaning:
The haplotype data is turned into genomic data. |
header |
integer. If
|
IndividualsPerColumn |
\ipc |
DoubledIndividuals |
\dindiv If |
leadingcolumns |
Integer. If |
loading |
logical. If |
... |
options, see |
genomicmatrix creates a
compressed matrix according to the coding scheme given by
RFoptions()$genetics$snpcoding.
In case snps is a string, i.e., a file name, the extension of
the file name predefines the file.type:
=‘beagle’
=‘beagle’
=‘plink’
=‘plink2’
=‘plink2’
=‘plinkbinary’
The definition can be overwritten by file.type. The latter
can be overwritten by all other options (except individuals).
If individuals is given, genomicmatrix creates a
snps \times individuals compressed data matrix filled
with zeros. The matrix can be modified afterwards by
fillGeno.
If a haplomatrix is given, it is
transformed into a genomicmatrix.
If genomicmatrix is given, the matrix is returned as is and a
warning is given.
Both functions, genomicmatrix and as have exactly
the same behavior execept for loading which is TRUE for
genomicmatrix by default and fixed to be FALSE
for as.genomicmatrix.
an object of class genomatrix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
set.seed(0)
snps <- 100
indiv <- 10
M <- matrix(sample(0:2, snps * indiv, replace=TRUE), nrow = snps)
(GM <- genomicmatrix(M))
stopifnot(all(as.matrix(GM) == M))
## There is a difference between genomicmatrix and as.genomicmatrix
## in case of files: 'as.genomicmatrix' creates only a pointer to
## the file, while 'genomicmatrix' reads the file
file <- "miraculix"
if (interactive() && !file.exists(paste0(file, ".bgl"))) {
f <- rhaplo(indiv=100, loci=1000, file=file, file.type="beagle")
print(f)
print(G <- as.genomicmatrix(f))
print(g <- genomicmatrix(f))
Print(object.size(G), object.size(g)) ## g needs much more memory
file.remove(f)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.