Prepare quant files for tximport
Arguments
- dir
character(1). Directory path containing quant files. Seetximport()for details.- type
character(1). Type of quant/abundance file to find. Expecting"quant.sf"for salmon,"abundance.h5"for kallisto.- makeNames
character(1). Syntactic name function to apply on sample names. Usesmatch.arg()internally.
Details
Runs the following internal comments:
Extract sample directory name from quant file using
dirname()andbasename().Autopad zeros, if necessary, via
autopadZeros().Sanitizes names with
snakeCase().Sorts files alphabetically.
Examples
suppressPackageStartupMessages({
library(AcidBase)
})
tempdir <- tempdir2()
#> Error in vapply(X = X, FUN = FUN, FUN.VALUE = logical(1L), ..., USE.NAMES = useNames): formal argument "USE.NAMES" matched by multiple actual arguments
samples <- c("1-sample-A", "2-sample-B")
salmonDir <- initDir(file.path(tempdir, "salmon"))
#> Error in file.path(tempdir, "salmon"): cannot coerce type 'closure' to vector of type 'character'
kallistoDir <- initDir(file.path(tempdir, "kallisto"))
#> Error in file.path(tempdir, "kallisto"): cannot coerce type 'closure' to vector of type 'character'
invisible({
lapply(X = file.path(salmonDir, samples), FUN = initDir)
file.create(file.path(salmonDir, samples, "quant.sf"))
lapply(X = file.path(kallistoDir, samples), FUN = initDir)
file.create(file.path(kallistoDir, samples, "abundance.h5"))
})
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'X' in selecting a method for function 'lapply': object 'salmonDir' not found
salmonFiles <- prepareTximportFiles(dir = salmonDir, type = "salmon")
#> Error: object 'salmonDir' not found
print(salmonFiles)
#> Error: object 'salmonFiles' not found
kallistoFiles <- prepareTximportFiles(dir = kallistoDir, type = "kallisto")
#> Error: object 'kallistoDir' not found
print(kallistoFiles)
#> Error: object 'kallistoFiles' not found
unlink2(tempdir)
#> Error in file.exists(x): invalid 'file' argument