comparison trinityrnaseq_protocol/analyze_diff_exp_wrapper.py @ 30:fac55e1121ee draft default tip

Uploaded
author gkumar09
date Wed, 02 Dec 2015 00:04:10 -0500
parents 7bfd42505a2e
children
comparison
equal deleted inserted replaced
29:f7c062297fb9 30:fac55e1121ee
1 import sys, os, subprocess
2
3 TRINITY_BASE_DIR = ""
4 if os.environ.has_key('TRINITY_HOME'):
5 TRINITY_BASE_DIR = os.environ['TRINITY_HOME'];
6 else:
7 sys.stderr.write("You must set the environmental variable TRINITY_BASE_DIR to the base installation directory of Trinity before running this");
8 sys.exit()
9
10 usage= "usage: " + sys.argv[0] + " " + "edgeR.tar.gz " + "TMM_normalized_FPKM_matrix " + "P-value " + "C-value"
11 print sys.argv
12 print usage
13 print " "
14
15 if len(sys.argv)<5:
16 print "Require atleast two parameters"
17 else:
18 print "All good- command going ahead"
19 print " "
20
21 Normalized_Matrix=sys.argv[2]
22 Pvalue=sys.argv[3]
23 Cvalue=sys.argv[4]
24
25 def run_command(cmd):
26 print "The command used: " + cmd
27 pipe= subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
28 pipe.wait()
29 ret= pipe.returncode
30 if ret:
31 print "command died: " + str(ret)
32 print pipe.stderr.readlines()
33 sys.exit(1)
34 else:
35 return
36 print " "
37
38 Final_tar_gz= "edgeR.tar.gz"
39 run_command("cp "+ sys.argv[1] + " " + "Final_tar_gz")
40 run_command("tar -xvf " + "Final_tar_gz")
41 run_command("mv " + "edgeR_results" + "/* ." )
42
43 # run the analyze command
44 cmd= TRINITY_BASE_DIR + "/Analysis/DifferentialExpression/analyze_diff_expr.pl "+ "--matrix " + Normalized_Matrix + " -P " + Pvalue + " -C " + Cvalue
45 run_command(cmd)
46
47 origMatrixName= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix"
48 # diffExpr.P0.001_C2.0.matrix
49 run_command("mv " + origMatrixName + " diffExpr.matrix")
50
51 SampleCorName= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.sample_cor.dat"
52 # diffExpr.P0.001_C2.0.matrix.log2.sample_cor.dat
53 run_command("mv " + SampleCorName + " diffExpr.matrix.log2.sample_cor.dat")
54
55 CorMatrix= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.sample_cor_matrix.pdf"
56 # diffExpr.P0.001_C2.0.matrix.log2.sample_cor_matrix.pdf
57 run_command("mv " + CorMatrix + " diffExpr.matrix.log2.sample_cor_matrix.pdf")
58
59 Heatmap= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.centered.genes_vs_samples_heatmap.pdf"
60 #diffExpr.P0.001_C2.0.matrix.log2.centered.genes_vs_samples_heatmap.pdf
61 run_command("mv " + Heatmap + " diffExpr.matrix.log2.centered.genes_vs_samples_heatmap.pdf")
62
63 sys.exit(0)