TXIMPORT¶
Import and summarize transcript-level estimates for both transcript-level and gene-level analysis.
Software dependencies¶
- bioconductor-tximport==1.14.0
- r-readr==1.3.1
- r-jsonlite==1.6
Example¶
This wrapper can be used in the following way:
rule tximport:
input:
quant = expand("quant/A/quant.sf")
# Optional transcript/gene links as described in tximport
# tx2gene = /path/to/tx2gene
output:
txi = "txi.RDS"
params:
extra = "type='salmon', txOut=TRUE"
wrapper:
"0.48.0/bio/tximport"
Note that input, output and log file paths can be chosen freely. When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Notes¶
Add any tximport options in the params, they will be transmitted through the R wrapper. Supplementary options will cause unknown parameters error.
Authors¶
- Thibault Dayris
Code¶
#!/bin/R
# Loading library
base::library("tximport"); # Perform actual count importation in R
base::library("readr"); # Read faster!
base::library("jsonlite"); # Importing inferential replicates
# Cast input paths as character to avoid errors
samples_paths <- sapply( # Sequentially apply
snakemake@input[["quant"]], # ... to all quantification paths
function(quant) as.character(quant) # ... a cast as character
);
# Collapse path into a character vector
samples_paths <- base::paste0(samples_paths, collapse = ', "');
# Building function arguments
extra <- base::paste0("files = c(\"", samples_paths, "\")");
# Check if user provided optional transcript to gene table
if ("tx_to_gene" %in% names(snakemake@input)) {
extra <- base::paste(
extra, # Foreward existing arguments
"tx2gene = ", snakemake@input[["tx_to_gene"]], # Add tx2gene to parameters
sep = ", " # Field separator
);
}
# Add user defined arguments
extra <- base::paste(
extra, # Foreward existing parameters
snakemake@params[["extra"]], # Add user parameters
sep = ", " # Field separator
);
print(extra);
# Perform tximport work
txi <- base::eval( # Evaluate the following
base::parse( # ... parsed expression
text = base::paste0(
"tximport::tximport(", extra, ");" # ... of tximport and its arguments
)
)
);
# Save results
base::saveRDS( # Save R object
object = txi, # The txi object
file = snakemake@output[["txi"]] # Output path is provided by Snakemake
);