run_samtools: Run Samtools

View source: R/run_samtools.R

run_samtoolsR Documentation

Run Samtools

Description

Runs the samtools program

Usage

run_samtools(
  command = NULL,
  input = NULL,
  output = NULL,
  threads = 10,
  mapq = NULL,
  memory = "5G",
  parallel = FALSE,
  cores = 4,
  execute = TRUE,
  samtools = NULL,
  version = FALSE
)

Arguments

command

Samtools command to run, at present can choose from 'view', 'sort', 'index' and 'depth', required

input

List of aligned files in sam or bam format, required

output

List of file names for output,

threads

Number of threads for samtools to use, default set to 10

mapq

Set to minimum mapping quality, for filtering bam files

memory

Set maximum memory per thread, default set to 5Gb

parallel

Run in parallel, default set to FALSE

cores

Number of cores/threads to use for parallel processing, default set to 4

execute

Whether to execute the commands or not, default set to TRUE

samtools

Path to the samtools program, required

version

Returns the version number

Value

A list with the samtools commands

Examples

## Not run: 
alignments_path <- "hisat2_alignments"
sam.files <- list.files(path = alignments_path, pattern = "sam$",
                       full.names = TRUE, recursive = TRUE)
bam.files <- gsub(sam.files, pattern = ".sam", replacement = ".bam")
sorted.bam.files <- gsub(sam.files, pattern = ".sam", replacement = "_sorted.bam")
sample_names <- unlist(lapply(strsplit(list.files(path = reads_path,
                       pattern = "*_R1_001.fastq$",
                       full.names = FALSE),"_"), `[[`, 1))

command <- "view"
samtools.cmds <- run_samtools(command = command,
                              input = sam.files,
                              output = bam.files,
                              sample.name = sample_names
                              samtools = samtools.path))
samtools.cmds

command <- "sort"
samtools.cmds <- run_samtools(command = command,
                              input = bam.files,
                              output = sorted.bam.files
                              samtools = samtools.path)
samtools.cmds

command <- "index"
samtools.cmds <- run_samtools(command = command,
                              input = sorted.bam.files,
                              samtools = samtools.path)
samtools.cmds
command <- "depth"
samtools.cmds <- run_samtools(command = command,
                              input = sorted.bam.files,
                              output = outfile.names,
                              samtools = samtools.path)
samtools.cmds

## End(Not run)


GrahamHamilton/pipelineTools documentation built on Dec. 8, 2024, 3:53 p.m.