seqAddValue {SeqArray}R Documentation

Add values to a GDS File

Description

Add or modify the values in a GDS file with hash code

Usage

seqAddValue(gdsfile, varnm, val, desp="", replace=FALSE, compress="LZMA_RA",
    packed=FALSE)

Arguments

gdsfile

a SeqVarGDSClass object

varnm

the variable name, e.g., "sample.id", "variant.id", "chromosome", "annotation/info/NEW_VARIABLE"

val

the R value can be integers, real numbers, characters, factor, logical or raw variable, list and data.frame

desp

variable description

replace

if TRUE, replace the existing variable silently if possible

compress

the compression method can be "" (no compression), see add.gdsn

packed

FALSE

Value

Return none.

Author(s)

Xiuwen Zheng

See Also

seqVCF2GDS

Examples

library(SeqArray)

# the file of GDS
gds.fn <- seqExampleFileName("gds")
file.copy(gds.fn, "tmp.gds", overwrite=TRUE)

# display
(f <- seqOpen("tmp.gds", FALSE))

show(index.gdsn(f, "sample.id"))
seqAddValue(f, "sample.id", 1:90, replace=TRUE)
show(index.gdsn(f, "sample.id"))

show(index.gdsn(f, "chromosome"))
v <- seqGetData(f, "chromosome")
seqAddValue(f, "chromosome", paste0("chr", v), replace=TRUE)
show(index.gdsn(f, "chromosome"))
table(seqGetData(f, "chromosome"))

# sample annotation
seqAddValue(f, "sample.annotation", data.frame(ii=1:90, y=rep("A", 90)), replace=TRUE)
seqAddValue(f, "sample.annotation/float", (1:90)/90)

# close the GDS file
seqClose(f)


# remove the temporary file
unlink("tmp.gds", force=TRUE)

[Package SeqArray version 1.26.2 Index]