Sorts and indexes the BAM file, and retrieves the idxstats (summary of the number of mapped reads on every chromosome) using Rsamtools package.

sort_index_idxstats_bam(
  bam_file,
  sorted_bam_file,
  sort = TRUE,
  index = TRUE,
  idxstats = TRUE
)

Arguments

bam_file

Input BAM file.

sorted_bam_file

Output file name for sorted BAM file if sort=TRUE.

sort

Logical. If TRUE, sorts the BAM file.

index

Logical. If TRUE, indexes the BAM file.

idxstats

Logical. If TRUE, retrieves idxstats summary of the number of mapped reads in each chromosome.

Examples

if (FALSE) {
# Sorts, indexes the BAM file, and retrieves the idxstats.
sort_index_idxstats_bam('example.bam', sort=TRUE, index=TRUE, idxstats=TRUE)

# Indexes the BAM file, and retrieves the idxstats, using sorted BAM file.
sort_index_idxstats_bam('example.sorted.bam', sort=FALSE, index=TRUE, idxstats=TRUE)
}