merge_bam_files: Merge multiple .bam files

Description Usage Arguments Value Examples

Description

This function merges .bam files. It first used the combined_header funtion to generate a combined header for all the files, reheaders the files, and then merges and sorts the .bam files. This is similar to the 'samtools merge' function, but it allows the .bam files to have different headers.

Usage

1
2
merge_bam_files(bam_files, destination, head_file = paste(destination,
  "_header.sam", sep = ""))

Arguments

bam_files

A list of file names for the .bam files to be merged

destination

A file name and location for the merged .bam file

head_file

A file name and location for the combined header file. Defaults to the destiation . For example, 'example.bam' will be written as 'exampleh.bam'

Value

This function merges .bam files and combines them into a single file. The function also outputs the new .bam filename.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
download_refseq('viral', compress = FALSE)
mk_subread_index('viral.fasta', split = .0005)
readPath <- system.file("extdata", "virus_example.fastq", package = "animalcules.preprocess")
Rsubread::align(index = "viral_1", readfile1 = readPath, output_file = "virus_example1.bam")
Rsubread::align(index = "viral_2", readfile1 = readPath, output_file = "virus_example2.bam")
bam_files <- c('virus_example1.bam','virus_example2.bam')
com_head <- combined_header(bam_files)
bam_reheader_R(com_head, 'virus_example1.bam')
bam_reheader_R(com_head, 'virus_example1.bam')
bam_files <- c('virus_example1h.bam','virus_example2h.bam')
merged_all <- merge_bam_files(bam_files, 'virus_example_merged')

wevanjohnson/animalcules.preprocess documentation built on May 11, 2019, 8:26 p.m.