run_samtools: Run Samtools

Description Usage Arguments Value Examples

View source: R/run_samtools.R

Description

Runs the samtools program

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
run_samtools(
  command = NULL,
  input = NULL,
  output = NULL,
  sample.name = NULL,
  threads = 10,
  mapq = NULL,
  memory = "5G",
  parallel = FALSE,
  cores = 4,
  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,

sample.name

List of sample names, required

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

samtools

Path to the samtools program, required

version

Returns the version number

Value

A list with the samtools commands

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## 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 June 19, 2021, 1:08 p.m.