Skip to content

Commit 02b7246

Browse files
committed
Make plot-vcfstats work with -s, --sample-names
Also, make <STDIN> input label printable Resolves #2353
1 parent a35ad84 commit 02b7246

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ Changes affecting specific commands:
4646

4747
- Print the number of removed duplicate sites in the final statistics (#2346)
4848

49+
* plot-vcfstats
50+
51+
- Make the option `-s, --sample-names` functional again (#2353)
52+
4953
* bcftools query
5054

5155
- The functions used in -i/-e filtering expressions (such as SUM, MEDIAN, etc) can be

misc/plot-vcfstats

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# The MIT License
66
#
7-
# Copyright (C) 2012-2020 Genome Research Ltd.
7+
# Copyright (C) 2012-2025 Genome Research Ltd.
88
#
99
# Author: Petr Danecek <pd3@sanger.ac.uk>
1010
#
@@ -658,6 +658,10 @@ sub parse_vcfstats1
658658
}
659659
if ( $line=~/^#/ ) { next; }
660660
my @items = split(/\t/,$line);
661+
if ( $items[0] eq 'ID' && $items[2] eq '<STDIN>' )
662+
{
663+
$items[2] = 'STDIN';
664+
}
661665
if ( $items[0] eq 'SN' )
662666
{
663667
$dat{$items[1]}{$items[2]} = splice(@items,3);
@@ -1927,7 +1931,7 @@ sub plot_vaf25_by_sample
19271931
tprint $fh, "
19281932
dat = [
19291933
";
1930-
for (my $i=0; $i<@vaf; $i++) { tprint $fh, "\t[$i,$vaf[$i]],\n"; }
1934+
for (my $i=0; $i<@vaf; $i++) { tprint $fh, "\t[$i,$vaf[$i],'$vals[$i][0]'],\n"; }
19311935
tprint $fh, "]\n";
19321936
tprint $fh, "
19331937
@@ -1938,7 +1942,7 @@ sub plot_vaf25_by_sample
19381942
ax1.set_ylabel('nVAF<0.25')
19391943
ax1.set_ylim(-0.1,1.1)
19401944
if sample_names:
1941-
plt.xticks([int(row[0]) for row in dat],[row[7] for row in dat],**sample_font)
1945+
plt.xticks([int(row[0]) for row in dat],[row[2] for row in dat],**sample_font)
19421946
plt.subplots_adjust(**sample_margins)
19431947
else:
19441948
plt.subplots_adjust(right=0.98,left=0.07,bottom=0.17)

0 commit comments

Comments
 (0)