Write NIPTeR-style bin counts to a bgzipped BED file
nipter_bin_bam_bed.RdBins a BAM/CRAM file with NIPTeR defaults and writes the result to a bgzipped, tabix-indexed BED file.
Usage
nipter_bin_bam_bed(
bam,
bed,
binsize = 50000L,
mapq = 0L,
require_flags = 0L,
exclude_flags = 0L,
rmdup = c("none", "flag"),
separate_strands = FALSE,
corrected = NULL,
con = NULL,
reference = NULL,
index = TRUE
)Arguments
- bam
Path to an indexed BAM or CRAM file.
- bed
Path for the output
.bed.gzfile. The tabix index is written alongside aspaste0(bed, ".tbi").- binsize
Bin size in base pairs (default 50000).
- mapq
Minimum mapping quality (default
0L). Set to40Lto match common NIPT pre-filtering (samtools view --min-MQ 40).- require_flags
Integer bitmask; only reads with all bits set are kept (samtools
-f). Default0L.- exclude_flags
Integer bitmask; reads with any bit set are dropped (samtools
-F). Default0L. Set to1024Lto exclude duplicate-flagged reads (samtools view -F 1024).- rmdup
Duplicate removal strategy:
"none"(default) or"flag".- separate_strands
Logical; when
TRUE, includes separatecount_fwdandcount_revcolumns for forward- and reverse-strand counts. DefaultFALSE.- corrected
Optional
NIPTeRSamplealready processed bynipter_gc_correct(). When supplied, its corrected counts populate thecorrected_countcolumn; otherwise the column isNA.- con
Optional open DBI connection with duckhts already loaded.
- reference
Optional FASTA reference path for CRAM inputs.
- index
Logical; create a tabix index (default
TRUE).
Details
When separate_strands = FALSE (default), the output has five columns:
chrom, start, end, count, corrected_count.
When separate_strands = TRUE, the output has nine columns:
chrom, start, end, count, count_fwd, count_rev,
corrected_count, corrected_fwd, corrected_rev. count is the total
(forward + reverse); corrected_count is the total of the per-strand
corrected values.
corrected_count (and corrected_fwd/corrected_rev) is NA until a
GC-corrected sample is supplied via the corrected parameter.
Examples
if (FALSE) { # \dontrun{
nipter_bin_bam_bed("sample.bam", "sample.nipter.bed.gz")
# With pre-filtering matching a typical NIPT pipeline
nipter_bin_bam_bed("sample.dm.bam", "sample.nipter.bed.gz",
mapq = 40L, exclude_flags = 1024L)
# Strand-separated output (9 columns)
nipter_bin_bam_bed("sample.bam", "sample.stranded.bed.gz",
separate_strands = TRUE)
} # }