42
Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0) Suggests parallel, snow, RUnit Author Xiuwen Zheng Maintainer Xiuwen Zheng <[email protected]> Description CoreArray project is to develop portable and scalable storage technologies for bioinformatics data, allowing parallel computing at the multicore and cluster levels. License LGPL-3 URL http://corearray.sourceforge.net/ Forums http://sourceforge.net/projects/corearray/forums NeedsCompilation yes Repository CRAN Date/Publication 2013-02-19 15:25:25 R topics documented: gdsfmt-package ....................................... 2 add.gdsn ........................................... 4 addfile.gdsn ......................................... 6 append.gdsn ......................................... 8 apply.gdsn .......................................... 9 assign.gdsn ......................................... 11 1

Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

Package ‘gdsfmt’February 19, 2013

Type Package

Title CoreArray Genomic Data Structure (GDS) R Interface

Version 0.9.12

Date 2013-02-15

Depends R (>= 2.12.0)

Suggests parallel, snow, RUnit

Author Xiuwen Zheng

Maintainer Xiuwen Zheng <[email protected]>

Description CoreArray project is to develop portable and scalablestorage technologies for bioinformatics data, allowing parallelcomputing at the multicore and cluster levels.

License LGPL-3

URL http://corearray.sourceforge.net/

Forums http://sourceforge.net/projects/corearray/forums

NeedsCompilation yes

Repository CRAN

Date/Publication 2013-02-19 15:25:25

R topics documented:gdsfmt-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2add.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4addfile.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6append.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8apply.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9assign.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1

Page 2: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

2 gdsfmt-package

cleanup.gds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12closefn.gds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13clusterApply.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14cnt.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16compression.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17createfn.gds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18delete.attr.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19delete.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20gds.class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21gdsn.class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21gdsUnitTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22get.attr.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22getfile.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23index.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24lasterr.gds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25ls.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26name.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27objdesp.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28openfn.gds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29print.gds.class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30print.gdsn.class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31put.attr.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32read.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33readex.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34readmode.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35rename.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36setdim.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37sync.gds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38write.gdsn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Index 41

gdsfmt-package CoreArray Genomic Data Structure (GDS) R Interface

Description

R interface of CoreArray GDS is based on the CoreArray project initiated and developed from 2007.

Details

Package: gdsfmtType: PackageVersion: 0.9.12Date: 2013-02-18License: LGPL version 3

Page 3: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

gdsfmt-package 3

R interface of CoreArray GDS is based on the CoreArray project initiated and developed by XiuwenZheng from 2007. The CoreArray project is to develop portable, scalable, bioinformatics datavisualization and storage technologies.

R is the most popular statistical environment, but one not necessarily optimized for high perfor-mance or parallel computing which ease the burden of large-scale calculations. To support efficientdata management in parallel for numerical genomic data, we developed the Genomic Data Structure(GDS) file format. gdsfmt provides fundamental functions to support accessing data in parallel, andallows future R packages to call these functions.

Forums: http://sourceforge.net/projects/corearray/forums

Author(s)

Xiuwen Zheng <[email protected]>

References

http://corearray.sourceforge.net

Xiuwen Zheng, David Levine, Jess Shen, Stephanie M. Gogarten, Cathy Laurie, Bruce S. Weir. AHigh-performance Computing Toolset for Relatedness and Principal Component Analysis of SNPData. Bioinformatics 2012; doi: 10.1093/bioinformatics/bts606

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))L <- -2500:2499

# commom typesadd.gdsn(f, "int", val=as.integer(1:10000), compress="ZIP", closezip=TRUE)add.gdsn(f, "int.matrix", val=matrix(L, nrow=100, ncol=50))add.gdsn(f, "mat", val=matrix(1:(10*6), nrow=10))add.gdsn(f, "double", val=seq(1, 1000, 0.4))add.gdsn(f, "character", val=c("int", "double", "logical", "factor"))add.gdsn(f, "logical", val=rep(c(TRUE, FALSE, NA), 50))add.gdsn(f, "factor", val=as.factor(c(letters, NA, "AA", "CC")))add.gdsn(f, "NA", val=rep(NA, 10))add.gdsn(f, "NaN", val=c(rep(NaN, 20), 1:20))add.gdsn(f, "bit2-matrix", val=matrix(L[1:5000], nrow=50, ncol=100), storage="bit2")# list and data.frameadd.gdsn(f, "list", val=list(X=1:10, Y=seq(1, 10, 0.25)))add.gdsn(f, "data.frame", val=data.frame(X=1:19, Y=seq(1, 10, 0.5)))

# save a .RData objectobj <- list(X=1:10, Y=seq(1, 10, 0.1))save(obj, file="tmp.RData")addfile.gdsn(f, "tmp.RData", filename="tmp.RData")

f

read.gdsn(index.gdsn(f, "list"))

Page 4: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

4 add.gdsn

read.gdsn(index.gdsn(f, "list/Y"))read.gdsn(index.gdsn(f, "data.frame"))read.gdsn(index.gdsn(f, "mat"))

# Apply functions over columns of matrixtmp <- apply.gdsn(index.gdsn(f, "mat"), margin=2, FUN=function(x) print(x))tmp <- apply.gdsn(index.gdsn(f, "mat"), margin=2,selection = list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3)),FUN=function(x) print(x))

closefn.gds(f)

add.gdsn Add a GDS node

Description

Adds a GDS node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

add.gdsn(node, name, val = NULL, storage = storage.mode(val), valdim = NULL,compress = c("", "ZIP", "ZIP.fast", "ZIP.default", "ZIP.max"), closezip = FALSE)

Arguments

node an object of class gdsn.class or gds.class: "gdsn" – the node of hierarchicalstructure; "gdsclass" – the root of hieracrchical structure

name the variable name of the added node

val the R value can be vector, list, data.frame

storage to specify data type (not case-sensitive): integer ( signed integer: "int8", "int16","int24", "int32", "int64", "sbit2", "sbit3", "sbit4", "sbit5", "sbit6", "sbit7", "sbit8","sbit9", "sbit10", "sbit11", "sbit12", "sbit13", "sbit14", "sbit15", "sbit16", "sbit24","sbit32", "sbit64" ; unsigned integer: "uint8", "uint16", "uint24", "uint32", "uint64","bit1", "bit2", "bit3", "bit4", "bit5", "bit6", "bit7", "bit8", "bit9", "bit10", "bit11","bit12", "bit13", "bit14", "bit15", "bit16", "bit24", "bit32", "bit64" ); float ("float32","float64"), string (variable-length: "string", "string16", "string32"; fixed-length:"fstring", "fstring16", "fstring32"). Or "integer" (="int32"), "float" (="float32"),"double" (="float64"), "character" (="string"), "logical", "list", "factor", "folder"

valdim the dimension attribute for the array to be created, which is a vector of lengthone or more giving the maximal indices in each dimension

compress the compression method can be "", "ZIP", "ZIP.fast", "ZIP.default", or "ZIP.max"

closezip if a compression method is specified, get into read mode after compression

Page 5: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

add.gdsn 5

Details

name if missing, “Item n” is assigned to name, where n is the number of child nodes + 1.

val if val is list or data.frame, the child node(s) will be added corresponding to objects in listor data.frame.

storage the default value is storage.mode(val), "int" denotes signed integer, "uint" denotes un-signed integer, 8, 16, 24, 32 and 64 denote the number of bits. "bit1" to "bit32" denote the packeddata types for 1 to 32 bits which are packed on disk, and "sbit2" to "sbit32" denote the correspondingsigned integers. "float32" denotes single-precision number, and "float64" denotes double-precisionnumber. "string" represents strings of 8-bit characters, "wstring" represents strings of 16-bit char-acters following UTF16 industry standard, and "dwstring" represents strings of 32-bit charactersfollowing UTF32 industry standard. "folder" is to create a folder.

valdim the values in data are taken to be those in the array with the leftmost subscript movingfastest. Some of entries can be ZERO!

compress Z compression algorithm can be used to deflate the data stored in the GDS file. "ZIP"option is equivalent to "ZIP.default". "ZIP.fast", "ZIP.default" and "ZIP.max" correspond to differentcompression levels. In the comprssion mode, you can not change the non-first dimension and readdata field. Call readmode.gdsn to return read mode.

closezip if compression option is specified, then enter a read mode after deflating the data. seereadmode.gdsn.

Value

An object of class gdsn.class of the added node.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

cnt.gdsn, objdesp.gdsn, ls.gdsn, index.gdsn, name.gdsn

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))L <- -2500:2499

########################################################################### commom types

add.gdsn(f, "int", val=as.integer(1:10000), compress="ZIP", closezip=TRUE)add.gdsn(f, "int.matrix", val=matrix(L, nrow=100, ncol=50))add.gdsn(f, "double", val=seq(1, 1000, 0.4))

Page 6: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

6 addfile.gdsn

add.gdsn(f, "character", val=c("int", "double", "logical", "factor"))add.gdsn(f, "logical", val=rep(c(TRUE, FALSE, NA), 50))add.gdsn(f, "factor", val=as.factor(c(letters, NA, "AA", "CC")))add.gdsn(f, "NA", val=rep(NA, 10))add.gdsn(f, "NaN", val=c(rep(NaN, 20), 1:20))add.gdsn(f, "bit2-matrix", val=matrix(L[1:5000], nrow=50, ncol=100), storage="bit2")# list and data.frameadd.gdsn(f, "list", val=list(X=1:10, Y=seq(1, 10, 0.25)))add.gdsn(f, "data.frame", val=data.frame(X=1:19, Y=seq(1, 10, 0.5)))

########################################################################### save a .RData object

obj <- list(X=1:10, Y=seq(1, 10, 0.1))save(obj, file="tmp.RData")addfile.gdsn(f, "tmp.RData", filename="tmp.RData")

f

read.gdsn(index.gdsn(f, "list"))read.gdsn(index.gdsn(f, "list/Y"))read.gdsn(index.gdsn(f, "data.frame"))

########################################################################### allocate the disk spaces

n1 <- add.gdsn(f, "n1", val=1:100, valdim=c(10, 20))read.gdsn(index.gdsn(f, "n1"))

n2 <- add.gdsn(f, "n2", val=matrix(1:100, 10, 10), valdim=c(15, 20))read.gdsn(index.gdsn(f, "n2"))

closefn.gds(f)

addfile.gdsn Add a GDS node with a file

Description

Adds a GDS node with a file, in a CoreArray Genomic Data Structure (GDS) file.

Usage

addfile.gdsn(node, name, filename, compress=c("ZIP", "ZIP.fast", "ZIP.default", "ZIP.max", ""))

Page 7: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

addfile.gdsn 7

Arguments

node an object of class gdsn.class or gds.class: "gdsn" – the node of hierarchicalstructure; "gdsclass" – the root of hieracrchical structure

name the variable name of the added nodefilename the file name of input stream.compress the compression method can be "", "ZIP", "ZIP.fast", "ZIP.default", or "ZIP.max".

Details

name if missing, “Item n” is assigned to name, where n is the number of child nodes + 1.

compress Z compression algorithm can be used to deflate the data stored in the GDS file. "ZIP"option is equivalent to "ZIP.default". "ZIP.fast", "ZIP.default" and "ZIP.max" correspond to differentcompression levels. In the comprssion mode, you can not change the non-first dimension and readdata field. Call readmode.gdsn to return read mode.

Value

An object of class gdsn.class of the added node.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

cnt.gdsn, objdesp.gdsn, ls.gdsn, index.gdsn, name.gdsn, add.gdsn, getfile.gdsn

Examples

# save a .RData objectobj <- list(X=1:10, Y=seq(1, 10, 0.1))save(obj, file="tmp.RData")

# cteate a GDS file "test.gds"f <- createfn.gds("test.gds")

add.gdsn(f, "double", val=seq(1, 1000, 0.4))addfile.gdsn(f, "tmp.RData", "tmp.RData")

f

getfile.gdsn(index.gdsn(f, "tmp.RData"), "tmp1.RData")(obj <- get(load("tmp1.RData")))

# open the GDS fileclosefn.gds(f)

Page 8: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

8 append.gdsn

append.gdsn Append data to a specified variable

Description

Appends data to the data field of a GDS node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

append.gdsn(node, val, check = TRUE)

Arguments

node an object of class gdsn.class, a GDS node

val data to be appended

check whether a warning is given, when appended data can not match the capability ofdata field

Details

storage.mode(val) should be "integer", "double", "character", or "logical".

Value

None.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

read.gdsn, write.gdsn, add.gdsn

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

# commom typesn <- add.gdsn(f, "int", val=matrix(as.integer(1:10000), nrow=100, ncol=100),

compress="ZIP")

# no warning, and add a new column

Page 9: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

apply.gdsn 9

append.gdsn(n, -1:-100)f

# a warningappend.gdsn(n, -1:-50)f

# no warning here, and add a new columnappend.gdsn(n, -51:-100)f

# you should call "readmode.gdsn", before readingreadmode.gdsn(n)

# check the last columnread.gdsn(n, start=c(1, 102), count=c(-1, 1))

# close the gds fileclosefn.gds(f)

apply.gdsn Apply functions over margins

Description

Returns a vector or list of values obtained by applying a function to margins of a matrix or array, ina CoreArray Genomic Data Structure (GDS) file.

Usage

apply.gdsn(node, margin, FUN, selection=NULL,as.is = c("list", "integer", "double", "character", "none"), ...)

Arguments

node an object of class gdsn.class, or a list of objects of class gdsn.class

margin an integer giving the subscripts which the function will be applied over. E.g.,for a matrix 1 indicates rows, 2 indicates columns

FUN the function to be applied

selection a list or NULL; if a list, it is a list of logical vectors according to dimensionsindicating selection; if NULL, uses all data

as.is returned value: a list, an integer vector, etc

... optional arguments to FUN

Details

The algorithm is optimized by blocking the computations to exploit the high-speed memory insteadof disk.

Page 10: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

10 apply.gdsn

Value

A vector or list of values.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

read.gdsn, readex.gdsn, clusterApply.gdsn

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

(n <- add.gdsn(f, "matrix", val=matrix(1:(10*6), nrow=10)))read.gdsn(index.gdsn(f, "matrix"))

# Apply functions over rows of matrixtmp <- apply.gdsn(n, margin=1, FUN=function(x) print(x))tmp <- apply.gdsn(n, margin=1,selection = list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3)),FUN=function(x) print(x))

# Apply functions over columns of matrixtmp <- apply.gdsn(n, margin=2, FUN=function(x) print(x))tmp <- apply.gdsn(n, margin=2,selection = list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3)),FUN=function(x) print(x))

# closeclosefn.gds(f)

########################################################## Multiple variables#

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

X <- matrix(1:50, nrow=10)Y <- matrix((1:50)/100, nrow=10)Z1 <- factor(c(rep(c("ABC", "DEF", "ETD"), 3), "TTT"))Z2 <- c(TRUE, FALSE, TRUE, FALSE, TRUE)

Page 11: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

assign.gdsn 11

node.X <- add.gdsn(f, "X", X)node.Y <- add.gdsn(f, "Y", Y)node.Z1 <- add.gdsn(f, "Z1", Z1)node.Z2 <- add.gdsn(f, "Z2", Z2)

v <- apply.gdsn(list(X=node.X, Y=node.Y, Z=node.Z1), margin=c(1, 1, 1),FUN=function(x) { print(x) }, as.is="none")

v <- apply.gdsn(list(X=node.X, Y=node.Y, Z=node.Z2), margin=c(2, 2, 1),FUN=function(x) print(x))

# with selection

s1 <- rep(c(FALSE, TRUE), 5)s2 <- c(TRUE, FALSE, TRUE, FALSE, TRUE)

v <- apply.gdsn(list(X=node.X, Y=node.Y, Z=node.Z1), margin=c(1, 1, 1),selection = list(list(s1, s2), list(s1, s2), list(s1)),FUN=function(x) print(x))

v <- apply.gdsn(list(X=node.X, Y=node.Y, Z=node.Z2), margin=c(2, 2, 1),selection = list(list(s1, s2), list(s1, s2), list(s2)),FUN=function(x) print(x))

# closeclosefn.gds(f)

assign.gdsn Assign/append data to a GDS node

Description

Assign data to a GDS node, or append data to a GDS node

Usage

assign.gdsn(dest.obj, src.obj, append)

Arguments

dest.obj an object of class gdsn.class, a destination GDS nodesrc.obj an object of class gdsn.class, a source GDS nodeappend if TRUE, append data; otherwise, replace the old one

Author(s)

Xiuwen Zheng <[email protected]>

Page 12: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

12 cleanup.gds

References

http://sourceforge.net/projects/corearray/

See Also

read.gdsn, write.gdsn

cleanup.gds Clean up fragments

Description

Cleans up the fragments of a CoreArray Genomic Data Structure (GDS) file.

Usage

cleanup.gds(fn, deep=FALSE, verbose=TRUE)

Arguments

fn the file name of a GDS file to be opened

deep if TRUE, performs a deep-construction strategy; otherwise, performs fast con-struction

verbose if TRUE, show information

Value

None.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

openfn.gds, createfn.gds, closefn.gds

Page 13: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

closefn.gds 13

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

# commom typesadd.gdsn(f, "int", val=as.integer(1:10000))L <- -2500:2499add.gdsn(f, "int.matrix", val=matrix(L, nrow=100, ncol=50))

# save a .RData objectobj <- list(X=1:10, Y=seq(1, 10, 0.1))save(obj, file="tmp.RData")addfile.gdsn(f, "tmp.RData", filename="tmp.RData")

f

closefn.gds(f)

# clean up fragmentscleanup.gds("test.gds")

# cteate the GDS file "test.gds"(f <- openfn.gds("test.gds"))closefn.gds(f)

closefn.gds Close a GDS file

Description

Closes an open CoreArray Genomic Data Structure (GDS) file.

Usage

closefn.gds(gds)

Arguments

gds an object of class gds.class, returned by createfn.gds or openfn.gds

Details

For better performance, Data in a GDS file are usually cached in memory. Keep in mind that thenew file may not actually be written to disk, until closefn.gds or sync.gds is called. Anyway,when R shuts down, all GDS files created or opened would be automatically closed.

Value

None.

Page 14: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

14 clusterApply.gdsn

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

createfn.gds, openfn.gds, sync.gds

clusterApply.gdsn Apply functions over matrix margins in parallel

Description

Returns a vector or list of values obtained by applying a function to margins of a matrix in parallel,in a CoreArray Genomic Data Structure (GDS) file.

Usage

clusterApply.gdsn(cl, gds.fn, node.name, margin, FUN, selection=NULL,as.is = c("list", "integer", "double", "character", "none"), ...)

Arguments

cl a cluster object, created by this package or by the package parallel or snow

gds.fn the file name of a GDS file

node.name a character vector indicating GDS node path

margin an integer giving the subscripts which the function will be applied over. E.g.,for a matrix 1 indicates rows, 2 indicates columns

FUN the function to be applied

selection a list or NULL; if a list, it is a list of logical vectors according to dimensionsindicating selection; if NULL, uses all data

as.is returned value: a list, an integer vector, etc

... optional arguments to FUN

Details

The algorithm of applying is optimized by blocking the computations to exploit the high-speedmemory instead of disk.

Value

A vector or list of values.

Page 15: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

clusterApply.gdsn 15

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

apply.gdsn

Examples

############################################################ prepare a GDS file

# cteate the GDS file "test1.gds"f <- createfn.gds("test1.gds")

(n <- add.gdsn(f, "matrix", val=matrix(1:(10*6), nrow=10)))read.gdsn(index.gdsn(f, "matrix"))

closefn.gds(f)

# cteate the GDS file "test2.gds"(f <- createfn.gds("test2.gds"))

X <- matrix(1:50, nrow=10)Y <- matrix((1:50)/100, nrow=10)Z1 <- factor(c(rep(c("ABC", "DEF", "ETD"), 3), "TTT"))Z2 <- c(TRUE, FALSE, TRUE, FALSE, TRUE)

node.X <- add.gdsn(f, "X", X)node.Y <- add.gdsn(f, "Y", Y)node.Z1 <- add.gdsn(f, "Z1", Z1)node.Z2 <- add.gdsn(f, "Z2", Z2)f

closefn.gds(f)

############################################################ apply in parallel

library(parallel)

# Use option cl.core to choose an appropriate cluster size.cl <- makeCluster(getOption("cl.cores", 2))

Page 16: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

16 cnt.gdsn

# Apply functions over rows or columns of matrix

clusterApply.gdsn(cl, "test1.gds", "matrix", margin=1, FUN=function(x) x)

clusterApply.gdsn(cl, "test1.gds", "matrix", margin=2, FUN=function(x) x)

clusterApply.gdsn(cl, "test1.gds", "matrix", margin=1,selection = list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3)),FUN=function(x) x)

clusterApply.gdsn(cl, "test1.gds", "matrix", margin=2,selection = list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3)),FUN=function(x) x)

# Apply functions over rows or columns of multiple data sets

clusterApply.gdsn(cl, "test2.gds", c("X", "Y", "Z1"), margin=c(1, 1, 1),FUN=function(x) x)

# with variable namesclusterApply.gdsn(cl, "test2.gds", c(X="X", Y="Y", Z="Z2"), margin=c(2, 2, 1),FUN=function(x) x)

cnt.gdsn Return the number of child nodes

Description

Returns the number of child nodes for a specified node, in a CoreArray Genomic Data Structure(GDS) file.

Usage

cnt.gdsn(node)

Arguments

node an object of class gdsn.class, a GDS node

Value

The number of child nodes.

Author(s)

Xiuwen Zheng <[email protected]>

Page 17: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

compression.gdsn 17

References

http://sourceforge.net/projects/corearray/

See Also

objdesp.gdsn, ls.gdsn, index.gdsn, delete.gdsn, add.gdsn

Examples

# cteate the GDS file "test.gds"f <- createfn.gds(fn="test.gds")

# add a list to "test.gds"node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE))cnt.gdsn(node)# 3

closefn.gds(f)

compression.gdsn Modify compression mode

Description

Modifies the data compression mode of data field, in a CoreArray Genomic Data Structure (GDS)file.

Usage

compression.gdsn(node, compress = c("", "ZIP", "ZIP.fast", "ZIP.default", "ZIP.max"))

Arguments

node an object of class gdsn.class, a GDS node

compress specify the compression method

Details

Z compression algorithm can be used to deflate the data stored in the GDS file. "ZIP" option isequivalent to "ZIP.default". "ZIP.fast", "ZIP.default" and "ZIP.max" correspond to different com-pression levels.

Value

Return node.

Author(s)

Xiuwen Zheng <[email protected]>

Page 18: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

18 createfn.gds

References

http://sourceforge.net/projects/corearray/, http://zlib.net/

See Also

readmode.gdsn, add.gdsn

createfn.gds Create a GDS file

Description

Creates a new CoreArray Genomic Data Structure (GDS) file.

Usage

createfn.gds(fn)

Arguments

fn the file name of a new GDS file to be created

Details

Keep in mind that the new file may not actually be written to disk until closefn.gds or sync.gdsis called.

Value

Return an object of class gds.class:

filename the file name to be created.

id ID of GDS file, internal use.

root an object of class gdsn.class, the root of hierachical structure.

readonly whether it is read-only or not

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

openfn.gds, closefn.gds

Page 19: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

delete.attr.gdsn 19

Examples

# cteate the GDS file "test.gds"f <- createfn.gds(fn="test.gds")

# add a list to "test.gds"node <- add.gdsn(f, val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE))

closefn.gds(f)

delete.attr.gdsn Delete an attribute

Description

Removes an attribute of a GDS node.

Usage

delete.attr.gdsn(node, name)

Arguments

node an object of class gdsn.class, a GDS node

name the name of an attribute

Details

If there is not an attribute with name, a warning will be given.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

put.attr.gdsn, get.attr.gdsn

Page 20: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

20 delete.gdsn

delete.gdsn Delete a GDS node

Description

Deletes a specified node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

delete.gdsn(node)

Arguments

node an object of class gdsn.class, a GDS node

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

cnt.gdsn, objdesp.gdsn, ls.gdsn, index.gdsn, name.gdsn, add.gdsn

Examples

# cteate the GDS file "test.gds"f <- createfn.gds(fn="test.gds")

# add a list to "test.gds"node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE))f

# delete "node"delete.gdsn(node)

closefn.gds(f)

Page 21: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

gds.class 21

gds.class the class of GDS file

Description

The class of a GDS file, and its instance is returned from openfn.gds or createfn.gds.

Value

There are three components:

filename the file name to be created.id ID of GDS file, internal use.root an object of class gdsn.class, the root of hierachical structure.readonly whether it is read-only or not

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

createfn.gds, openfn.gds, closefn.gds

gdsn.class the class of a node of GDS file

Description

The class of the node of hierarchical structure from a GDS file, and its instance is returned fromadd.gdsn or index.gdsn.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

createfn.gds, closefn.gds

Page 22: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

22 get.attr.gdsn

gdsUnitTest Unit testing

Description

Run the test R codes in the folder of ’unitTests’

Usage

gdsUnitTest()

Value

None.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

get.attr.gdsn Get attributes

Description

Gets the attributes of a CoreArray GDS node.

Usage

get.attr.gdsn(node)

Arguments

node an object of class gdsn.class, a GDS node

Value

A list of attributes.

Author(s)

Xiuwen Zheng <[email protected]>

Page 23: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

getfile.gdsn 23

References

http://sourceforge.net/projects/corearray/

See Also

put.attr.gdsn, delete.attr.gdsn

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

node <- add.gdsn(f, "int", val=as.integer(1:10000))put.attr.gdsn(node, "missing.value", 10000)

fget.attr.gdsn(node)

closefn.gds(f)

getfile.gdsn Output a file from a stream container

Description

Gets a file from a stream container, in a CoreArray Genomic Data Structure (GDS) file.

Usage

getfile.gdsn(node, out.filename)

Arguments

node an object of class gdsn.class or gds.class: "gdsn" – the node of hierarchicalstructure; "gdsclass" – the root of hieracrchical structure

out.filename the file name of output stream

Value

None.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

Page 24: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

24 index.gdsn

See Also

cnt.gdsn, objdesp.gdsn, ls.gdsn, index.gdsn, name.gdsn, add.gdsn, addfile.gdsn

Examples

# save a .RData objectobj <- list(X=1:10, Y=seq(1, 10, 0.1))save(obj, file="tmp.RData")

# cteate a GDS file "test.gds"f <- createfn.gds("test.gds")

add.gdsn(f, "double", val=seq(1, 1000, 0.4))addfile.gdsn(f, "tmp.RData", "tmp.RData")

f

getfile.gdsn(index.gdsn(f, "tmp.RData"), "tmp1.RData")(obj <- get(load("tmp1.RData")))

# open the GDS fileclosefn.gds(f)

index.gdsn Return the specified node

Description

Returns a specified node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

index.gdsn(node, path=NULL, index=NULL, silent=FALSE)

Arguments

node an object of class gdsn.class or gds.class: "gdsn" – the node of hierarchicalstructure; "gdsclass" – the root of hieracrchical structure

path the path specifying a GDS node with ’/’ as a separator

index a vector of integers or characters, specifying the path; it has effects when pathis missing

silent if TRUE, return NULL if the specified path does not exist

Details

If index is a vector of integers, e.g., c(1, 2), the result is the second child node of the first childof node. If index is a vector of characters, e.g., c("list", "x"), the result is the child node withname "x" of the "list" child node.

Page 25: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

lasterr.gds 25

Value

An object of class gdsn.class for the specified node.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

cnt.gdsn, objdesp.gdsn, ls.gdsn, name.gdsn, delete.gdsn, add.gdsn

Examples

# cteate the GDS file "test.gds"f <- createfn.gds(fn="test.gds")

# add a list to "test.gds"node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE))f

index.gdsn(f, "list/x")index.gdsn(f, index=c("list", "x"))index.gdsn(f, index=c(1, 1))

index.gdsn(f, index=c("list", "z"))

closefn.gds(f)

lasterr.gds Return the last error

Description

Gets the last error of gdsfmt.

Usage

lasterr.gds()

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

Page 26: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

26 ls.gdsn

ls.gdsn Return the names of child nodes

Description

Gets a list of names for its child nodes, in a CoreArray Genomic Data Structure (GDS) file.

Usage

ls.gdsn(node)

Arguments

node an object of class gdsn.class, a GDS node

Value

A vector of characters.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

cnt.gdsn, objdesp.gdsn, ls.gdsn, index.gdsn

Examples

# cteate the GDS file "test.gds"f <- createfn.gds("test.gds")

# add a list to "test.gds"node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE))

ls.gdsn(node)

closefn.gds(f)

Page 27: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

name.gdsn 27

name.gdsn Return the variable name of a node

Description

Gets the variable name of a node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

name.gdsn(node, fullname = FALSE)

Arguments

node an object of class gdsn.class, a GDS node

fullname if FALSE, return the node name (by default), otherwise the full name

Value

A vector of charactors.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

cnt.gdsn, objdesp.gdsn, ls.gdsn, rename.gdsn

Examples

# cteate the GDS file "test.gds"f <- createfn.gds("test.gds")

# add a list to "test.gds"node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE))

name.gdsn(node)# "list"

name.gdsn(node, fullname=TRUE)# "test/list"

closefn.gds(f)

Page 28: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

28 objdesp.gdsn

objdesp.gdsn Get node description

Description

Gets the descritpion of a specified node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

objdesp.gdsn(node)

Arguments

node an object of class gdsn.class, a GDS node

Value

Returns a list:

type the description of data field

name the variable name of a specified node

svtype the internal type of the specified node: 1 – Int8, 2 – UInt8, 3 – Int16, 4 – UInt16,5 – Int32, 6 – UInt32, 7 – Int64, 8 – UInt64, 9 – Int128, 10 – UInt128, 11 –Float32, 12 – Float64, 13 – Long Float, 14 – UTF8 String, 15 – UTF16 String,16 – UTF32 String, 0 – others

is.array indicates whether it is array-type

dim the dimension of data field

compress the compression method: "", "ZIP", etc

cpratio data compression ratio, "NaN" indicates no compression

maxlen if svtype = 14, 15 or 16, it is the maximum length of characters

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

cnt.gdsn, name.gdsn, ls.gdsn, index.gdsn, delete.gdsn, add.gdsn

Page 29: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

openfn.gds 29

Examples

# cteate the GDS file "test.gds"f <- createfn.gds("test.gds")

# add a vector to "test.gds"node1 <- add.gdsn(f, name="vector1", val=1:10000, compress="ZIP")objdesp.gdsn(node1)

# add a character to "test.gds"node2 <- add.gdsn(f, name="vector2", val=c("A", "BC", "DEF"), compress="ZIP")objdesp.gdsn(node2)

closefn.gds(f)

openfn.gds Open a GDS file

Description

Opens an existing file of CoreArray Genomic Data Structure (GDS) for reading or writing.

Usage

openfn.gds(fn, readonly = TRUE)

Arguments

fn the file name of a GDS file to be opened

readonly if TRUE, the file is opened read-only; otherwise, writing to the file is allowed.

Details

This routine opens an existing GDS file for reading (or, if readonly=FALSE, for writing). To createa new GDS file, use createfn.gds instead.

If the file is opened read-only, all data in the file are not allowed to change, including hierachicalstructure, variable names, data field, etc.

Value

Return an object of class gds.class.

filename the file name

id ID of GDS file, internal use

root an object of class gdsn.class, the root of hierachical structure

readonly whether it is read-only or not

Page 30: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

30 print.gds.class

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

createfn.gds, closefn.gds

Examples

# cteate the GDS file "test.gds"f <- createfn.gds("test.gds")# add a list to "test.gds"node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE))# closeclosefn.gds(f)

# openf <- openfn.gds("test.gds")# read(node <- index.gdsn(f, "list"))read.gdsn(node)# closeclosefn.gds(f)

print.gds.class Show the information of class "gds.class"

Description

Displays an object of class "gds.class", in a CoreArray Genomic Data Structure (GDS) file.

Usage

## S3 method for class ’gds.class’print(x, all=FALSE, ...)

Arguments

x an object of class gds.class, a CoreArray GDS file

all if FALSE, hide GDS nodes with an attribute "R.invisible"

... the arguments passed to or from other methods

Author(s)

Xiuwen Zheng <[email protected]>

Page 31: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

print.gdsn.class 31

References

http://sourceforge.net/projects/corearray/

See Also

print.gdsn.class

print.gdsn.class Show the information of class "gdsn.class"

Description

Displays an object of class "gdsn.class", a GDS node in a CoreArray Genomic Data Structure (GDS)file.

Usage

## S3 method for class ’gdsn.class’print(x, expand = TRUE, all=FALSE, ...)

Arguments

x an object of class gdsn.class, a GDS node

expand whether enumerate all of child nodes

all if FALSE, hide GDS nodes with an attribute "R.invisible"

... the arguments passed to or from other methods

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

print.gds.class

Page 32: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

32 put.attr.gdsn

put.attr.gdsn Add an attribute into a GDS file

Description

Adds an attribute to a GDS node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

put.attr.gdsn(node, name, val = NULL)

Arguments

node an object of class gdsn.class, a GDS node

name the name of an attribute

val the value of an attribute

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

get.attr.gdsn, delete.attr.gdsn

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

node <- add.gdsn(f, "int", val=as.integer(1:10000))put.attr.gdsn(node, "missing.value", 10000)

fget.attr.gdsn(node)

closefn.gds(f)

Page 33: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

read.gdsn 33

read.gdsn Read data field of a GDS node

Description

Gets data from a GDS node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

read.gdsn(node, start, count)

Arguments

node an object of class gdsn.class, a GDS node

start a vector of integers, starting from 1 for each dimension component

count a vector of integers, the length of each dimnension. As a special case, the value"-1" indicates that all entries along that dimension should be written

Details

start, count: the values in data are taken to be those in the array with the leftmost subscriptmoving fastest.

Value

Returns an array, list, or data.frame.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

readex.gdsn, append.gdsn, write.gdsn, add.gdsn

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

add.gdsn(f, "vector", val=1:128)add.gdsn(f, "list", val=list(X=1:10, Y=seq(1, 10, 0.25)))add.gdsn(f, "data.frame", val=data.frame(X=1:19, Y=seq(1, 10, 0.5)))

Page 34: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

34 readex.gdsn

f

read.gdsn(index.gdsn(f, "vector"))read.gdsn(index.gdsn(f, "list"))read.gdsn(index.gdsn(f, "data.frame"))

closefn.gds(f)

readex.gdsn Read data field of a GDS node with a selection

Description

Gets data from a GDS node with subset selection, in a CoreArray Genomic Data Structure (GDS)file.

Usage

readex.gdsn(node, sel=NULL)

Arguments

node an object of class gdsn.class, the GDS node

sel a list of m logical vectors, where m is the number of dimensions of node andeach logical vector should have the same size of dimension in node

Value

Return an array.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

read.gdsn, append.gdsn, write.gdsn, add.gdsn

Page 35: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

readmode.gdsn 35

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

add.gdsn(f, "vector", val=1:128)add.gdsn(f, "matrix", val=matrix(as.character(1:(10*6)), nrow=10))f

# read vectorreadex.gdsn(index.gdsn(f, "vector"), sel=rep(c(TRUE, FALSE), 64))

# read matrixreadex.gdsn(index.gdsn(f, "matrix"))readex.gdsn(index.gdsn(f, "matrix"),sel=list(d1=rep(c(TRUE, FALSE), 5), d2=rep(c(TRUE, FALSE), 3)))

closefn.gds(f)

readmode.gdsn Get into read mode in the compression mode

Description

Gets into the read mode for a GDS node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

readmode.gdsn(node)

Arguments

node an object of class gdsn.class, a GDS node

Details

After the compressed data field is created, it is in writing mode. Users can add new data to thecompressed data field, but can not read data from the data field. Users need to call readmode.gdsnfor reading.

Once get into the read mode, users can not add more data to the data field. If users would like toappend more data or modify the data field, please call compression.gdsn (node, compress="")to decompress data first.

Value

Return node.

Author(s)

Xiuwen Zheng <[email protected]>

Page 36: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

36 rename.gdsn

References

http://sourceforge.net/projects/corearray/

See Also

compression.gdsn, add.gdsn

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))

# commom typesn <- add.gdsn(f, "int", val=as.integer(1:10000), compress="ZIP")

# you can not read "int", because "int" is in writing mode.# read.gdsn(n)

readmode.gdsn(n)

# now you can read "int"read.gdsn(n)

closefn.gds(f)

rename.gdsn Rename a GDS node

Description

Renames a GDS node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

rename.gdsn(node, newname)

Arguments

node an object of class gdsn.class, a GDS node

newname the new name of a specified node

Details

CoreArray hierarchical structure does not allow duplicate names in the same path.

Value

Returns node.

Page 37: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

setdim.gdsn 37

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

cnt.gdsn, objdesp.gdsn, ls.gdsn, index.gdsn

Examples

# cteate the GDS file "test.gds"f <- createfn.gds("test.gds")n <- add.gdsn(f, "old.name", val=1:10)f

rename.gdsn(n, "new.name")f

closefn.gds(f)

setdim.gdsn Set the dimension of data field

Description

Assigns a new dimension to the data field of a GDS node, in a CoreArray Genomic Data Structure(GDS) file.

Usage

setdim.gdsn(node, valdim)

Arguments

node an object of class gdsn.class, a GDS node

valdim the new dimension for the array to be created, which is a vector of length one ormore giving the maximal indices in each dimension

Value

Returns node.

Author(s)

Xiuwen Zheng <[email protected]>

Page 38: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

38 sync.gds

References

http://sourceforge.net/projects/corearray/

See Also

read.gdsn, write.gdsn, append.gdsn, add.gdsn

Examples

# cteate the GDS file "test.gds"(f <- createfn.gds("test.gds"))n <- add.gdsn(f, "int", val=as.integer(1:100))fsetdim.gdsn(n, c(120, 4))fclosefn.gds(f)

sync.gds Synchronize a GDS file

Description

Writes the data cached in memory to disk.

Usage

sync.gds(gds)

Arguments

gds An object of class gds.class, returned by createfn.gds or openfn.gds

Details

For better performance, Data in a GDS file are usually cached in memory. Keep in mind that thenew file may not actually be written to disk, until closefn.gds or sync.gds is called. Anyway,when R shuts down, all GDS files created or opened would be automatically closed.

Value

None.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

Page 39: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

write.gdsn 39

See Also

createfn.gds, openfn.gds

write.gdsn Write data to a GDS node

Description

Writes data to a GDS node, in a CoreArray Genomic Data Structure (GDS) file.

Usage

write.gdsn(node, val, start, count)

Arguments

node an object of class gdsn.class, a GDS node

val the data to be written

start a vector of integers, starting from 1 for each dimension

count a vector of integers, the length of each dimnension

Details

start, count: The values in data are taken to be those in the array with the leftmost subscriptmoving fastest.

start and count should both exist or be missing. If start and count are both missing, the dimen-sions and values of val will be assigned to the data field.

Value

None.

Author(s)

Xiuwen Zheng <[email protected]>

References

http://sourceforge.net/projects/corearray/

See Also

append.gdsn, read.gdsn, add.gdsn

Page 40: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

40 write.gdsn

Examples

(f <- createfn.gds("test.gds"))L <- -2500:2499

# commom typesadd.gdsn(f, "int.matrix", val=matrix(L, nrow=100, ncol=50),

valdim=c(110, 60))write.gdsn(index.gdsn(f, "int.matrix"), val=rep(0, 100), start=c(20, 20),

count=c(10, 10))fclosefn.gds(f)

Page 41: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

Index

∗Topic GDSadd.gdsn, 4addfile.gdsn, 6append.gdsn, 8apply.gdsn, 9assign.gdsn, 11cleanup.gds, 12closefn.gds, 13clusterApply.gdsn, 14cnt.gdsn, 16compression.gdsn, 17createfn.gds, 18delete.attr.gdsn, 19delete.gdsn, 20gds.class, 21gdsfmt-package, 2gdsn.class, 21gdsUnitTest, 22get.attr.gdsn, 22getfile.gdsn, 23index.gdsn, 24lasterr.gds, 25ls.gdsn, 26name.gdsn, 27objdesp.gdsn, 28openfn.gds, 29print.gds.class, 30print.gdsn.class, 31put.attr.gdsn, 32read.gdsn, 33readex.gdsn, 34readmode.gdsn, 35rename.gdsn, 36setdim.gdsn, 37sync.gds, 38write.gdsn, 39

∗Topic IOgdsfmt-package, 2

∗Topic database

gdsfmt-package, 2∗Topic file

gdsfmt-package, 2∗Topic interface

gdsfmt-package, 2∗Topic utilities

add.gdsn, 4addfile.gdsn, 6append.gdsn, 8apply.gdsn, 9assign.gdsn, 11cleanup.gds, 12closefn.gds, 13clusterApply.gdsn, 14cnt.gdsn, 16compression.gdsn, 17createfn.gds, 18delete.attr.gdsn, 19delete.gdsn, 20gds.class, 21gdsfmt-package, 2gdsn.class, 21gdsUnitTest, 22get.attr.gdsn, 22getfile.gdsn, 23index.gdsn, 24lasterr.gds, 25ls.gdsn, 26name.gdsn, 27objdesp.gdsn, 28openfn.gds, 29print.gds.class, 30print.gdsn.class, 31put.attr.gdsn, 32read.gdsn, 33readex.gdsn, 34readmode.gdsn, 35rename.gdsn, 36setdim.gdsn, 37

41

Page 42: Package ‘gdsfmt’Package ‘gdsfmt’ February 19, 2013 Type Package Title CoreArray Genomic Data Structure (GDS) R Interface Version 0.9.12 Date 2013-02-15 Depends R (>= 2.12.0)

42 INDEX

sync.gds, 38write.gdsn, 39

add.gdsn, 4, 7, 8, 17, 18, 20, 21, 24, 25, 28,33, 34, 36, 38, 39

addfile.gdsn, 6, 24append.gdsn, 8, 33, 34, 38, 39apply.gdsn, 9, 15assign.gdsn, 11

cleanup.gds, 12closefn.gds, 12, 13, 13, 18, 21, 30, 38clusterApply.gdsn, 10, 14cnt.gdsn, 5, 7, 16, 20, 24–28, 37compression.gdsn, 17, 35, 36createfn.gds, 12–14, 18, 21, 29, 30, 38, 39

delete.attr.gdsn, 19, 23, 32delete.gdsn, 17, 20, 25, 28

gds.class, 4, 7, 13, 18, 21, 23, 24, 29, 30, 38gdsfmt (gdsfmt-package), 2gdsfmt-package, 2gdsn.class, 4, 5, 7–9, 11, 16–21, 21, 22–29,

31–37, 39gdsUnitTest, 22get.attr.gdsn, 19, 22, 32getfile.gdsn, 7, 23

index.gdsn, 5, 7, 17, 20, 21, 24, 24, 26, 28, 37

lasterr.gds, 25ls.gdsn, 5, 7, 17, 20, 24–26, 26, 27, 28, 37

name.gdsn, 5, 7, 20, 24, 25, 27, 28

objdesp.gdsn, 5, 7, 17, 20, 24–27, 28, 37openfn.gds, 12–14, 18, 21, 29, 38, 39

parallel, 14print.gds.class, 30, 31print.gdsn.class, 31, 31put.attr.gdsn, 19, 23, 32

read.gdsn, 8, 10, 12, 33, 34, 38, 39readex.gdsn, 10, 33, 34readmode.gdsn, 5, 7, 18, 35rename.gdsn, 27, 36

setdim.gdsn, 37sync.gds, 13, 14, 18, 38, 38

write.gdsn, 8, 12, 33, 34, 38, 39