.. _`bio/tximport`: TXIMPORT ======== .. image:: https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/tximport?label=version%20update%20pull%20requests :target: https://github.com/snakemake/snakemake-wrappers/pulls?q=is%3Apr+is%3Aopen+label%3Abio/tximport Import and summarize transcript-level estimates for both transcript-level and gene-level analysis. Example ------- This wrapper can be used in the following way: .. code-block:: python 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: "v3.0.1/bio/tximport" Note that input, output and log file paths can be chosen freely. When running with .. code-block:: bash 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. Software dependencies --------------------- * ``bioconductor-tximport=1.28.0`` * ``r-readr=2.1.4`` * ``r-jsonlite=1.8.7`` Input/Output ------------ **Input:** * A list of paths to count data **Output:** * A tximport RDS object Authors ------- * Thibault Dayris Code ---- .. code-block:: R #!/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)) { tx2gene <- readr::read_tsv(snakemake@input[["tx_to_gene"]]); extra <- base::paste( extra, # Foreward existing arguments ", tx2gene = ", # Argument name "tx2gene" # Add tx2gene to parameters ); } # Add user defined arguments if ("extra" %in% names(snakemake@params)) { if (snakemake@params[["extra"]] != "") { 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 ); .. |nl| raw:: html