Git Product home page Git Product logo

rock's Introduction

Travis build status

Rocking R at UMCCR

rock is an R package that (hopefully) helps with the day to day bioinformatics life at UMCCR (UniMelb Centre for Cancer Research).

You can do the following:

  • Create Perl circos plots using structural variant calls from Manta, and copy number variant calls from CNVkit or PURPLE.

  • Create CNV profiles in horizontal facets for multiple samples or callers (piano plots). Can also zoom into specific chromosomes, and include an ideogram when specifying a single chromosome.

  • Generate bedgraph files for viewing the copy number segments in IGV as a bar plot.

  • Generate IGV files for viewing SNP values in IGV as a scatter plot.

Contents

Installation

devtools

You can install the development version of rock from GitHub with:

# install.packages("devtools") # if not pre-installed
devtools::install_github("pdiakumis/rock") # master version
devtools::install_github("pdiakumis/[email protected]") # release v1.2.3
devtools::install_github("pdiakumis/rock@abcd") # commit abcd
require(rock)

conda

There is a conda package version at https://anaconda.org/pdiakumis/r-rock which is updated regularly.

You need to create a conda environment, and then install with:

conda install -c pdiakumis r-rock

Circos Plots

We can generate circos plots using the original circos software package, written in Perl.

circos needs to be installed in your PATH for it to work straight from within rock. I’ve had a terrible time trying to install circos either from source or from conda. The only way that I’ve found to consistently work is through Docker.

I have a docker image available on DockerHub, which you can pull (docker pull pdiakumis/circos:0.69-6) and then run as shown below.

Input preparation

Start by preparing the Manta and CNVkit calls. The required input files will be written to outdir:

manta <- system.file("extdata", "HCC2218_manta.vcf", package = "pebbles")
cnvkit <- system.file("extdata", "HCC2218_cnvkit-call.cns", package = "pebbles")
outdir <- "man/figures/perl_circos"
rock::circos_prep(outdir = outdir, manta = manta, cnv = cnvkit)
#> Warning in dir.create(outdir, recursive = TRUE): 'man/figures/perl_circos'
#> already exists
#> Exporting Manta and/or CNV circos files to 'man/figures/perl_circos'.
#> Registered S3 method overwritten by 'R.oo':
#>   method        from       
#>   throw.default R.methodsS3
#> Copying circos templates to 'man/figures/perl_circos'. 'template' is cnvsv.

Run Circos

Now comes the fun part of running the circos command. Depending on if you’ve managed to install a working version of circos or if you want to use the Docker version, you have the following options:

  • If you can find circos in your R session, just run the following R command. If you’re an RStudio user, you can make sure it recognises the user’s PATH by opening the RStudio app via the terminal, or perhaps following the suggestions here: https://stackoverflow.com/questions/31121645
plot_circos(outdir = outdir, name = "my_fabulous_plot")
  • If you just want to run it on your command line, adjust the following BASH command:
circos -nosvg -conf <outdir>/circos_simple.conf -outputdir <outdir> -outputfile my_fabulous_plot_circos.png
  • If you want to run the Docker version on your command line from the outdir:
docker container run --rm -v $(pwd):/data pdiakumis/circos:0.69-6 -conf /data/circos.conf -outputdir /data
  • Result:
knitr::include_graphics("man/figures/perl_circos/foo_circos_cnvkit_manta.png")

Piano Plots

  • We can generate ‘piano’ plots to compare CNV calls from multiple callers or samples.

  • Start by preparing the SV and CNV calls.

manta <- system.file("extdata", "HCC2218_manta.vcf", package = "pebbles")
cnvkit <- system.file("extdata", "HCC2218_cnvkit-call.cns", package = "pebbles")
facets <- system.file("extdata", "HCC2218_facets_cncf.tsv", package = "pebbles")
titan <- system.file("extdata", "HCC2218_titan.segs.tsv", package = "pebbles")
purple <- system.file("extdata", "HCC2218_purple.cnv.tsv", package = "pebbles")
truth <- system.file("extdata", "HCC2218_truthset_cnv_bcbio.tsv", package = "pebbles")
sv_manta <- prep_manta_vcf(manta)
cn_facets <- prep_facets_seg(facets)
cn_cnvkit <- prep_cnvkit_seg(cnvkit)
cn_purple <- prep_purple_seg(purple)
cn_truth <- prep_truth_seg(truth)
cn_titan <- prep_titan_seg(titan) # titan needs -1 for this case
cn_titan$cnv$tot_cn <- cn_titan$cnv$tot_cn - 1
cnv_list <- list(truth = cn_truth, cnvkit = cn_cnvkit, facets = cn_facets, purple = cn_purple, titan = cn_titan)
plot_piano(cnv_list = cnv_list)

  • You can also zoom into specific chromosomes:
plot_piano(cnv_list = cnv_list, chromosomes = c("1", "7", "8"), hide_x_lab = FALSE)

  • Change colours of the CNV segments:
plot_piano(cnv_list = cnv_list, chromosomes = c("1", "7", "8"),
           seg.col = c("orange", "lightblue", "blue", "pink"), hide_x_lab = FALSE)

  • And even plot an ideogram of the chromosome:
require(patchwork)
#> Loading required package: patchwork
plot_ideogram(chrom = "13") +
  plot_piano(cnv_list = cnv_list,
             chromosomes = "13", hide_x_lab = FALSE) +
  plot_layout(ncol = 1, heights = c(1, 15))

View CNV segments in IGV

cn_fname <- system.file("extdata", "HCC2218_purple.cnv.tsv", package = "pebbles")
cnv <- read_cnv(cn_fname)
cnv2igv(cnv, out_file = "~/Desktop/tmp/cnv_segs4igv.bedgraph", track_name = "cnv_segs2")
knitr::include_graphics("man/figures/README-cnv2igv_output.png")

View BED values in IGV

bed <- system.file("extdata", "HCC2218_baf.tsv", package = "pebbles")
bedval2igv(bed, out_file = "~/Desktop/tmp/baf1.igv", track_name = "baf", col = "purple")
# example for COLO829 whole-genome BAFs
knitr::include_graphics("man/figures/README-bedval2igv_output.png")

rock's People

Contributors

pdiakumis avatar

Stargazers

 avatar  avatar  avatar Clemens Messerschmidt avatar Clint Valentine avatar Sigve Nakken avatar Vlad Savelyev avatar Liuzaoqu avatar Adrian Forsythe avatar

Watchers

 avatar  avatar

rock's Issues

Handle more than 10K CNVkit calls

Currently the graphics device or OmicCircos can't handle more than 40K segments:

> sv <- prep_manta_vcf("COLO829_80pc-batch__COLO829_80pc_EMA-sv-prioritize-manta-filter.vcf")
> cnv <- prep_cnvkit_seg("COLO829_80pc-batch-cnvkit-call.cns")
> plot_circos(sv = sv, cnv = cnv)
Error: vector memory exhausted (limit reached?)

> cnv
$cnv
# A tibble: 82,321 x 4
   chrom   start     end tot_cn
   <chr>   <int>   <int>  <dbl>
 1 1      238901 1475299      2
 2 1     1475557 1511599      1
 3 1     1511599 1645636      2
 4 1     1645737 1655154      3
 5 1     1655255 1669985      2
 6 1     1670095 1686350      1
 7 1     1686350 1771996      2
 8 1     1771996 1798373      3
 9 1     1798373 1814923      2
10 1     1814923 1839386      1
# ... with 82,311 more rows

attr(,"class")
[1] "cnv"

For now let's just output the Manta calls and ignore CNVkit segments.

Run without cnv file

Is it possible to run circos_prep() and plot_circos2() without a cnv file, i.e. only with manta?

HTTP error 404 while trying to install

Hi,
I get HTTP error 404 while trying to install:

devtools::install_github("umccr/rock")
Downloading GitHub repo umccr/rock@master
Error: HTTP error 404.
Not Found

Rate limit remaining: 54/60
Rate limit reset at: 2019-04-01 09:50:59 UTC

Zoom into chromosome regions

Add support for zooming into chromosomal regions

  • Given a set of chr: start-end coordinates, zoom into region. Make sure region is valid.
  • Accept multiple geom_rects and geom_points, e.g. for BAF display. See example below.

screen shot 2018-08-13 at 16 08 06

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.