forked from sahilseth/bamreadcountr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_bamreadcount.R
59 lines (46 loc) · 1.86 KB
/
run_bamreadcount.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Usage: bam-readcount [OPTIONS] <bam_file> [region]
# Generate metrics for bam_file at single nucleotide positions.
# Example: bam-readcount -f ref.fa some.bam
# Available options:
# -h [ --help ] produce this message
# -v [ --version ] output the version
# -q [ --min-mapping-quality ] arg (=0) minimum mapping quality of reads used
# for counting.
# -b [ --min-base-quality ] arg (=0) minimum base quality at a position to
# use the read for counting.
# -d [ --max-count ] arg (=10000000) max depth to avoid excessive memory
# usage.
# -l [ --site-list ] arg file containing a list of regions to
# report readcounts within.
# -f [ --reference-fasta ] arg reference sequence in the fasta format.
# -D [ --print-individual-mapq ] arg report the mapping qualities as a comma
# separated list.
# -p [ --per-library ] report results by library.
# -w [ --max-warnings ] arg maximum number of warnings of each type
# to emit. -1 gives an unlimited number.
# -i [ --insertion-centric ] generate indel centric readcounts.
# Reads containing insertions will not be
# included in per-base counts
#' Run BAM readcount
#'
#' @param bam
#' @param bed
#' @param bamreadcount_exe
#'
#' @return
#' @export
#'
#' @examples
bam_readcount <- function(bam,
samplename,
bed,
outfile,
fa_fl = "~/ref/human/b37/fastas/Homo_sapiens_assembly19.fasta",
bamreadcount_exe = "bam-readcount"){
# bam-readcount [OPTIONS] <bam_file> [region]
cmd = glue("{bamreadcount_exe} -l {bed} -f {fa_fl} {bam} > {outfile}")
#system(cmd)
flowmat = to_flowmat(list(bamreadcount = cmd), samplename = samplename)
ret = list(flowmat = flowmat)
return(ret)
}