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. > library("R.utils") # Arguments Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help. R.oo v1.27.0 (2024-11-01 18:00:02 UTC) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object is masked from 'package:R.methodsS3': throw The following objects are masked from 'package:methods': getClasses, getMethods The following objects are masked from 'package:base': attach, detach, load, save R.utils v2.13.0 (2025-02-24 21:20:02 UTC) successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object is masked from 'package:affxparser': findFiles The following object is masked from 'package:utils': timestamp The following objects are masked from 'package:base': cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings > > verbose <- Arguments$getVerbose(TRUE) > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # 1. Scan for existing CEL files > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # a) Scan current directory for CEL files > files <- list.files(pattern="[.](cel|CEL)$") > files <- files[!file.info(files)$isdir] > if (length(files) > 0 && require("affxparser")) { + # b) Corresponding APD filenames + celNames <- files + apdNames <- gsub(pattern, ".apd", files) + + + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # 1. Copy the probe intensities from a CEL to an APD file + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + for (kk in 1) { + verbose && enter(verbose, "Reading CEL file #", kk) + cel <- readCel(celNames[kk]) + verbose && exit(verbose) + + chipType <- cel$header$chiptype + verbose && enter(verbose, "Getting read map for '", chipType, "'") + mapType <- chipType + mapFile <- paste(mapType, ".apm", sep="") + if (file.exists(mapFile)) { + verbose && enter(verbose, "Reading read map from APD map file") + readMap <- readApdMap(mapFile)$map + verbose && exit(verbose) + } else { + verbose && enter(verbose, "Generating read map from CDF file") + cdfFile <- findCdf(chipType) + readMap <- readCdfUnitsMap(cdfFile) + writeApdMap(mapFile, map=readMap) + verbose && exit(verbose) + } + verbose && exit(verbose) + + if (!file.exists(apdNames[kk])) { + verbose && enter(verbose, "Calculating write map from read map") + writeMap <- invertMap(readMap) + verbose && exit(verbose) + + verbose && enter(verbose, "Creating APD file #", kk) + writeApd(apdNames[kk], data=cel$intensities, chipType=chipType, + mapType=mapType, writeMap=writeMap) + verbose && exit(verbose) + rm(writeMap) + } + + verbose && enter(verbose, "Verifying APD file #", kk) + apd <- readApd(apdNames[kk], readMap=readMap) + verbose && exit(verbose) + stopifnot(identical(apd$intensities, cel$intensities)) + + rm(cel, mapType, mapFile, apd) + } + + + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # 2. Read a subset of the units + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + units <- c(1, 20:205) + cel <- readCelUnits(celNames[1], units=units) + apd <- readApdUnits(apdNames[1], units=units) + stopifnot(identical(apd, cel)) + + + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # 3. Benchmark reading with and without read map + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # To minimize the overhead from searching for and reading CDF + # file when benchmarking, we read the CDF already here + cdfFile <- findCdf(chipType) + cdf <- readCdfCellIndices(cdfFile, units=units) + + cat("Benchmarks for read APD file:\n") + t0 <- system.time({ + # Approximately 10 times faster than without a read map + apd <- readApdUnits(apdNames[1], cdf=cdf, readMap=readMap) + })[3] + cat(sprintf("a) with read map by vector: %.3fs [ 1.00x]\n", t0)) + + t <- system.time({ + apd <- readApdUnits(apdNames[1], cdf=cdf) + })[3] + cat(sprintf("b) with read map from file: %.3fs [%5.2fx]\n", t, t/t0)) + + t <- system.time({ + # Force no read map to be used + apd <- readApdUnits(apdNames[1], cdf=cdf, readMap=NULL) + })[3] + cat(sprintf("c) without read map : %.3fs [%5.2fx]\n", t, t/t0)) + } # if (length(files) > 0) > > proc.time() user system elapsed 0.18 0.10 0.28