seqAddValue {SeqArray} | R Documentation |
Add or modify the values in a GDS file with hash code
seqAddValue(gdsfile, varnm, val, desp=character(), replace=FALSE, compress="LZMA_RA", packed=TRUE, verbose=TRUE, verbose.attr=TRUE)
gdsfile |
character for file name, or a |
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, raw variable, |
desp |
variable description |
replace |
if |
compress |
the compression method can be "" (no compression), see
|
packed |
|
verbose |
if |
verbose.attr |
if |
Return none.
Xiuwen Zheng
# 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")) # annotation info seqAddValue(f, "annotation/info/folder", NULL) # add a new folder seqAddValue(f, "annotation/info/folder/val", 1:1348, "random number") seqAddValue(f, "annotation/info/folder/packed", c(rep(2L, 1000), rep(NA, 348))) seqAddValue(f, "annotation/info/newff", data.frame(x=1:1348, y=rep("s", 1348), stringsAsFactors=FALSE), desp=c("integer numbers", "character")) # variable-length annotation info data v <- lapply(1:1348, function(x) as.character(x)) v[[1]] <- 1:10 seqAddValue(f, "annotation/info/folder/val1", v) head(seqGetData(f, "annotation/info/folder/val1", .tolist=TRUE)) # 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)