Hi,
I have this network file based on gene expression data that indicates interactions between genes such that the first column is the source and the second column is the target, the third column is the edge attribute for the interaction between first and second column, the fourth column is again the target of the first column and fifth column is the edge attribute for this interaction and so on...I'm trying to use this file to generate a network in cytoscape but all sources have to be in 1st column and targets have to be in 2nd column and any edge attributes thereafter. How can I convert this file into 3 columns with 1st column being source, 2nd target and 3rd the edge attribute. Can it be done in R?
A4GALT ABI1 0.290467 ABL1 0.291354 ACTC1 0.290467 AKR1B10 0.322647 AMN1 0.290467
AAGAB AHCYL1 0.286272 ALG10 0.275442 ANKRD15 0.303029 CA12 0.303029 CDC42SE2 0.286272
AARSD1 AARSD1 0.274792 ABCC4 0.27289 ACADL 0.349349 ACBD5 0.329398 ACSL4 0.335957
AARSD1 AARSD1 0.274792 ACADL 0.274792 ACBD5 0.26986 ACSL4 0.291354 ACTR3B 0.26986
Edit: The output file should look like this for example the first line should become:
A4GALT ABI1 0.290467
A4GALT ABL1 0.291354
A4GALT ACTC1 0.290467
A4GALT AKR1B10 0.322647
A4GALT AMN1 0.290467
and similarly all lines should be converted to such format in a single text file.
code edit:
#!/usr/bin/env perl
open(INFILE, "<aracne_network_microarray.txt") or die ("couldn't open the file\n");
use v5.10;
use strict;
use warnings;
my @a =();
my @b =();
open(MYOUTFILE, ">aracne_network_output.txt");
while (<INFILE>) {
chomp;
s/^\t|^\s+|//;
my ($source, $tar, $att, @f) = split;
@a = join ("\t", $source, $tar, $att);
while (my ($targ, $attr) = splice(@f, 0, 2)) {
@b = join ("\t", $source, $targ, $attr);
print MYOUTFILE "@b" }
}
close(MYOUTFILE)
Thanks alot!!!
I can write script for you if you could give me the example of desired output.
Ive edited the post. Thanks a lot Noolean!