Skip to contents

This function merges multiple BAM files into a single output file. It checks for the existence of each input BAM file and the output directory. The function allows optional customization of output names and prefixes.

Usage

mergebams(bams, out_path, names = NULL, prefixes = NULL)

Arguments

bams

A vector of file paths for the BAM files to be merged.

out_path

The directory path where the merged BAM file will be saved. The function will stop if the specified output path does not exist.

names

Optional; a vector of names to assign to the merged BAM files. If not provided, the names will be set to empty list.

prefixes

Optional; a vector of prefixes to prepend to the BAM file names during merging. If not provided, no prefixes are used.

Value

Does not return a value; it generates a merged BAM file at the specified output path.

References

This documentation was written by ChatGPT v4 - OpenAI, conversation with the author, 5-1-2024.

Examples

# Assuming you have valid paths to BAM files:
bam_files <- c("path/to/bam1.bam", "path/to/bam2.bam")
output_path <- "path/to/output/directory"
mergebams(bam_files, output_path)
#> Error in mergebams(bam_files, output_path): Provided out_path not found: path/to/output/directory