Skip to content

Commit

Permalink
Preparing release v0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
suvakov committed Aug 13, 2019
1 parent b2219e5 commit 3270a51
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 163 deletions.
184 changes: 67 additions & 117 deletions HisMaker.cpp

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion HisMaker.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
// C/C++ includes
#include <iostream>
#include <fstream>
#include <sstream>
#include <sstream>
#include <string>
#include <map>
#include <vector>

using namespace std;

// ROOT includes
Expand Down
138 changes: 138 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
Building, Installing and Running CNVnator
=========================================

Requirements
============

Building CNVnator requires at least the following:
GNU make
C compiler (e.g. gcc or clang)
CERN ROOT (https://root.cern.ch)
samtools with HTSlib

You must install ROOT package and set up $ROOTSYS variable (see ROOT documentation
https://root.cern.ch/root/html534/guides/users-guide/GettingStarted.html).

Download last samtools release https://github.com/samtools/samtools/releases and
compile samtools and HTSlib.

Building
========

Download last CNVnator release v0.4.1:
https://github.com/abyzovlab/CNVnator/releases/download/v0.4.1/CNVnator_v0.4.1.zip

Unzip and compile:

unzip CNVnator_v0.4.1.zip
cd CNVnator_v0.4.1
cd src
ln -s <path_to_samtools_dir> samtools
make -OMP=no # without parallel support

or

make # with parallel suport

Installing
==========

Add CNVnator_v0.4.1/src folder to $PATH by adding following line to .bash_profile:

export PATH=<path_to_CNVnator_v0.4.1>/src:$PATH

or create symbolic links in folder that is already in $PATH (e.g. ~/bin/):

cd <local_bin_folder>
ln -s <path_to_CNVnator_v0.4.1>/src/cnvnator
ln -s <path_to_CNVnator_v0.4.1>/src/plotcircular.py
ln -s <path_to_CNVnator_v0.4.1>/src/plotrdbaf.py
ln -s <path_to_CNVnator_v0.4.1>/src/plotbaf.py
ln -s <path_to_CNVnator_v0.4.1>/src/pytools

Running
=======

* Extract read mapping:

cnvnator -root file.root -tree file.bam

* Generate histogram:

cnvnator -root file.root -his 1000 -fasta reference_genome.fasta.gz -chrom $(seq 1 22) X Y
or
cnvnator -root file.root -his 1000 -fasta reference_genome.fasta.gz -chrom $(seq -f "chr%g" 1 22) chrX chrY

* Calculate statistics

cnvnator -root file.root -stat 1000

* Partition

cnvnator -root file.root -partition 1000

* Call CNVs

cnvnator -root file.root -call 1000

* Import SNP data

cnvnator -root file.root -vcf file.vcf.gz

* Import mask data

cnvnator -root file.root -mask mask.fa.gz

For hg19 reference genome mask file is provaded with CNVnator:

CNVnator_v0.4.1/ExampleData/20141020.strict_mask.whole_genome.fasta.gz

* Generate SNP histograms

cnvnator -root file.root -baf 10000

* List root file content

cnvnator -root file.root -ls

* Copy RD and SNP data to new root file

cnvnator -root file.root -cptrees new_file.root

* Genotype genomic regions - interactive mode

cnvnator -root file.root -genotype bin_size

* Ploting - interactive mode

cnvnator -root file.root -view 1000

* Ploting RD and BAF whole genome circular plots using python tool:

plotcircular.py file.root

all options:

plotcircular.py [-chrom CHROMOSOMES] [-bs BINSIZE] [-o SAVE_FILE]
[-t TITLE] [-rdbs RDBINSIZE] [-pbs PLOTBINSIZE]
[-nomask] [-useid] root_file

* Ploting RD and BAF signal over genomic region using python tool:

plotrdbaf.py file.root 15:1000000-5000000

all options:

plotrdbaf.py [-h] [-bs BINSIZE] [-rdbs RDBINSIZE] [-res RESOLUTION]
[-o SAVE_FILE] [-t TITLE] [-nomask] [-useid]
root_file region

* Ploting BAF signal over genomic region using python tool:

plotbaf.py file.root 15:1000000-5000000

all options:

plotbaf.py [-h] [-bs BINSIZE] [-rdbs RDBINSIZE] [-res RESOLUTION]
[-o SAVE_FILE] [-t TITLE] [-nomask] [-useid]
root_file region
15 changes: 8 additions & 7 deletions IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const vector<string> IO::Signal = vector<string>({
// Distribution use same signal name + " dist"


IO::IO(string _rootfile) : rootfile(_rootfile),file(rootfile,"Read") {
IO::IO(string _rootfile) : rootfile(_rootfile),file(rootfile,"Update") {
if (file.IsZombie()) {
cerr<<"Can't open file '"<<rootfile<<"'."<<endl;
return;
Expand Down Expand Up @@ -364,12 +364,13 @@ TH2* IO::newSignalTH2(string title,string chr, int bin, string signal, unsigned
}

bool IO::writeHistogramsToBinDir(int bin,TH1 *his1,TH1 *his2,TH1 *his3,TH1 *his4,TH1 *his5,TH1 *his6) {
TFile file(rootfile,"Update");
if(file.IsZombie()) {
cerr << "Can't open file '" << rootfile << "'." <<endl;
return false;
}
//TFile file(rootfile,"Update");
//if(file.IsZombie()) {
// cerr << "Can't open file '" << rootfile << "'." <<endl;
// return false;
//}
if(bin>0) {
file.cd();
TString dir_name=getDirName(bin);
TDirectory *dir = (TDirectory*)file.Get(dir_name);
if (!dir) {
Expand All @@ -389,7 +390,7 @@ bool IO::writeHistogramsToBinDir(int bin,TH1 *his1,TH1 *his2,TH1 *his3,TH1 *his4
if (his4) his4->Write(his4->GetName(),TObject::kOverwrite);
if (his5) his5->Write(his5->GetName(),TObject::kOverwrite);
if (his6) his6->Write(his6->GetName(),TObject::kOverwrite);
file.Close();
//file.Close();
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions IO.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class IO {
const static map<string,unsigned int> Flag;

TString rootfile;
TFile file;
vector<string> rd_tree;
vector<string> snp_tree;
vector<string> bin_dir;
Expand All @@ -39,7 +38,8 @@ class IO {
public:
IO(string _rootfile);
~IO();


TFile file;
// NAMES
TString treeName(string chr,string signal);
TString signalName(string chr, int bin, string signal, unsigned int flags);
Expand Down
35 changes: 18 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = v0.4
VERSION = v0.4.1
override LIBS += -lz -lbz2 -lcurl -llzma -lreadline -lcrypto

ifneq ($(wildcard $(ROOTSYS)/lib/root),)
Expand Down Expand Up @@ -38,19 +38,18 @@ ifneq ($(YEPPPINCLUDEDIR),)
endif

CXX = g++ -O3 -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -DCNVNATOR_VERSION=\"$(VERSION)\" $(OMPFLAGS)
#CXX = g++ -O3 -DCNVNATOR_VERSION=\"$(VERSION)\" $(OMPFLAGS)

OBJDIR = obj
OBJS = $(OBJDIR)/cnvnator.o \
$(OBJDIR)/EXOnator.o \
$(OBJDIR)/IO.o \
$(OBJDIR)/Visualizer.o \
$(OBJDIR)/HisMaker.o \
OBJS = $(OBJDIR)/cnvnator.o \
$(OBJDIR)/EXOnator.o \
$(OBJDIR)/IO.o \
$(OBJDIR)/Visualizer.o \
$(OBJDIR)/HisMaker.o \
$(OBJDIR)/AliParser.o \
$(OBJDIR)/FastaParser.o \
$(OBJDIR)/VcfParser.o \
$(OBJDIR)/Genotyper.o \
$(OBJDIR)/Interval.o \
$(OBJDIR)/Interval.o \
$(OBJDIR)/Genome.o

DISTRIBUTION = $(PWD)/CNVnator_$(VERSION).zip
Expand All @@ -74,17 +73,19 @@ clean:
distribution: clean all
@echo Creating directory ...
@rm -rf $(MAINDIR)
@rm -f $(DISTRIBUTION)
@mkdir $(MAINDIR)
@mkdir $(SRCDIR)
@rm -f $(DISTRIBUTION)
@mkdir $(MAINDIR)
@mkdir $(SRCDIR)
@echo Copying files ...
@cp *.hh *.cpp $(SRCDIR)
@cp Makefile $(SRCDIR)
@cp README.md $(MAINDIR)
@cp *.hh *.cpp $(SRCDIR)
@cp Makefile $(SRCDIR)
@cp README.md $(MAINDIR)
@cp ReleaseNotes.md $(MAINDIR)
@cp CITATION $(MAINDIR)
@cp license.rtf $(MAINDIR)
@cp cnvnator2VCF.pl plotbaf.py $(MAINDIR)
@cp INSTALL $(MAINDIR)
@cp CITATION $(MAINDIR)
@cp license.rtf $(MAINDIR)
@cp -r ExampleData $(MAINDIR)
@cp -r pytools cnvnator2VCF.pl plotbaf.py plotrdbaf.py plotcircular.py $(SRCDIR)
@echo Zipping ...
@ln -s $(MAINDIR)
@zip -qr $(DISTRIBUTION) $(CNVDIR)
Expand Down
16 changes: 0 additions & 16 deletions Visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ char** Visualizer::completer(const char* text, int start, int end) {
}

char* Visualizer::completion_generator(const char* text, int state) {
// std::vector<std::string> vocabulary{"set RD", "set RD raw", "set RD partition", "set RD call", "set SNP", "set SNP likelihood", "set SNP likelihood call", "set SNP count", "show"};
static std::vector<std::string> matches;
static size_t match_index = 0;
if (state == 0) {
Expand All @@ -190,7 +189,6 @@ char* Visualizer::completion_generator(const char* text, int state) {

void Visualizer::prompt() {
TTimer *timer = new TTimer("gSystem->ProcessEvents();",50,kFALSE);
// TString input = "";
string input="";
char* buf;
rl_attempted_completion_function = completer;
Expand All @@ -205,17 +203,12 @@ void Visualizer::prompt() {
input=string(buf);
if(buf!=nullptr) add_history(buf);
free(buf);
// input = Getline(">");
// getline(cin,input);
// input.ReplaceAll("\n","\0");
// input = input.Remove(TString::kBoth,' ');
timer->TurnOff();
}
delete timer;
}

void Visualizer::gview() {
// int n=io[0]->nChromWithTree();
int n=chroms.size();
TCanvas *canvas = new TCanvas("canv","canv",1000,800);
canvas->SetFillColor(kWhite);
Expand All @@ -234,7 +227,6 @@ void Visualizer::generateView(string chrom,int start,int end,TVirtualPad *canvas
int win = 1*(end - start + 1);
if (win < 10000) win = 10000;

// if (canvas) delete canvas;
TStyle *st = new TStyle("st","st");
st->SetOptStat(false); // No box with statistics
st->SetOptTitle(false); // No box with title
Expand Down Expand Up @@ -263,14 +255,6 @@ void Visualizer::generateView(string chrom,int start,int end,TVirtualPad *canvas
pad->SetFrameLineColor(kWhite);
pad->SetFrameBorderMode(0);
drawHistograms(chrom,start,end,win,"RD",pad,raw,his,hisc,hisp,hism);
// if (hisc) {
// double mean,sigma;
// TH1 *rd_his = getHistogram(getDistrName("chr1",bin_size,
// useATcorr,useGCcorr));
// getMeanSigma(rd_his,mean,sigma);
// hisc->GetYaxis()->SetRangeUser(0,2*mean);
// hisc->SetLineWidth(1);
// }
}

if(panel(2)) {
Expand Down
2 changes: 2 additions & 0 deletions Visualizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "IO.hh"
#include <map>
#include <vector>
#include <string>


class Visualizer
{
Expand Down
1 change: 1 addition & 0 deletions cnvnator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// C/C++ includes
#include <iostream>
#include <fstream>
#include <string>

#ifdef USE_YEPPP
#include <yepMath.h>
Expand Down
2 changes: 1 addition & 1 deletion plotrdbaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
parser.add_argument("-bs", "--binsize", type=int,
help="size of bins", default=100000)
parser.add_argument("-rdbs", "--rdbinsize", type=int,
help="size of bins for RD signal", default=10000)
help="size of bins for RD signal", default=100000)
parser.add_argument("-res", "--resolution", type=int,
help="size of bins", default=100)
parser.add_argument("-o", "--save_file",
Expand Down
7 changes: 5 additions & 2 deletions pytools/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ def get_signal(self, chr, bin_size, signal, flags=FLAG_USEMASK | FLAG_GC_CORR):
return [his.GetBinCenter(i) for i in range(n)], [his.GetBinContent(i) for i in range(n)]

def get_signal_2d(self, chr, bin_size, signal, flags=FLAG_USEMASK | FLAG_GC_CORR):
"""ToDo - Returns 2D histogram: (Xbin_centers, Values) """
return True
"""Returns 2D histogram: (Xbin_centers, Values) """
his = self.file.Get("bin_" + str(bin_size)).Get(self.signal_name(chr, bin_size, signal, flags))
nx=his.GetXaxis().GetNbins()
ny=his.GetYaxis().GetNbins()
return [his.GetXaxis().GetBinCenter(i) for i in range(nx)],[his.GetYaxis().GetBinCenter(i) for i in range(ny)],[[his.GetBinContent(i,j) for j in range(ny)] for i in range(nx)]


if __name__ == '__main__':
Expand Down

0 comments on commit 3270a51

Please sign in to comment.