Skip to main content

finds mutants in your scRNA-seq experiment

Project description

cerebra

PyPI Docker Build
Build Status codecov

What is cerebra?

This tool allows you to quickly summarize and interpret VCF files.

If you're interested in learning the full complement of genomic variants present in your DNA/RNA samples, a typical workflow might involve sequencing, followed by variant calling with a tool such as GATK HaplotypeCaller, which generates variant calling format (VCF) files.

A VCF file looks like this:

##source=HaplotypeCaller
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT
chr1 631391 . C T 72.28 . AC=2;AF=1.00;AN=2;DP=2;ExcessHet=3.0103;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=NaN;QD=25.36;SOR=2.303 GT:AD:DP:GQ:PL 1/1:0,2:2:6:84,6,0

Note that only a single VCF record is displayed here. A sequencing run can generate on the order of 108 unique VCF records. Only a small portion of these VCF records are likely to be relevant to the researcher. Thus drawing conclusions from VCF files remains a substantial challenge.

cerebra provides a fast and intuitive framework for summarizing VCF records across samples. It comprises three modules that do the following:

    1) remove germline variants from samples of interest        
    2) count the total number of variants in a given sample, on a per-gene basis           
    3) report protein variants for each sample                 

cerebra gets its name from the eponymous X-men character, who had the ability to detect mutant individuals among the general public.

If you're working with tumor data, it might be a good idea to limit the variant search space to only known, and potentially actionable, cancer variants. Therefore cerebra implements an optional method for restricting to variants also found in the COSMIC database.

This tool was developed for, but is certainly not limited to, single-cell RNA sequencing data. cerebra is free software available under the MIT license.

What makes cerebra different from traditional VCF parsers?

Python libraries exist (i.e. PyVCF and vcfpy) for extracting information from VCF files. Another is GATK VariantsToTable, which produces a file that looks like this:

CHROM    POS ID      QUAL    AC
 1        10  .       50      1
 1        20  rs10    99      10

This table contains only genomic (i.e. DNA-level) coordinates. Often the next questions are: what are the genes associated with these variants, and what are the peptide-level effects of these variants? cerebra queries a reference genome (.fa) and annotation (.gtf) to match each DNA-level variant with its associated gene, and its probable protein variant. cerebra produces the following outfile:

$ python
> import json
> f = open(/path/to/cerebra/output.json)
> data = json.load(f)
> print(json.dumps(data, indent=4))

{
    "CCN1": {
        "A16_B000563": [],
        "A1_B001546": [],
        "A1_B002531": [
            "ENSP00000398736.2:p.(Glu189=)"
        ],
        "A1_B002570": [],
        "A2_B002558": [],
        "A3_B000561": [
            "ENSP00000398736.2:p.(Arg209Trp)",
            "ENSP00000398736.2:p.(Ile90Val)"
        ],
        "A3_B000568": [],
        "A3_B001544": [
            "ENSP00000398736.2:p.(Ala82Thr)"
        ],
        "A3_B002090": [],
        "A3_B002531": [
            "ENSP00000398736.2:p.(Pro217Ser)"
        ]
    }
}

Here CCN1 is a gene name while A16_B000563, A1_B001546, A1_B002531,... are RNA-seq sample IDs. cerebra reports variants to every gene in the genome, for every sample in a given experiment. The ENSP* numbers refer to Ensembl translation IDs -- unique identifiers that correspond to exactly one polypeptide in the Ensembl database. The strings enclosed in parentheses refer to the amino-acid level variants reported in that particular sample. For example the string Arg209Trp indicates that position 209 of this particular polypeptide should contain an Arg, but the experimental sample instead contains a Trp. cerebra adheres to HGVS sequence variant nomenclature in reporting amino-acid variants.

Features

germline-filter

Variant calling is often applied to the study of cancer. If the research project is centered around a “tumor vs. normal” question, then germline-filter is the proper starting point. This module removes germline variants that are common between tumor and normal samples, and thus excludes variants unlikely to be pathogenic for the cancer under study. The user provides a very simple metadata file (see USAGE.md) that indicates which tumor samples correspond to which normal samples. The output of germline-filter is a set of trimmed-down VCF files, which will be used for the next two steps. If you do not have access to “normal” samples then proceed directly to count-variants or find-peptide-variants.

count-variants

This module reports the raw variant counts for every gene across every sample. The output is a CSV file that contains counts for each sample versus every gene in the genome. If working with cancer variants, the user has the option of limiting the search space to variants also found in the COSMIC database.

find-peptide-variants

This module reports the protein variations associated with each genomic variant. VCF records are converted to peptide-level variants, and then ENSEMBL protein IDs, in accordance to the HGVS sequence variant nomenclature. The output is a hierarchically ordered text file (CSV or JSON) that reports the Ensemble protein ID and the gene associated with each variant, for each experimental sample. The user again has the option of limiting the search space to variants also found in the COSMIC database. This module also has an option to report the number of variant vs. wildtype reads found at each locus.

Dependencies

cerebra depends on some (fairly standard) packages and libraries. Before installing, it might be a good idea to make sure all of the requisite packages are installed on your system (note: if installing with Docker you can skip this step).

MacOS Dependencies:

sudo pip install setuptools
brew update
brew install openssl
brew install zlib

Linux Dependencies:

sudo apt-get install autoconf automake make gcc perl zlib1g-dev libbz2-dev liblzma-dev libcurl4-gnutls-dev libssl-dev

As of present cerebra is not installable on Windows. cerebra depends on the pysam library (or rather, pysam is a dependency-of-a-dependency) and currently this library is only available on Unix-like systems. Windows solutions like WSL exist for overcoming precisely this challenge, however, cerebra has not been tested on WSL or any other Unix-like subsystem for Windows.

Installation (for users)

There are four different methods available to install cerebra. Choose one of the following:

With Docker (recommended)

docker pull lincolnharris/cerebra
docker run -it lincolnharris/cerebra

warning: this image will take up ~1Gb of space.

With the python standard library venv module

python3 -m venv cerebra
source cerebra/bin/activate
pip3 install cerebra 

With conda

conda create -n cerebra python=3.7
conda activate cerebra
pip3 install cerebra

From PyPi (system-wide installation, NOT RECOMMENDED)
For novice users, it's generally a better idea to install packages within virtual environments. However, cerebra can be installed system-wide, if you so choose.

pip3 install cerebra

# OR, if you dont have root privileges
pip3 install --user cerebra

Installation (for developers)

Here's how to set up cerebra for local development. After installing the requisite dependencies:

  1. Fork the cerebra repo on GitHub: https://github.com/czbiohub/cerebra

  2. Clone your fork locally:

    $ git clone https://github.com/your-name/cerebra.git
    
  3. Install your local copy into a virtualenv. Using the standard library venv module:

    $ cd cerebra
    $ python3 -m venv cerebra-dev
    $ source cerebra-dev/bin/activate
    $ pip3 install -r requirements.txt -r test_requirements.txt -e .
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you're done making changes, check that your changes pass flake8 and pytest:

    $ make test
    $ make coverage
    $ make lint
    
  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website. See CONTRIBUTING.md for more.

(Quickstart) Usage

$ cerebra should return usage information

Usage: cerebra  <command>

  a tool for fast and accurate summarizing of variant calling format (VCF)
  files

Options:
  -h, --help  Show this message and exit.

Commands:
  germline-filter    filter out common SNPs/indels between tumor and normal samples
  count-variants    count total number of variants in each sample, and report on a per-gene basis
  find-peptide-variants  report peptide-level SNPs and indels in each sample, and associated coverage

Note that the -h command will display usage information for each of the three commands.

An example workflow might look like this:

Step 1:

cerebra germline-filter --processes 2 --normal_path /path/to/normal/vcfs --tumor_path /path/to/tumor/vcfs --metadata /path/to/metadata/file --outdir /path/to/filtered/vcfs

Step 2:

cerebra count-variants --processes 2 --cosmicdb /optional/path/to/cosmic/database --refgenome /path/to/genome/annotation --outfile /path/to/output/file /path/to/filtered/vcfs/*

Step 3:

cerebra find-peptide-variants --processes 2 --cosmicdb /optional/path/to/cosmic/database --annotation /path/to/genome/annotation --genomefa /path/to/genome/fasta --report_coverage 1 --output /path/to/output/file /path/to/filtered/vcfs/*

For advanced usage information, see USAGE.md.

Authors

This work was produced by Lincoln Harris, Rohan Vanheusden, Olga Botvinnik and Spyros Darmanis of the Chan Zuckerberg Biohub. For questions please contact ljharris018@gmail.com

Contributing

We welcome any bug reports, feature requests or other contributions. Please submit a well documented report on our issue tracker. For substantial changes please fork this repo and submit a pull request for review.

See CONTRIBUTING.md for additional details.

You can find official releases here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cerebra-1.2.0.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

cerebra-1.2.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file cerebra-1.2.0.tar.gz.

File metadata

  • Download URL: cerebra-1.2.0.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.8

File hashes

Hashes for cerebra-1.2.0.tar.gz
Algorithm Hash digest
SHA256 072796400a11df68d1b6fdeceadb62c79c772e37a598ec3ec1e43f9888ca0fed
MD5 01b56bdfca3cc5995f87263aa7f512ed
BLAKE2b-256 f43849412a2fd503d56a1e6da8798d24d0625529f5a8f82510475a60f440e573

See more details on using hashes here.

File details

Details for the file cerebra-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: cerebra-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.8

File hashes

Hashes for cerebra-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d1f9cd8f0a50f729e3a672d195db284d9294019d6168aed5f61ccefe51c1433
MD5 4bce18a530d5dbb8048ca46375926ede
BLAKE2b-256 2b67eb4aeffb0ae821abcc9d08acfc71f93de4a0f78770661aaeaf858f778d19

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page