forked from Ensembl/VEP_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Carol.pm
177 lines (123 loc) · 4.7 KB
/
Carol.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2023] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=head1 CONTACT
Ensembl <http://www.ensembl.org/info/about/contact/index.html>
=cut
=head1 NAME
Carol
=head1 SYNOPSIS
mv Carol.pm ~/.vep/Plugins
./vep -i variations.vcf --plugin Carol
=head1 DESCRIPTION
A VEP plugin that calculates the Combined Annotation scoRing toOL (CAROL)
score (1) for a missense mutation based on the pre-calculated SIFT (2) and
PolyPhen-2 (3) scores from the Ensembl API (4).
It adds one new entry class to the VEP's Extra column, CAROL which is
the calculated CAROL score. Note that this module is a perl reimplementation of
the original R script, available at: https://sanger.ac.uk/tool/carol/
I believe that both versions implement the same algorithm, but if there are any
discrepancies the R version should be treated as the reference implementation.
Bug reports are welcome.
References:
(1) Lopes MC, Joyce C, Ritchie GRS, John SL, Cunningham F, Asimit J, Zeggini E.
A combined functional annotation score for non-synonymous variants
Human Heredity 73(1):47-51 (2012)
doi:10.1159/000334984
(2) Kumar P, Henikoff S, Ng PC.
Predicting the effects of coding non-synonymous variants on protein function using the SIFT algorithm
Nature Protocols 4(8):1073-1081 (2009)
doi:10.1038/nprot.2009.86
(3) Adzhubei IA, Schmidt S, Peshkin L, Ramensky VE, Gerasimova A, Bork P, Kondrashov AS, Sunyaev SR.
A method and server for predicting damaging missense mutations
Nature Methods 7(4):248-249 (2010)
doi:10.1038/nmeth0410-248
(4) Flicek P, et al.
Ensembl 2012
Nucleic Acids Research 40(D1):D84-D90 (2011)
doi: 10.1093/nar/gkr991
=cut
package Carol;
use strict;
use warnings;
use Math::CDF qw(pnorm qnorm);
use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepPlugin);
my $CAROL_CUTOFF = 0.98;
sub version {
return '2.3';
}
sub feature_types {
return ['Transcript'];
}
sub get_header_info {
return {
CAROL => "Combined Annotation scoRing toOL prediction",
};
}
sub run {
my ($self, $tva) = @_;
my $pph_pred = $tva->polyphen_prediction;
my $pph_score = $pph_pred ? ($pph_pred eq 'unknown' ? undef: $tva->polyphen_score) : undef;
my $sift_score = $tva->sift_score;
my ($carol_pred, $carol_score) = compute_carol($pph_score, $sift_score);
my $results = {};
if (defined $carol_pred) {
$carol_score = sprintf "%.3f", $carol_score;
my $result = "$carol_pred($carol_score)";
if (@{ $self->params } > 0) {
$result = $carol_pred if ($self->params->[0] =~ /^p/i);
$result = $carol_score if ($self->params->[0] =~ /^s/i);
}
$results = {
CAROL => $result,
};
}
return $results;
}
sub compute_carol {
my ($pph_score, $sift_score) = @_;
my $carol_score;
if (defined $pph_score) {
$pph_score = 0.999 if $pph_score == 1;
$pph_score = 0.0001 if $pph_score == 0;
}
if (defined $sift_score) {
$sift_score = 1 - $sift_score;
$sift_score = 0.999 if $sift_score == 1;
$sift_score = 0.0001 if $sift_score == 0;
}
if (defined $pph_score && defined $sift_score) {
my $pph_weight = log(1/(1-$pph_score));
my $sift_weight = log(1/(1-$sift_score));
# we take -qnorm, because the R script uses qnorm(..., lower.tail = FALSE)
my $pph_z = -qnorm($pph_score);
my $sift_z = -qnorm($sift_score);
my $numerator = ($pph_weight * $pph_z) + ($sift_weight * $sift_z);
my $denominator = sqrt( ($pph_weight ** 2) + ($sift_weight ** 2) );
# likewise we take 1 - pnorm
$carol_score = 1 - pnorm($numerator / $denominator);
}
elsif (defined $pph_score) {
$carol_score = $pph_score;
}
else {
$carol_score = $sift_score;
}
if (defined $carol_score) {
my $carol_pred = $carol_score < $CAROL_CUTOFF ? 'Neutral' : 'Deleterious';
return ($carol_pred, $carol_score);
}
else {
return undef;
}
}
1;