R version 4.5.0 RC (2025-04-04 r88112 ucrt) -- "How About a Twenty-Six" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("aroma.apd") Loading required package: affxparser aroma.apd v0.7.1 successfully loaded. See ?aroma.apd for help. > > # 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") File name: D:\temp\2025_04_06_19_05_17_23833\RtmpSE8LLX\file284283cf06b13.apd > cat("File size:", file.info(pathname)$size, "bytes\n") File size: 10244369 bytes > cat("APD header:\n") APD header: > header <- readApdHeader(pathname) Warning messages: 1: In readChar(con = con, nchars = 64) : truncating string with embedded nuls 2: In readChar(con = con, nchars = 16) : truncating string with embedded nuls > print(header) $creator [1] "R package aroma.snp by Henrik Bengtsson" $dataType [1] "float" $bytesPerCell [1] "4" $RStorageMode [1] "double" $chipType [1] "Mapping50K_Hind240" $nbrOfProbes [1] 2560000 > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # 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) Warning messages: 1: In readChar(con = con, nchars = 64) : truncating string with embedded nuls 2: In readChar(con = con, nchars = 16) : truncating string with embedded nuls > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # 3. Re-read the signals for a subset of probes > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > apd <- readApd(pathname, indices=cells) Warning messages: 1: In readChar(con = con, nchars = 64) : truncating string with embedded nuls 2: In readChar(con = con, nchars = 16) : truncating string with embedded nuls > > # 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) [1] TRUE > > proc.time() user system elapsed 0.34 0.12 0.92