[Bio] / FigKernelScripts / svr_corr_by_exp.pl Repository:
ViewVC logotype

View of /FigKernelScripts/svr_corr_by_exp.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Tue Feb 8 20:06:35 2011 UTC (9 years, 5 months ago) by overbeek
Branch: MAIN
CVS Tags: mgrast_dev_02212011, mgrast_release_3_0, mgrast_dev_03252011, mgrast_release_3_0_2, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_dev_04012011, myrast_33, mgrast_dev_02222011
Changes since 1.2: +1 -1 lines
get format right for print

use strict;
use Data::Dumper;
use Carp;

#
# This is a SAS Component
#


=head1 svr_corr_by_exp [-m MinPCC]

Get genes that have similar expression profiles.

------

Example:

    svr_all_features 83333.1 peg | svr_corr_by_exp

would produce a 3-column table.  The first column would contain
PEG IDs for genes occurring in genome 3702.1, the second would give the
Pearson correlation coefficient, and the third would give the PEG that
seems to have a similar expression profile..

------

The standard input should be a tab-separated table (i.e., each line 
is a tab-separated set of fields).  Normally, the last field in each
line would contain the PEG for which functions are being requested.
If some other column contains the PEGs, use

    -c N

where N is the column (from 1) that contains the PEG in each case.

This is a pipe command. The input is taken from the standard input, and the
output is to the standard output.

=head2 Command-Line Options

=over 4

=item -c Column

This is used only if the column containing PEGs is not the last.

=item -m Minimum value for the Pearson correlation coefficient

=back

=head2 Output Format

The standard output is a tab-delimited file. It consists of lines from
the input file that are for PEGs that have Pearson correlation
coefficients that indicate potential correlation.  The lines will have
two appended columns: the Pearson correlation coefficient and the
functionally PEG that appears to have a correlated profile.

=cut

use SeedUtils;
use SAPserver;
my $sapObject = SAPserver->new();
use Getopt::Long;

my $usage = "usage: svr_corr_by_exp [-c column]";

my $column;
my $min_pcc = 0;
my $rc  = GetOptions('c=i' => \$column,
		     'm=f' => \$min_pcc);

if (! $rc) { print STDERR $usage; exit }

my @lines = map { chomp; [split(/\t/,$_)] } <STDIN>;
if (! $column)  { $column = @{$lines[0]} }
my @fids = map { $_->[$column-1] } @lines;

my $corrH = $sapObject->coregulated_fids(-ids => \@fids);
foreach $_ (@lines)
{
    my $peg = $_->[$column-1];
    if (my $x = $corrH->{$peg})
    {
	my @pegs2 = keys(%$x);
	foreach my $peg2 (@pegs2)
	{
	    my $pcc = sprintf("%0.3f",$x->{$peg2});
	    if ($pcc >= $min_pcc)
	    {
		print join("\t",(@$_,$pcc,$peg2)),"\n";
	    }
	}
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3