MassSpec::ViewSpectrum - Perl extension for viewing a mass spectrum.
use MassSpec::ViewSpectrum; open PNG, ">mygraphic.png" or die "Unable to open output file\n"; binmode PNG; my @masses = (1036.4,1133,1437,1480,1502); my @intensities = (0.1,0.15,0.05,0.10,0.2); my @annotations = ('b','w','internal w', '','internal y'); my $vs = MassSpec::ViewSpectrum->new(\@masses,\@intensities, \@annotations); $vs->set(yaxismultiplier => 1.8); # a sample tweak to adjust the output my $output = $vs->plot(); print PNG $output; close PNG;
MassSpec::ViewSpectrum - Perl extension for viewing a mass spectrum, e.g. typically obtained from the fragmentation of proteins or peptides.
At present this is only implemented using GD graphics, but in principle this could be subclassed in the future to include alternative graphic paradigms such as SVG and Tk.
The current implementation uses a mixture of GD::Graph and native GD, since GD::Graph 1.43 fails to draw the required vertical lines correctly.
Negative peak intensity values are permitted; this permits the drawing of "pseudospectra" which, for example, illustrate peaks present in one spectrum but missing in another.
The width and height of the canvas in pixels. Default: 500 x 500
Width of vertical spectra in pixels. Default: 2
Offset of annotations on y axis measured in pixels. This is used to permit some whitespace separation between annotations and peaks. Default: 4
Number of tick marks on X axis. Default: 5
Number of pixels for offset of annotations on x axis. Default: 6
A ratio, used to permit vertical room for peak annotations. Default: 2.0
For pseudospectra which contain some peaks with negative intensities, this is a fudge factor used to make room for annotations on those peaks underneath those peaks. This value has the same units as the original spectrum. Default: 0.1
One of 'png', 'jpg' or 'gif'. Your local GD installation might only support a subset of these. Default: 'png'
The label which appears on the X axis. Default: 'm/z'
The label which appears on the Y axis. Default: 'Intensity'
The title of the graph. Default: ''
Font size of peak labels; one of 'tiny','small','medium','large'. Default: 'medium'
Jonathan Epstein, <Jonathan_Epstein@nih.gov>
PUBLIC DOMAIN NOTICE National Institute of Child Health and Human Development This software/database is a "United States Government Work" under the terms of the United States Copyright Act. It was written as part of the author's official duties as a United States Government employee and thus cannot be copyrighted. This software/database is freely available to the public for use. The National Institutes of Health and the U.S. Government have not placed any restriction on its use or reproduction. Although all reasonable efforts have been taken to ensure the accuracy and reliability of the software and data, the NIH and the U.S. Government do not and cannot warrant the performance or results that may be obtained by using this software or data. The NIH and the U.S. Government disclaim all warranties, express or implied, including warranties of performance, merchantability or fitness for any particular purpose.
Please cite the author in any work or product based on this material.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
To install MassSpec::ViewSpectrum, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MassSpec::ViewSpectrum
CPAN shell
perl -MCPAN -e shell install MassSpec::ViewSpectrum
For more information on module installation, please visit the detailed CPAN module installation guide.