bamSort: bamSort: Creation of a sorted copy of a BAM file.

Description Usage Arguments Details Author(s) Examples

Description

The function takes an opened instance of bamReader, a prefix for the output file and produces a sorted BAM file which is (apart from being sorted) identical to the input file. BAM-files must be sorted before an index can be created. During this routine, some content of the source file is copied into the working memory, sorted and written into temporary files. Finally, the sorted files are merged into a single target. The name of the sorted BAM-file will be [prefix].bam. Number and size of temporary files depend on source file size and used working memory (maxmem). Small maxmem values result in large numbers of temporary files. The minimum maxmem value is 100000000. Smaller maxmem values cause an error.

Usage

1
2
bamSort(object, prefix="sorted",
            byName=FALSE, maxmem=1e+9, path=dirname(filename(object)))

Arguments

object

bamReader (must be opened) or sampleBamFiles

prefix

The prefix of the output file. When 'sorted' is given as prefix, the routine produces a file named 'sorted.bam'.

byName

(Optional) Logical. Must have length 1. When TRUE the file will be sorted by align name. When FALSE the file will be sorted by coordinate. Sorting by coordinate is the prerequisite for creation of an index file.

maxmem

(Optional) Numeric. Must have length 1. Minimum value is 100000000. Smaller maxmem values cause an error. Determines how many aligns are sorted inside the working memory before they are written into a temporary file.

path

character. Directory where sorted output file is written to. Default value is the directory where the input file is located.

Details

The function does not take a complete name for the output file but only a prefix. The prefix is internally completed with a '.bam' suffix. This is because the samtools function 'bam_sort_core_ext' only takes a prefix. samtools in turn produces intermediate files which also use the prefix and which are removed again when the 'bam_sort_core_ext' cleans up.

Author(s)

Wolfgang Kaisers

Examples

1
2
3
4
5
6
7
bam<-system.file("extdata","accepted_hits.bam",package="rbamtools")
reader<-bamReader(bam)
bamSort(reader)
## - - - - - - - - - - - - - - - - - ##
## sampleBamFiles
## - - - - - - - - - - - - - - - - - ##
bs <- sampleBamFiles(bam)

rbamtools documentation built on Nov. 11, 2019, 5:09 p.m.