createApd: Creates an Affymetrix probe data (APD) file

createApdR Documentation

Creates an Affymetrix probe data (APD) file

Description

Creates an Affymetrix probe data (APD) file.

An Affymetrix probe data (APD) structure can hold a header and a numeric data vector. Since the APD structure is kept on file all the time, the number of elements in the data vector is only limited by the file system and not the amount of system memory available. For more details, see the FileVector class (and its superclass), which is used internally.

Usage

## Default S3 method:
createApd(filename, nbrOfCells, dataType=c("float", "double", "integer", "short",
  "byte"), chipType=NULL, mapType=NULL, ..., verbose=FALSE, .checkArgs=TRUE)

Arguments

filename

The filename of the APD file.

nbrOfCells

The number of cells (probes) data elements the APD file structure should hold.

dataType

The data type of the data elements.

chipType

An (optional) character string specifying the chip type.

mapType

An (optional) character string specifying the probe-index map. Use by findApdMap() to find read map.

...

Additional named arguments added to the header of the APD file structure.

verbose

See Verbose.

.checkArgs

If TRUE, arguments are checked, otherwise not.

Value

Returns (invisibly) the pathname of the file created.

Data type

Valid data types are: byte (1 byte), short (2 bytes), integer (4 bytes), float (4 bytes), and double (8 bytes).

Note that in Affymetrix CEL files, the probe intensities as well as the standard deviations are stored as floats (4 bytes) and not doubles (8 bytes). This is why, the default data type is "float".

Author(s)

Henrik Bengtsson

See Also

updateApd() and readApd(). To find a map of a certain type, see findApdMap().

Examples



# Float precision
.Machine$float.eps <- (2^((8-4)*8)*.Machine$double.eps)
tol <- .Machine$float.eps ^ 0.5


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 1. Create an Affymetrix Probe Signal (APD) file for a
#    'Mapping50K_Hind240' with 1600-by-1600 probes.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
chipType <- "Mapping50K_Hind240"
nbrOfCells <- 1600^2

pathname <- paste(tempfile(), "apd", sep=".")
createApd(pathname, nbrOfCells=nbrOfCells, chipType=chipType)

# File size
cat("File name:", pathname, "\n")
cat("File size:", file.info(pathname)$size, "bytes\n")
cat("APD header:\n")
header <- readApdHeader(pathname)
print(header)


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 2. Update the signals for a subset of probes
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cells <- c(1, 1100:1120, 220:201, 998300:999302)
signals <- log(cells+1, base=2)  # Fake signals
updateApd(pathname, indices=cells, data=signals)


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 3. Re-read the signals for a subset of probes
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apd <- readApd(pathname, indices=cells)

# Signals in APD files are stored as floats (since this is
# the precision in CEL files).
stopifnot(all.equal(signals, apd$intensities, tolerance=tol))


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 4. Re-read the signals for a subset of probes
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (require("affxparser") && FALSE) {
  cdfFile <- findCdf(chipType)
  if (length(cdfFile) > 0) {
 
    apd <- readApdUnits(pathname, units=100:104)
   
    # Sample new data (with one decimal precision)
    apd2 <- lapply(apd, function(unit) {
      lapply(unit, function(groups) {
        n <- length(groups$intensities)
        values <- as.integer(runif(n, max=655350))/10
        list(intensities=values)
      })
    })
   
    # Update APD file with new data
    updateApdUnits(pathname, units=100:104, data=apd2)
   
    # Re-read data to verify correctness
    apd <- readApdUnits(pathname, units=100:104)
   
    # Signals in APD files are stored as floats (since this is
    # the precision in CEL files).
    stopifnot(all.equal(apd2, apd, tolerance=tol))
  } # if (length(cdfFile) > 0 ...)
} # if (require("affxparser"))


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 4. Clean up
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
file.remove(pathname)



HenrikBengtsson/aroma.apd documentation built on Jan. 31, 2024, 8:17 a.m.