Skip to content

Commit

Permalink
Merge branch 'release/v4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranmraine committed Dec 9, 2016
2 parents 1b98c8d + 3f83e02 commit c1933d5
Show file tree
Hide file tree
Showing 12 changed files with 276 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ perl:
- "5.22"

script:
- git clone --depth 1 --single-branch --branch develop https://github.com/cancerit/cgpBigWig.git
- cd cgpBigWig
- ./setup.sh $HOME/PCAP-opt
- cd ../
- git clone --depth 1 --single-branch --branch dev https://github.com/ICGC-TCGA-PanCancer/PCAP-core.git
- cd PCAP-core
- ./setup.sh $HOME/PCAP-opt
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ AscatNGS
AscatNGS contains the Cancer Genome Projects workflow implementation of the ASCAT copy number
algorithm for paired end sequencing.

##For WHOLEGENOME (WGS) sequencing only
We do not offer support for WXS analysis, please contact the authors of [ASCAT](https://www.crick.ac.uk/peter-van-loo/software/ASCAT).

---

For details of the underlying algorithm please see the [ASCAT](https://www.crick.ac.uk/peter-van-loo/software/ASCAT) site. The GitHub repoitory can be found [here](https://github.com/Crick-CancerGenomics/ascat).

| Master | Dev |
Expand Down
2 changes: 2 additions & 0 deletions perl/MANIFEST
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bin/ascat.pl
bin/ascatCnToVCF.pl
bin/ascatFailedCnCsv.pl
bin/ascatToBigWig.pl
bin/utilities/ascatFaiChunk.pl
bin/utilities/ascatSnpPanelFromVcfs.pl
bin/utilities/ascatSnpPanelGcCorrections.pl
Expand All @@ -21,6 +22,7 @@ docs/pod_html/_whtpurk.css
docs/pod_html/ascat.html
docs/pod_html/ascatCnToVCF.html
docs/pod_html/ascatFailedCnCsv.html
docs/pod_html/ascatToBigWig.html
docs/pod_html/index.html
docs/pod_html/Sanger/CGP/Ascat.html
docs/pod_html/utilities/ascatSnpPanelGenerator.html
Expand Down
1 change: 1 addition & 0 deletions perl/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WriteMakefile(
EXE_FILES => [qw( bin/ascat.pl
bin/ascatCnToVCF.pl
bin/ascatFailedCnCsv.pl
bin/ascatToBigWig.pl
bin/utilities/ascatFaiChunk.pl
bin/utilities/ascatSnpPanelFromVcfs.pl
bin/utilities/ascatSnpPanelGcCorrections.pl
Expand Down
7 changes: 5 additions & 2 deletions perl/bin/ascat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ sub setup {
my %opts;
pod2usage(-msg => "\nERROR: Option must be defined.\n", -verbose => 1, -output => \*STDERR) if(scalar @ARGV == 0);
$opts{'cmd'} = join " ", $0, @ARGV;
warn "Executing: $opts{cmd}\n";
GetOptions( 'h|help' => \$opts{'h'},
'm|man' => \$opts{'m'},
'v|version' => \$opts{'v'},
Expand All @@ -111,6 +110,7 @@ sub setup {
'pi|ploidy=s' => \$opts{'ploidy'},
'f|force' => \$opts{'force'},
'nc|noclean' => \$opts{'noclean'},
'nb|nobigwig' => \$opts{'nobigwig'},
) or pod2usage(2);

pod2usage(-verbose => 1, -exitval => 0) if(defined $opts{'h'});
Expand All @@ -121,6 +121,8 @@ sub setup {
exit;
}

warn "Executing: $opts{cmd}\n";

if(!defined($opts{'noclean'})){
$opts{'noclean'} = 0;
}
Expand Down Expand Up @@ -238,7 +240,7 @@ =head1 SYNOPSIS
ascat.pl [options]
Please defined as many of the parameters as possible
Please define as many of the parameters as possible
Required parameters
Expand Down Expand Up @@ -277,6 +279,7 @@ =head1 SYNOPSIS
-ploidy -pi Ploidy (psi) setting for manual setting of sunrise plot location
-noclean -nc Finalise results but don't clean up the tmp directory.
- Useful when including a manual check and restarting ascat with new pu and pi params.
-nobigwig -nb Don't generate BigWig files.
Other
-help -h Brief help message
Expand Down
4 changes: 2 additions & 2 deletions perl/bin/ascatCnToVCF.pl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ =head1 NAME
=head1 SYNOPSIS
CN_to_VCF.pl [options]
ascatCnToVCF.pl [options]
Required parameters:
-sample-bam-mut -sbm Mutant sample bam file.
Expand Down Expand Up @@ -324,6 +324,6 @@ =head1 PARAMETERS
=head1 DESCRIPTION
B<CN_to_VCF.pl> will attempt convert the input segmented file into VCF copy number format.
B<ascatCnToVCF.pl> will attempt convert the input segmented file into VCF copy number format.
=cut
4 changes: 2 additions & 2 deletions perl/bin/ascatFailedCnCsv.pl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ =head1 NAME
=head1 SYNOPSIS
failed_cn_csv.pl [options]
ascatFailedCnCsv.pl [options]
Required parameters:
-reference -r Path to reference fasta (with corresponding fai)
Expand Down Expand Up @@ -142,6 +142,6 @@ =head1 PARAMETERS
=head1 DESCRIPTION
B<failed_cn_csv.pl> generates CopyNumber csv for a failed ASCAT run suitable for caveman, 5/2 (tumour/normal).
B<ascatFailedCnCsv.pl> generates CopyNumber csv for a failed ASCAT run suitable for caveman, 5/2 (tumour/normal).
=cut
221 changes: 221 additions & 0 deletions perl/bin/ascatToBigWig.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
#!/usr/bin/perl

##########LICENCE##########
# Copyright (c) 2014-2016 Genome Research Ltd.
#
# Author: CancerIT <[email protected]>
#
# This file is part of AscatNGS.
#
# AscatNGS is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##########LICENCE##########

use strict;
use warnings FATAL => 'all';
use autodie qw(:all);
use FindBin qw($Bin);
use lib "$Bin/../lib";
use Getopt::Long;
use Pod::Usage qw(pod2usage);
use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
use Const::Fast qw(const);

use PCAP::Cli;
use Sanger::CGP::Ascat;

# chr, 0-start, 1-stop, value (use string to leave precision as source)
const my $BG_FRMT => "%s\t%d\t%d\t%s\n";
const my $DFLT_ALIAS => '23:X,24:Y';

my $options = setup();
my $chr_map = chr_lookup($options->{'alias'});

my $z = new IO::Uncompress::Gunzip $options->{'input'}, MultiStream=>1 or die "gunzip failed: $GunzipError\n";

my $bg_fhs = get_output_files($options->{'outpre'});

my $chr_last = q{};
my ($start_segbaf, $end_segbaf, $val_segbaf) = (0,0,'NA');
my ($start_seglogr, $end_seglogr, $val_seglogr) = (0,0,'NA');
my ($start_total_cn, $end_total_cn, $val_total_cn) = (0,0,'NA');
my ($start_minor_cn, $end_minor_cn, $val_minor_cn) = (0,0,'NA');

while(my $line = <$z>) {
next if($line =~ /^\t/);
chomp $line;
my (undef, $chr, $pos, $logR, $segLogR, $baf, $segBaf, $total_cn, $minor_cn, $raw_cn) = split /\t/, $line;
$chr = $chr_map->{$chr} if(exists $chr_map->{$chr});

if($chr ne $chr_last) {
if($chr_last ne q{}) {
printf {$bg_fhs->{'segLogR'}} $BG_FRMT, $chr_last, $start_seglogr-1, $end_seglogr, $val_seglogr if($val_seglogr ne 'NA');
printf {$bg_fhs->{'segBaf'}} $BG_FRMT, $chr_last, $start_segbaf-1, $end_segbaf, $val_segbaf if($val_segbaf ne 'NA');
printf {$bg_fhs->{'totalCn'}} $BG_FRMT, $chr_last, $start_total_cn-1, $end_total_cn, $val_total_cn if($val_total_cn ne 'NA');
printf {$bg_fhs->{'minorCn'}} $BG_FRMT, $chr_last, $start_minor_cn-1, $end_minor_cn, $val_minor_cn if($val_minor_cn ne 'NA');
}
$chr_last = $chr;
($start_segbaf, $end_segbaf, $val_segbaf) = (0,0,'NA');
($start_seglogr, $end_seglogr, $val_seglogr) = (0,0,'NA');
($start_total_cn, $end_total_cn, $val_total_cn) = (0,0,'NA');
($start_minor_cn, $end_minor_cn, $val_minor_cn) = (0,0,'NA');
}

printf {$bg_fhs->{'logR'}} $BG_FRMT, $chr, $pos-1, $pos, $logR if($logR ne 'NA');
printf {$bg_fhs->{'baf'}} $BG_FRMT, $chr, $pos-1, $pos, $baf if($baf ne 'NA');
printf {$bg_fhs->{'rawCn'}} $BG_FRMT, $chr, $pos-1, $pos, $raw_cn if($raw_cn ne 'NA');

if($segLogR ne $val_seglogr) {
printf {$bg_fhs->{'segLogR'}} $BG_FRMT, $chr_last, $start_seglogr-1, $end_seglogr, $val_seglogr if($val_seglogr ne 'NA');
($start_seglogr, $end_seglogr, $val_seglogr) = ($pos, $pos, $segLogR);
}
else {
$end_seglogr = $pos;
}

if($segBaf ne $val_segbaf) {
printf {$bg_fhs->{'segBaf'}} $BG_FRMT, $chr_last, $start_segbaf-1, $end_segbaf, $val_segbaf if($val_segbaf ne 'NA');
($start_segbaf, $end_segbaf, $val_segbaf) = ($pos, $pos, $segBaf);
}
else {
$end_segbaf = $pos;
}

if($total_cn ne $val_total_cn) {
printf {$bg_fhs->{'totalCn'}} $BG_FRMT, $chr_last, $start_total_cn-1, $end_total_cn, $val_total_cn if($val_total_cn ne 'NA');
($start_total_cn, $end_total_cn, $val_total_cn) = ($pos, $pos, $total_cn);
}
else {
$end_total_cn = $pos;
}

if($minor_cn ne $val_minor_cn) {
printf {$bg_fhs->{'minorCn'}} $BG_FRMT, $chr_last, $start_minor_cn-1, $end_minor_cn, $val_minor_cn if($val_minor_cn ne 'NA');
($start_minor_cn, $end_minor_cn, $val_minor_cn) = ($pos, $pos, $minor_cn);
}
else {
$end_minor_cn = $pos;
}
}
close $z;

printf {$bg_fhs->{'segLogR'}} $BG_FRMT, $chr_last, $start_seglogr-1, $end_seglogr, $val_seglogr if($val_seglogr ne 'NA');
printf {$bg_fhs->{'segBaf'}} $BG_FRMT, $chr_last, $start_segbaf-1, $end_segbaf, $val_segbaf if($val_segbaf ne 'NA');
printf {$bg_fhs->{'totalCn'}} $BG_FRMT, $chr_last, $start_total_cn-1, $end_total_cn, $val_total_cn if($val_total_cn ne 'NA');
printf {$bg_fhs->{'minorCn'}} $BG_FRMT, $chr_last, $start_minor_cn-1, $end_minor_cn, $val_minor_cn if($val_minor_cn ne 'NA');

close_output_files($options->{'outpre'}, $bg_fhs);
convert_bg_to_bw($options->{'outpre'}, $options->{'fai'});

sub chr_lookup {
my $alias_lst = shift;
my %chr_map = split /[:,]/, $alias_lst;
return \%chr_map;
}

sub convert_bg_to_bw {
my ($outpre, $chromlst) = @_;
for (qw(logR segLogR baf segBaf totalCn minorCn rawCn)) {
my $bg_file = sprintf '%s.%s.bg', $outpre, $_;
my $bw_file = sprintf '%s.%s.bw', $outpre, $_;
my $cmd = sprintf 'bg2bw -i %s -o %s -c %s', $bg_file, $bw_file, $chromlst;
warn "Executing: $cmd\n";
system($cmd) && die "Execution failed: $!";
unlink $bg_file;
}
}

sub get_output_files {
my $outpre = shift;
my %fhs;
for (qw(logR segLogR baf segBaf totalCn minorCn rawCn)) {
my $bg_file = sprintf '%s.%s.bg', $outpre, $_;
open my $fh, '>', $bg_file or die "Failed to create $bg_file";
$fhs{$_} = $fh;
}
return \%fhs;
}

sub close_output_files {
my ($outpre, $fhs) = @_;
for (keys %{$fhs}) {
my $bg_file = sprintf '%s.%s.bg', $outpre, $_;
close $fhs->{$_} or die "Failed to close $bg_file";
}
}

sub setup {
my %opts;
pod2usage(-msg => "\nERROR: Options must be defined.\n", -verbose => 1, -output => \*STDERR) if(scalar @ARGV == 0);
$opts{'cmd'} = join " ", $0, @ARGV;
warn "Executing: $opts{cmd}\n";
GetOptions( 'h|help' => \$opts{'h'},
'm|man' => \$opts{'m'},
'v|version' => \$opts{'v'},
'i|input=s' => \$opts{'input'},
'o|outpre=s' => \$opts{'outpre'},
'f|fai=s' => \$opts{'fai'},
'a|alias:s' => \$opts{'alias'},
) or pod2usage(2);

pod2usage(-verbose => 1, -exitval => 0) if(defined $opts{'h'});
pod2usage(-verbose => 2, -exitval => 0) if(defined $opts{'m'});

if($opts{'v'}){
print Sanger::CGP::Ascat->VERSION."\n";
exit;
}

# then check for no args:
my $defined;
for(keys %opts) { $defined++ if(defined $opts{$_}); }
pod2usage(-msg => "\nERROR: Parameters must be defined.\n", -verbose => 1, -output => \*STDERR) unless($defined);


PCAP::Cli::file_for_reading('input', $opts{'input'});
PCAP::Cli::file_for_reading('fai', $opts{'fai'});
pod2usage(-msg => "\nERROR: '-o' must be defined.\n", -verbose => 1, -output => \*STDERR) unless(defined $opts{'outpre'});

$opts{'alias'} = $DFLT_ALIAS unless(defined $opts{'alias'});

return \%opts;
}

__END__
=head1 ascatToBigWig.pl
Converts raw data used in log and BAF plots to BigWig data files
suitable for use with JBrowse/MuiltBigWig.
=head1 SYNOPSIS
ascatToBigWig.pl [options]
Required parameters
-input -i Input *.ascat_ngs.cn.tsv[.gz]
-outpre -o File name to use in output, suffixes applied are:
- *.logR.bw
- *.segLogR.bw
- *.baf.bw
- *.segBaf.bw
-fai -f Path to chrom list or fai file
- a tsv file with first 2 columns chr, chr-length
-alias -a csv for numeric to chr mapping applied to chr column of input [23:X,24:Y]
Other
-help -h Brief help message
-man -m Full documentation.
-version -v Ascat version number
Binary file modified perl/docs.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion perl/lib/Sanger/CGP/Ascat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use strict;
use Const::Fast qw(const);
use base 'Exporter';

our $VERSION = '3.1.0';
our $VERSION = '4.0.0';
our @EXPORT = qw($VERSION);

const my $LICENSE =>
Expand Down
Loading

0 comments on commit c1933d5

Please sign in to comment.