monkfan has asked for the wisdom of the Perl Monks concerning the following question:

This figure is created with the following script:
#!/usr/bin/perl -w use strict; use Data::Dumper; use Bio::Graphics; use Bio::SeqFeature::Generic; use List::Compare; use List::Util qw(max); my %nofseq = ( 0 => 300, 1 => 300, 2 => 300, 3 => 300, 4 => 300, 5 => +300 ); my @seqid = keys %nofseq; my @lenlist = values %nofseq; #Sequence length my $maxlen = max (@lenlist); #print Dumper \@seqid ; my $panel = Bio::Graphics::Panel->new( -length => 300, -width => 500, -pad_left => 70, -pad_right => 70, -key_style => 'left', -connector => 'solid', ); my $flen = Bio::SeqFeature::Generic->new( -start => 1, -end => 300, ); my $track1 = $panel->add_track( $flen, -glyph => 'arrow', -tick => 2, -fgcolor => 'black', -double => 1, ); my %nlist; while ( <DATA> ) { chomp; next if /^\#/; my ($sqi,$pos,$str,$progname) = split /\,/; my $start = $pos + $nofseq{$sqi}; my $end = $start + length($str) + 1; push @{$nlist{$sqi}}, $start." ".$end." ".$progname; } # Check which sequence has no motifs; my @bssi = keys %nlist; my $lc = List::Compare->new(\@seqid, \@bssi); my @comp = $lc->get_unique; foreach my $comp ( @comp ) { push @{$nlist{$comp}}, '0'." ".'0'." "."NONE"; } my %prog_color = ( "WEEDER" => 3000, "MEME" => 200, "NONE" => 0 ); foreach my $seqid ( sort keys %nlist ) { my $track = $panel->add_track( -glyph => 'graded_segments', -key => "SEQ ". $seqid, -connector => "solid" -label => 1, -bgcolor => 'blue', -bump => +1, -height => 8, -min_score => 0, -max_score => 5000 ); foreach my $range ( @{$nlist{$seqid}} ) { my ($st,$en,$progname) = split(" ", $range); my $dname = " "; if ( $st != 0 and $en !=0 ) { $dname = "Seq ". $seqid; } my $score; if ( $progname eq "WEEDER" ) { $score = $prog_color{$progname}; } elsif ($progname eq "MEME" ) { $score = $prog_color{$progname}; } my $feature = Bio::SeqFeature::Generic->new( -display_name => $dname, -start => $st, -end => $en, -score => $score ); $track->add_feature($feature); } } print $panel->png; __DATA__ # sequence number,pos,binding sites,program 4,-63,AGCTTTCTCT,MEME 0,-22,AACTTTGTAC,WEEDER 1,-13,AAGTTTCTCT,WEEDER 5,-228,ACCTTTGCCA,MEME 5,-121,AAGTTTGTCT,WEEDER 5,-88,AAGTTTTTCC,SPACE 3,-148,AACTTAGTCA,MEME 0,-184,AACTTTGTCT,MEME
The DATA is simply just list of string and its location in their respective sequence. The figure is just the plot of it out.

As you can see from the figure, there are some misgivings of my script above. I was thinking to mimic this figure.
Does anybody has experience in dealing with such issues with Bio::Graphics? Any idea how to achieve that?

Regards,
Edward

Replies are listed 'Best First'.
Re: Bio::Graphics - Howto Enable Neg Start-End, Connector, Create Legend
by lbragg (Initiate) on Sep 09, 2008 at 00:55 UTC
    I know this reply is too late to help you, but for anyone wanting to do a negative scale, I think the following example should work. However, the coordinate system will continue to be positive, so you'll just have to convert your positions to positive values (ie. abs(minimum value on scale - feature pos) + 1). For example, the -63 relative to the TSS will be need to be converted to:
    abs(-300 - - 63) + 1 = 238
    The following code creates the feature and the panel:
    my $full_length = Bio::SeqFeature::Generic->new( -start => 1, -end => 300 ); my $panel = Bio::Graphics::Panel->new( -length => $length, -width => 1000, -pad_left => 10, -pad_right => 10, );
    This next statement adds the arrow track to the panel, the relative coords needs to be set to true and the relative coords offset is set to the minimum value you want represented on arrow track (in this example it is -300).
    $panel->add_track($full_length, -glyph => 'arrow', -tick => 2, -fgcolor => 'black', -double => 1, -relative_coords => 1, -relative_coords_offset => -300 );
    Hope that helps someone,
    Lauren