Tool:trackplot: Fast and minimal dependency standalone R script to generate IGV style locus tracks from bigWig files
0
14
Entering edit mode
18 months ago
poisonAlien ★ 3.1k

If you are working with chip-seq or atac-seq or any assays resulting in bigWig files, one of the common visualizations is to generate track plots displaying signal intensities across genomic loci. Libraries in R like Gviz facilitates such visualization but they are slow, complicated, and come with a large number of dependencies, not to mention R versions themselves.

Introducing trackplot - a fast and minimal dependency standalone R script to generate IGV style locus tracks from bigWig files in R. trackplot has only two depdencies namely data.table R package, and bwtool CLI tool.

Features:

  • Its fast since most of the heavy lifting is done by bwtool
  • Plots are generated using pure base graphics (no ggplot2 or tidyverse dependencies)
  • Automatically queries UCSC genome browser for gene models.
  • Supports GTF and standard UCSC gene formats as well.
  • Customization: Each track can be customized for color, scale, height/width.
  • Region highlighting, gene track collapsing, etc

Usage:

trackplot is a standalone R script and requires no installation. Just source it and you're good to go!

Source code on Github. Comments and suggestions are always welcome :)

# download and source the script  
> download.file(url = "https://raw.githubusercontent.com/PoisonAlien/trackplot/master/trackplot.R", destfile = "trackplot.R") 
> source('trackplot.R') 

> trackplot(bigWigs = c("CD34.bw", "EC.bw", "LC.bw", "CD4p.bw", "CD8p.bw"),   
          loci = "chr3:187,715,903-187,752,003",   
          draw_gene_track = TRUE, build = "hg38", mark_regions = markregions,   
          custom_names = c("CD34", "EC", "LC", "CD4+", "CD8+") )

edit: Answering the comments, bwtool pre-built binaries are now included as part of the trackplot repository. Just make them executable and start using them.

ChIP-Seq bigwigs igv R visualization Tool • 4.7k views
ADD COMMENT
0
Entering edit mode

Try these instructions for bwtool compilation. It should work. Copied below as well.

git clone 'https://github.com/CRG-Barcelona/bwtool'
git clone 'https://github.com/CRG-Barcelona/libbeato'
git clone https://github.com/madler/zlib

cd libbeato/
git checkout 0c30432af9c7e1e09ba065ad3b2bc042baa54dc2
./configure
make
cd ..

cd zlib
./configure
make
cd ..

cd bwtool/
./configure CFLAGS='-I../libbeato -I../zlib' LDFLAGS='-L../libbeato/jkweb -L../libbeato/beato -L../zlib'
make

# copy/move the binary to PATH or to a directory under PATH
sudo cp bwtool /usr/local/bin
ADD REPLY
0
Entering edit mode

Hi I tried your script to make the plots but got an error

Parsing loci..
Queried region: chr1:202717141-202817514 [100373 bps]
Checking for files..
 Error in .check_bwtool() : 
Could not locate bwtool. Download it from here: https://github.com/CRG-Barcelona/bwtool/releases

The bwtool installed using the same lines above.

git clone 'https://github.com/CRG-Barcelona/bwtool'
git clone 'https://github.com/CRG-Barcelona/libbeato'
git clone https://github.com/madler/zlib

cd libbeato/
git checkout 0c30432af9c7e1e09ba065ad3b2bc042baa54dc2
./configure
make
cd ..

cd zlib
./configure
make
cd ..

cd bwtool/
./configure CFLAGS='-I../libbeato -I../zlib' LDFLAGS='-L../libbeato/jkweb -L../libbeato/beato -L../zlib'
make

R session

R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)

Running under: Ubuntu 18.04.5 LTS

Matrix products: default

BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1

LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C



attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.2    parallel_3.6.2    tools_3.6.2       tinytex_0.27      data.table_1.13.2 xfun_0.19
ADD REPLY
0
Entering edit mode

Did you add it to PATH or to a folder in PATH?

ADD REPLY
0
Entering edit mode

I just added it to PATH. Still I get the same error.

ADD REPLY
0
Entering edit mode

Problem solved using:

git clone https://github.com/CRG-Barcelona/libbeato.git
git clone https://github.com/CRG-Barcelona/bwtool.git
cd libbeato/
./configure
git checkout 0c30432af9c7e1e09ba065ad3b2bc042baa54dc2
make
sudo make install
cd ../bwtool/
./configure
make
sudo make install
ADD REPLY
0
Entering edit mode

You are almost there. You just need to copy/move the binary to a PATH (e.g; /usr/local/bin) or to a directory under PATH.

ADD REPLY
0
Entering edit mode

Getting this error on MacOS 10.14.6

gcc -DHAVE_CONFIG_H -I. -I..    -I.. -Wall -Wformat -Wimplicit -Wreturn-type -Wuninitialized -fno-strict-aliasing -g -O0 -I/Users/kopardevn/SandBox/bwtool/libbeato/include -MT metaBigBam.o -MD -MP -MF .deps/metaBigBam.Tpo -c -o metaBigBam.o metaBigBam.c
metaBigBam.c:485:12: warning: 'cigar_tab' is deprecated: Use bam_cigar_table[] instead
      [-Wdeprecated-declarations]
    if (h->cigar_tab == 0)
           ^
/usr/local/include/htslib/sam.h:77:29: note: 'cigar_tab' has been explicitly marked deprecated here
    const int8_t *cigar_tab HTS_DEPRECATED("Use bam_cigar_table[] instead");
                            ^
/usr/local/include/htslib/hts_defs.h:75:49: note: expanded from macro 'HTS_DEPRECATED'
#define HTS_DEPRECATED(message) __attribute__ ((__deprecated__ (message)))
                                                ^
metaBigBam.c:487:5: warning: 'cigar_tab' is deprecated: Use bam_cigar_table[] instead
      [-Wdeprecated-declarations]
        h->cigar_tab = (int8_t*)calloc(128, sizeof(int8_t));
           ^
/usr/local/include/htslib/sam.h:77:29: note: 'cigar_tab' has been explicitly marked deprecated here
    const int8_t *cigar_tab HTS_DEPRECATED("Use bam_cigar_table[] instead");
                            ^
/usr/local/include/htslib/hts_defs.h:75:49: note: expanded from macro 'HTS_DEPRECATED'
#define HTS_DEPRECATED(message) __attribute__ ((__deprecated__ (message)))
                                                ^
metaBigBam.c:489:9: warning: 'cigar_tab' is deprecated: Use bam_cigar_table[] instead
      [-Wdeprecated-declarations]
            h->cigar_tab[(int)BAM_CIGAR_STR[i]] = i;
               ^
/usr/local/include/htslib/sam.h:77:29: note: 'cigar_tab' has been explicitly marked deprecated here
    const int8_t *cigar_tab HTS_DEPRECATED("Use bam_cigar_table[] instead");
                            ^
/usr/local/include/htslib/hts_defs.h:75:49: note: expanded from macro 'HTS_DEPRECATED'
#define HTS_DEPRECATED(message) __attribute__ ((__deprecated__ (message)))
                                                ^
metaBigBam.c:489:42: error: read-only variable is not assignable
            h->cigar_tab[(int)BAM_CIGAR_STR[i]] = i;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
metaBigBam.c:502:35: warning: 'cigar_tab' is deprecated: Use bam_cigar_table[] instead
      [-Wdeprecated-declarations]
        op = (uint8_t)*q >= 128? -1 : h->cigar_tab[(int)*q];
                                         ^
/usr/local/include/htslib/sam.h:77:29: note: 'cigar_tab' has been explicitly marked deprecated here
    const int8_t *cigar_tab HTS_DEPRECATED("Use bam_cigar_table[] instead");
                            ^
/usr/local/include/htslib/hts_defs.h:75:49: note: expanded from macro 'HTS_DEPRECATED'
#define HTS_DEPRECATED(message) __attribute__ ((__deprecated__ (message)))
                                                ^
4 warnings and 1 error generated.
make[2]: *** [metaBigBam.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Any idea whats going on? Also seems like others are running into the same problem ( https://github.com/CRG-Barcelona/libbeato/issues/9 ). A solution will be appreciated.

ADD REPLY

Login before adding your answer.

Traffic: 863 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6