Skip to content

Instantly share code, notes, and snippets.

@katwre
Last active August 27, 2015 12:22
Show Gist options
  • Save katwre/3da58ff9c70d775af120 to your computer and use it in GitHub Desktop.
Save katwre/3da58ff9c70d775af120 to your computer and use it in GitHub Desktop.
count total number of reads
bampath = "example.bam"
command=paste0("samtools idxstats ", bampath," | awk 'BEGIN {a=0} {a += $3 } END{print a }'")
tot.mapped=as.numeric(try(system(command,intern=TRUE)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment