createApd: Creates an Affymetrix probe data (APD) file

Description Usage Arguments Value Data type Author(s) See Also Examples

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

1
2
3
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 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")) {
  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)

aroma.apd documentation built on May 2, 2019, 9:58 a.m.