NcdfReader {GWASTools} | R Documentation

## Class NcdfReader

### Description

The NcdfReader class is a wrapper for the ncdf4-package that provides an interface for reading NetCDF files.

### Constructor

  `NcdfReader(filename)`:

  `filename` must be the path to a NetCDF file.

  The `NcdfReader` constructor creates and returns a NcdfReader instance pointing to this file.

### Accessors

In the code snippets below, `object` is a NcdfReader object.

  `getVariable(object, varname, start, count, drop=TRUE)`: Returns the contents of the variable `varname`.

  - `start` is a vector of integers indicating where to start reading values. The length of this vector must equal the number of dimensions the variable has. If not specified, reading starts at the beginning of the file (1,1,...).

  - `count` is a vector of integers indicating the count of values to read along each dimension. The length of this vector must equal the number of dimensions the variable has. If not specified and the variable does NOT have an unlimited dimension, the entire variable is read. As a special case, the value "-1" indicates that all entries along that dimension should be read.

  - `drop` is a logical for whether the result will be coerced to the lowest possible dimension.

  The result is a vector, matrix, or array, depending on the number of dimensions in the returned values and the value of `drop`. Missing values (specified by a "missing_value" attribute, see `ncvar_change_missval`) are represented as `NA`. If the variable is not found in the NetCDF file, returns `NULL`.

  `getVariableNames(object)`: Returns names of variables in the NetCDF file.

  `getDimension(object, varname)`: Returns dimension for NetCDF variable `varname`.

  `getDimensionNames(object, varname)`: Returns names of dimensions in the NetCDF file. If `varname` is provided, returns dimension names for NetCDF variable `varname`.

  `getAttribute(object, attname, varname)`: Returns the attribute `attname` associated with the variable `varname`. If `varname` is not specified, `attname` is assumed to be a global attribute.

  `hasCoordVariable(object, varname)`: Returns `TRUE` if `varname` is a coordinate variable (a variable with the same name as a dimension).

  `hasVariable(object, varname)`: Returns `TRUE` if `varname` is a variable in the NetCDF file (including coordinate variables).

### Standard Generic Methods

In the code snippets below, `object` is a NcdfReader object.

  `open(object)`: Opens a connection to a NetCDF file.

  `close(object)`: Closes the connection to a NetCDF file.

  `show(object)`: Summarizes the contents of a NetCDF file.

### Author(s)

Stephanie Gogarten

### See Also

ncdf4-package, `NcdfGenotypeReader`, `NcdfIntensityReader`

### Examples

    file <- system.file("extdata", "affy_geno.nc", package="GWASdata")
    nc <- NcdfReader(file)

    getDimensionNames(nc)
    getVariableNames(nc)

    hasVariable(nc, "genotype")
    geno <- getVariable(nc, "genotype", start=c(1,1), count=c(10,10))

    close(nc)

[Package GWASTools version 1.33.3 Index]