`smash_local()`, `sylph_local()` and `funprofiler_local()` are the counterparts of [smash_runs()], [sylph_runs()] and [funprofiler_runs()] for reads already on disk. Instead of a table of SRA runs, they take a table of specimens and a directory of FASTQ files, find each specimen's R1 and R2 files there, and then sketch or profile them exactly as the `*_runs()` functions do, writing the same outputs with the specimen ID in place of the run accession:
- `smash_local()`
`<outdir>/<specimen_id>_k<k>_scale<scaled>_seed<seed>_<method>.sig` (default `outdir`: `data/smash`). R1 and R2 are sketched together into one signature named after the specimen.
- `sylph_local()`
`<outdir>/<specimen_id>_profiling.tsv` (default `outdir`: `data/sylph`). The reads are sketched as a pair (`sylph sketch -1 <R1> -2 <R2> -S <specimen_id>`), so the profile's `Sample_file` column holds the specimen ID.
- `funprofiler_local()`
`<outdir>/<specimen_id>_k<k>_scale<scaled>_ko_profiles.csv` (default `outdir`: `data/funprofiler`). `funcprofiler` takes a single reads file, so R1 and R2 are first joined into `working_file`, which is deleted at the end.
Usage
smash_local(
specimens,
local_files,
k = 31,
scaled = 1000,
method = "abund",
seed = 42,
outdir = file.path("data", "smash"),
quiet = FALSE,
overwrite = FALSE,
smash_env = "smash_env"
)
sylph_local(
specimens,
local_files,
database = "../gtdb-r232-c200-dbv2.syl2db",
outdir = file.path("data", "sylph"),
threads = 6,
quiet = FALSE,
overwrite = FALSE,
sylph_env = "sylph_env"
)
funprofiler_local(
specimens,
local_files,
database = "../KOs_sketched_scaled_1000.sig.zip",
k = 11,
scaled = 1000,
threshold_bp = 1000,
outdir = file.path("data", "funprofiler"),
working_file = "working_data.fastq.gz",
quiet = FALSE,
overwrite = FALSE,
funprofiler_env = "funprofiler_env"
)Arguments
- specimens
A data frame with a `specimen_id` column. The IDs are used in the output file names, so they must be unique and must not contain `/` or `\`. Other columns are ignored.
- local_files
Directory holding the specimens' paired FASTQ files.
- k
For `smash_local()`, k-mer size(s), as in [smash_runs()]; for `funprofiler_local()`, protein k-mer size(s), as in [funprofiler_runs()] (default 11).
- scaled
Scaled value(s), as in [smash_runs()] or [funprofiler_runs()].
- method
`"abund"` to track k-mer abundance, `"noabund"` not to, or `c("abund", "noabund")` for both. Defaults to `"abund"`.
- seed
Hash seed for the sketch. Only a single seed is allowed.
- outdir
Directory for the output files. Created if needed. Defaults to `data/smash`, `data/sylph` or `data/funprofiler`.
- quiet
If `TRUE`, hide the console output of `sourmash`, `sylph` or `funcprofiler`. Defaults to `FALSE`.
- overwrite
If `TRUE`, make outputs that already exist again. If `FALSE` (the default), skip them.
- smash_env
Conda environment with sourmash (see [setup_conda_sourmash()]).
- database
For `sylph_local()`, a sylph database, as in [sylph_runs()]; for `funprofiler_local()`, a KO reference sketch, as in [funprofiler_runs()].
- threads
Number of threads for `sylph sketch` and `sylph profile`.
- sylph_env
Conda environment with sylph (see [setup_conda_sylph()]).
- threshold_bp
Minimum overlap for a KO to be reported, as in [funprofiler_runs()].
- working_file
For `funprofiler_local()`, the path of the temporary file R1 and R2 are joined into. If the read files are not gzipped, the `.gz` ending is dropped.
- funprofiler_env
Conda environment with fmh-funprofiler (see [setup_conda_funprofiler()]).
Value
A tibble, invisibly, like that of the matching `*_runs()` function but with a `specimen_id` column in place of `run_accession`: one row per specimen (and per parameter combination for `smash_local()` and `funprofiler_local()`), with the output path (`signature` or `profile`; `NA` if it failed), `status` and `message`.
Details
Read files are found as in [lv2sra](https://github.com/bjklab/lv2sra): files in `local_files` (not its subdirectories) are recognized by their R1/R2 designator, `_R1` or `_R2`, optionally followed by `_001`, then `.fastq` or `.fq`, optionally gzipped (e.g. `S-240926-01587_S294_R1_001.fastq.gz` or `S-01_R2.fq`). A file belongs to a specimen when the text before `_R1`/`_R2` is the specimen ID, alone or followed by `_` and anything else (`_S294`, `_S572_L001`). The `_` keeps specimen `S-1` from claiming the files of `S-10`, and a file goes to the longest specimen ID it matches. Matching is case-sensitive and character-exact, so `-` and `_` are not interchangeable. A message reports how many specimens had files found, and how many file stems matched a specimen. If a specimen matches more than one pair of files, one pair is used (preferring an exact match) and a warning names the specimen.
Specimens without both an R1 and an R2 file are reported with a warning and recorded as `"failed"` in the result; the other specimens are still processed. As with the `*_runs()` functions, outputs that already exist are skipped unless `overwrite = TRUE` (outputs left unfinished by an interrupted, killed or crashed R session are made again), a specimen that fails is reported with a warning, and `quiet = TRUE` hides the tools' console output. The local read files are never changed or deleted.
Examples
if (FALSE) { # \dontrun{
specimens <- tibble::tibble(specimen_id = c("S-01", "S-02"))
# data/smash/S-01_k31_scale1000_seed42_abund.sig, ...
smash_local(specimens, "fastq")
# data/sylph/S-01_profiling.tsv, ...
sylph_local(specimens, "fastq", database = "../gtdb-r232-c200-dbv2.syl2db")
# data/funprofiler/S-01_k11_scale1000_ko_profiles.csv, ...
funprofiler_local(specimens, "fastq")
} # }