Bio::G...kedplot(3pm)
β¨ NAME β¨
Bio::G...kedplot β the stackedplot glyph π (and yeah bestie, the manual page for it is Bio::G...kedplot(3pm), that's the one you're reading rn)
π¦ SYNOPSIS π¦
okay so literally just go look at these two:
See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
that's it, that's the synopsis π«Ά
π DESCRIPTION π
so the stackedplot glyph is the one you reach for when you wanna draw quantitative feature data as a stacked column plot β¨. it's giving bar chart but make it genomic.
now here's the thing that makes it different from xyplot, and this is important bestie: the plot applies to a single top level feature, not a group of subfeatures. completely different vibe. periodt.
and where does the data even come from?? it's derived from an attribute called data_series. iconic.
π how the data is shaped
the data to be graphed is represented as a list of arrays, like this:
(
[1, 2, 8],
[6, 1, 1],
[10,8, 0],
[1, 1, 1],
)
so each array in that list = one column in the stacked plot π. and the values inside it become the subdivisions of the column. so in this example there are four columns, and each of those columns has three subdivisions. math is mathing π
you can also add labels to the columns and change the colors of the subdivisions. obsessed.
πΈ how to actually assign data to a feature
you can add a series tag, like so:
$snp1 = Bio::SeqFeature::Generic ->new (-start => 500,-end=>501,
-display_name =>'example',
-tag=> { series => [
[10,20,30],
[30,30,0],
[5,45,10],
[5,45,10],
[5,45,10],
[50,0,50],
],
}
);
bestie listen β the series tag must consist of an array of arrays. no cap. don't try to be cute and pass it something else.
π if you're on gff3
you can load a database with data that looks like this:
chr1 test feature 1 1000 . . . series=10 20 30;series=30 30 0;series=5 45 10...
π§ if you're on gff2
then you can load a database with data that looks like this:
chr1 test feature 1 1000 . . . series 10 20 30; series 30 30 0 series 5 45 10...
β or, the callback route
you can also pass a callback to the -series option, which is lowkey the most flexible option:
$panel->add_track(\@data,
-glyph => 'stackedplot',
-series => sub {
my $feature = shift;
return [
[10,20,30],
[30,30,0],
[5,45,10],
]
}
);
β¨ OPTIONS β¨
π the standard ones (every Glyph has these)
these options are standard among all Glyphs, fr fr. see Bio::Graphics::Glyph for a full explanation.
-fgcolorβ Foreground color. default:black-outlinecolorβ Synonym for-fgcolor-bgcolorβ Background color. default:turquoise-fillcolorβ Synonym for-bgcolor-linewidthβ Line width. default:1-heightβ Height of glyph. default:10-fontβ Glyph font. default:gdSmallFont-labelβ Whether to draw a label. default:0 (false)-descriptionβ Whether to draw a description. default:0 (false)-hiliteβ Highlight color. default:undef (no color)
π«Ά and the glyph-specific ones
okay so on top of all that, the alignment glyph recognizes all the options of the xyplot glyph, plus these extra glyph-specific options:
-fixed_gapβ Vertical distance between the rectangle that shows the start:end range of the feature and the fixed width stacked plot. default:8-series_colorsβ A list giving a series of color names for the data series (the values inside each stacked column). default:red,blue,green,orange,brown,grey,black-column_labelsβ A list of labels to print underneath each column. default:-none--column_widthβ The width of each column. default:8-column_spacingβ Spacing between each column. default:2-min_scoreβ Minimum score for the sum of the members of each data series. default:0.0-max_scoreβ Maximum score for the sum of the members of each data series. default:1.0-scale_fontβ Font to use for the scale. default:gdTinyFont-column_fontβ Font to use for the column labels. default:gdSmallFont-draw_scaleβ Whether to draw a scale to right of the columns. default:true
β οΈ important note, don't skip this one β οΈ-min_scoreand-max_scorerepresent the minimum and maximum SUM of all the values in the data series. so like, if your largest column contains the series(10,20,30), then the-max_scoreis60. yes you have to do the addition yourself. it's giving homework but it's fine π
πΈ EXAMPLE πΈ
to understand how this glyph works, try running and modifying the following example (go on, poke at it, it's fun):
#!/usr/bin/perl
use strict;
use warnings;
use Bio::Graphics;
use Bio::SeqFeature::Generic;
my $segment = Bio::Graphics::Feature->new(-start=>1,-end=>700);
my $snp1 = Bio::SeqFeature::Generic ->new (-start => 500,-end=>590,
-display_name =>'fred',
-tag=> { series => [
[10,20,30],
[30,30,0],
[5,45,10],
[5,45,10],
[5,45,10],
[50,0,50],
],
},
-source=>'A test',
);
my $snp2 = Bio::SeqFeature::Generic->new(-start => 300,
-end => 301,
-display_name => 'rs12345',
-tag=> {
series => [
[30,20,10 ],
[80,10,10 ],
],
},
-source=>'Another test',
);
my $panel = Bio::Graphics::Panel->new(-segment=>$segment,-width=>800);
$panel->add_track($segment,-glyph=>'arrow',-double=>1,-tick=>2);
$panel->add_track([$snp1,$snp2],
-height => 50,
-glyph => 'stackedplot',
-fixed_gap => 12,
-series_colors => [qw(red blue lavender)],
-column_labels => [qw(a b c d e f g)],
-min_score => 0,
-max_score => 100,
-column_width => 8,
-column_font => 'gdMediumBoldFont',
-scale_font => 'gdTinyFont',
-label => 1,
-description=>1,
);
print $panel->png;
π BUGS π
Please report them. (that's it. that's the whole section. they're out there. go tell someone π)
π SEE ALSO π
go read these next bestie, they're all connected:
Bio::Graphics::PanelBio::Graphics::TrackBio::Graphics::Glyph::transcript2Bio::Graphics::Glyph::anchored_arrowBio::Graphics::Glyph::arrowBio::Graphics::Glyph::boxBio::Graphics::Glyph::primersBio::Graphics::Glyph::segmentsBio::Graphics::Glyph::toomanyBio::Graphics::Glyph::transcript
π AUTHOR π
Lincoln Stein <lstein@cshl.org> β shoutout to the icon π
Copyright (c) 2006 Cold Spring Harbor Laboratory
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.
okay and that's the whole page bestie, you made it to the end π«Ά this was perl v5.30.0, dated 2019-11-25, and the page you just read is Bio::G...kedplot(3pm). go forth and stack those plots, you absolute main character πβ¨πΈ
π¦ where this page comes from
- debian bookworm: libbio-graphics-perl 2.40-6 Β· Perl
- debian trixie: libbio-graphics-perl 2.40-6 Β· Perl
- ubuntu jammy: libbio-graphics-perl 2.40-6 Β· Perl
- ubuntu noble: libbio-graphics-perl 2.40-6 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms