om..bcftools

outsider-module: bcftools

https://github.com/stephenturner/om..bcftools

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.6%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

outsider-module: bcftools

Basic Info
  • Host: GitHub
  • Owner: stephenturner
  • License: other
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 37.1 KB
Statistics
  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 4 years ago · Last pushed over 4 years ago
Metadata Files
Readme License Citation

README.Rmd

---
output: github_document
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
  eval=FALSE,
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
```

# Run `bcftools` with `outsider` in R

This module allows you to run bcftools in R via Docker. See the full [bcftools documentation](http://samtools.github.io/bcftools/bcftools.html) for more information.


## Installation

```{r}
# install.packages("outsider")
library(outsider)
module_install(repo = "stephenturner/om..bcftools")
```

## Examples

After installing the bcftools outsider module, import the `bcftools()`, `bgzip()`, and `tabix()` functions into your global environment.

```{r}
library(outsider)
bcftools <- module_import(fname = 'bcftools', repo = "stephenturner/om..bcftools")
bgzip <- module_import(fname = 'bgzip', repo = "stephenturner/om..bcftools")
tabix <- module_import(fname = 'tabix', repo = "stephenturner/om..bcftools")
```

If you'd like, copy an example VCF file from the package to your current working directory to work with.

```{r}
file.copy(from=system.file("extdata", "example.vcf", package = "om..bcftools"), to=".")
```

Take a look at it:

```{r}
bcftools("view", "example.vcf")
```

```
##fileformat=VCFv4.0
##FILTER=
##source=vcfrandom
##reference=/d2/data/references/build_37/human_reference_v37.fa
##phasing=none
##INFO=
##INFO=
##INFO=
##INFO=
##INFO=
##FORMAT=
##FORMAT=
##FORMAT=
##contig=
##contig=
##bcftools_concatVersion=1.12+htslib-1.12
##bcftools_concatCommand=concat 1.vcf.gz 2.vcf.gz; Date=Fri Nov 12 09:06:27 2021
##bcftools_viewVersion=1.12+htslib-1.12
##bcftools_viewCommand=view -Oz -o example.vcf.gz; Date=Fri Nov 12 09:06:27 2021
#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	example
1	1	.	A	C,G	100	.	DP=65	GT:DP	0/1:12
1	2	.	G	A,G	100	.	DP=41	GT:DP	0/1:77
1	3	.	T	T,G	100	.	DP=36	GT:DP	0/1:65
1	4	.	C	T,A	100	.	DP=0	GT:DP	0/1:77
1	5	.	T	T,C	100	.	DP=92	GT:DP	0/1:6
1	6	.	T	G,A	100	.	DP=57	GT:DP	0/1:7
1	7	.	G	C,T	100	.	DP=32	GT:DP	0/1:16
1	8	.	C	A,A	100	.	DP=94	GT:DP	0/1:76
1	9	.	A	T,A	100	.	DP=78	GT:DP	0/1:64
2	1	.	C	A,G	100	.	DP=10	GT:DP	0/1:21
2	2	.	C	G,A	100	.	DP=61	GT:DP	0/1:87
2	3	.	C	T,A	100	.	DP=20	GT:DP	0/1:0
2	4	.	A	G,G	100	.	DP=47	GT:DP	0/1:37
2	5	.	G	T,T	100	.	DP=49	GT:DP	0/1:71
2	6	.	A	C,G	100	.	DP=52	GT:DP	0/1:94
2	7	.	A	A,T	100	.	DP=74	GT:DP	0/1:78
2	8	.	T	A,A	100	.	DP=48	GT:DP	0/1:87
2	9	.	A	G,A	100	.	DP=3	GT:DP	0/1:48
```

Compress and tabix index it:

```{r}
bgzip("example.vcf")
tabix("example.vcf.gz")
```

Query just chromosome 2 to get chromosome, position, ref, alternate alleles, and the genotype, in a tab delimited output.

```{r}
bcftools("query", "-r 2", "-f '%CHROM\\t%POS\\t%REF\\t%ALT\\t[%TGT]\\n'", "example.vcf.gz")
```

```
2	1	C	A,G	C/A
2	2	C	G,A	C/G
2	3	C	T,A	C/T
2	4	A	G,G	A/G
2	5	G	T,T	G/T
2	6	A	C,G	A/C
2	7	A	A,T	A/A
2	8	T	A,A	T/A
2	9	A	G,A	A/G
```

Add an `output_file=` to write it to file:

```{r}
bcftools("query", "-r 2", "-f '%CHROM\\t%POS\\t%REF\\t%ALT\\t[%TGT]\\n'", "example.vcf.gz", output_file="example.vcf.query.tsv")
```

Read it back in:

```{r}
read.table("example.vcf.query.tsv")
```

```
  V1 V2 V3  V4  V5
1  2  1  C A,G C/A
2  2  2  C G,A C/G
3  2  3  C T,A C/T
4  2  4  A G,G A/G
5  2  5  G T,T G/T
6  2  6  A C,G A/C
7  2  7  A A,T A/A
8  2  8  T A,A T/A
9  2  9  A G,A A/G
```

Plugins work too!

```{r}
bcftools("plugin --list-plugins")
```

```
GTisec
GTsubset
ad-bias
add-variantkey
af-dist
allele-length
check-ploidy
check-sparsity
color-chrs
contrast
counts
dosage
fill-AN-AC
fill-from-fasta
fill-tags
fixploidy
fixref
frameshifts
guess-ploidy
gvcfz
impute-info
indel-stats
isecGT
mendelian
missing2ref
parental-origin
prune
remove-overlaps
scatter
setGT
smpl-stats
split
split-vep
tag2tag
trio-dnm2
trio-stats
trio-switch-rate
variantkey-hex
```

Clean up:

```{r}
file.remove(c("example.vcf", "example.vcf.gz", "example.vcf.gz.tbi", "example.vcf.query.tsv"))
```


## Links

Find out more by visiting the [bcftools's manual page](http://samtools.github.io/bcftools/bcftools.html).

## Please cite

- Turner, S.D. (2021). Bcftools outsider module. .
- Bennett et al., (2020). outsider: Install and run programs, outside of R, inside of R. Journal of Open Source Software, 5(45), 2038, https://doi.org/10.21105/joss.02038
- Danecek, Petr, et al. "Twelve years of SAMtools and BCFtools." Gigascience 10.2 (2021): https://doi.org/10.1093/gigascience/giab008.


---



**An `outsider` module**

Learn more at [outsider website](https://docs.ropensci.org/outsider/).
Want to build your own module? Check out [`outsider.devtools` website](https://docs.ropensci.org/outsider.devtools/).

Owner

  • Name: Stephen Turner
  • Login: stephenturner
  • Kind: user
  • Location: Charlottesville, VA
  • Company: @colossal-compsci

Data scientist in biotech, former academic, Principal Scientist and Head of Genomic Strategy at Colossal Biosciences

Citation (CITATION.cff)

# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.1.1
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------
 
cff-version: 1.2.0
message: 'To cite package "om..bcftools" in publications use:'
type: software
license: MIT
title: 'om..bcftools: Outsider module for running bcftools'
version: 0.0.1
abstract: Install and run bcftools from within R.
authors:
- family-names: Turner
  given-names: Stephen
  email: vustephen@gmail.com
  orcid: https://orcid.org/0000-0001-9140-9028
preferred-citation:
  type: manual
  title: 'om..bcftools: Outsider module for running bcftools'
  authors:
  - family-names: Turner
    given-names: Stephen
    email: vustephen@gmail.com
    orcid: https://orcid.org/0000-0001-9140-9028
  version: 0.0.1
  abstract: Install and run bcftools from within R.
  contact:
  - family-names: Turner
    given-names: Stephen
    email: vustephen@gmail.com
    orcid: https://orcid.org/0000-0001-9140-9028
  license: MIT
  year: '2021'
contact:
- family-names: Turner
  given-names: Stephen
  email: vustephen@gmail.com
  orcid: https://orcid.org/0000-0001-9140-9028

GitHub Events

Total
Last Year

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 28
  • Total Committers: 1
  • Avg Commits per committer: 28.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Stephen Turner v****n@g****m 28

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels