annotate runCrossSample.py @ 4:e80b0f62ffb3 draft default tip

"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
author azomics
date Wed, 29 Jul 2020 13:32:17 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
1 #!/usr/bin/env python
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
2 ######################################################################
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
3 # Copyright (c) 2016 Northrop Grumman.
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
4 # All rights reserved.
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
5 ######################################################################
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
6 import sys
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
7 import os
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
8 from scipy.stats import gmean
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
9 from argparse import ArgumentParser
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
10 from collections import defaultdict
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
11 import pandas as pd
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
12
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
13 #
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
14 # version 1.1 -- April 2016 -- C. Thomas
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
15 # modified to read in several input files and output to a directory
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
16 # + generates summary statistics
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
17 # also checks before running that input files are consistent with centroid file
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
18 #
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
19
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
20
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
21 def compare_MFIs(input_files, f_names, mfi_file):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
22 header_MFIs = ""
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
23 flag_error = False
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
24 with open(mfi_file, "r") as mfi_check:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
25 mfi_fl = mfi_check.readline().split("\t")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
26 header_MFIs = "\t".join([mfi_fl[h] for h in range(1, len(mfi_fl))])
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
27
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
28 for hh, files in enumerate(input_files):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
29 with open(files, "r") as inf:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
30 hdrs = inf.readline()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
31 if hdrs != header_MFIs:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
32 sys.stderr.write(hdrs + "headers in " + f_names[hh] + " are not consistent with FLOCK centroid file:\n" + header_MFIs + "\n")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
33 flag_error = True
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
34 if flag_error:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
35 sys.exit(2)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
36
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
37
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
38 def stats_MFIs(cs_df, ctr, mfi_calc):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
39 if mfi_calc == "mfi":
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
40 MFIs = cs_df.groupby('Population').mean().round(decimals=2)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
41 elif mfi_calc == "gmfi":
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
42 MFIs = cs_df.groupby('Population').agg(lambda x: gmean(list(x))).round(decimals=2)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
43 else:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
44 MFIs = cs_df.groupby('Population').median().round(decimals=2)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
45 pop_freq = (cs_df.Population.value_counts(normalize=True) * 100).round(decimals=2)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
46 sorted_pop_freq = pop_freq.sort_index()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
47 MFIs['Percentage'] = sorted_pop_freq
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
48 MFIs['Population'] = MFIs.index
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
49 MFIs['SampleName'] = "".join(["Sample", str(ctr).zfill(2)])
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
50 return MFIs
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
51
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
52
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
53 def get_pop_prop(input_files, summary_stat, mfi_stats, marker_names, mfi_calc):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
54 pop_count = defaultdict(dict)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
55 mrk = marker_names.strip().split("\t")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
56 markers = "\t".join([mrk[m] for m in range(1, len(mrk))])
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
57
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
58 ctr_mfi = 0
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
59 nb_pop = 0
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
60 tot = {}
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
61 with open(mfi_stats, "a") as mfis:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
62 mfis.write("\t".join([markers, "Percentage", "Population", "SampleName"]) + "\n")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
63 for files in input_files:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
64 cs = pd.read_table(files)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
65 tot[files] = len(cs.index)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
66 for pops in cs.Population:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
67 if pops in pop_count[files]:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
68 pop_count[files][pops] += 1
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
69 else:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
70 pop_count[files][pops] = 1
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
71 max_nb_pop = max(set(cs.Population))
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
72 if (max_nb_pop > nb_pop):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
73 nb_pop = max_nb_pop
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
74 ctr_mfi += 1
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
75 cs_stats = stats_MFIs(cs, ctr_mfi, mfi_calc)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
76 cs_stats.to_csv(mfis, sep="\t", header=False, index=False)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
77
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
78 ctr = 0
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
79 with open(summary_stat, "w") as outf:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
80 itpop = [str(x) for x in range(1, nb_pop + 1)]
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
81 cols = "\t".join(itpop)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
82 outf.write("FileID\tSampleName\t" + cols + "\n")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
83 for eachfile in pop_count:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
84 tmp = []
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
85 for num in range(1, nb_pop + 1):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
86 if num not in pop_count[eachfile]:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
87 pop_count[eachfile][num] = 0
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
88 tmp.append(str((pop_count[eachfile][num] / float(tot[eachfile])) * 100))
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
89 props = "\t".join(tmp)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
90 ctr += 1
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
91 sample_name = "".join(["Sample", str(ctr).zfill(2)])
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
92 outf.write("\t".join([input_files[eachfile], sample_name, props]) + "\n")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
93
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
94
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
95 def run_cross_sample(input_files, f_names, mfi_file, output_dir, summary_stat,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
96 mfi_stats, mfi_calc):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
97 markers = ""
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
98 # Strip off Header Line
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
99 with open(mfi_file, "r") as mfi_in, open("mfi.txt", "w") as mfi_out:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
100 markers = mfi_in.readline().strip("\n")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
101 for line in mfi_in:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
102 mfi_out.write(line)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
103
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
104 # Create output directory
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
105 if not os.path.exists(output_dir):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
106 os.makedirs(output_dir)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
107
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
108 outputs = {}
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
109 # Run cent_adjust
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
110 for nm, flow_file in enumerate(input_files):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
111 run_command = "cent_adjust mfi.txt " + flow_file
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
112 print(run_command)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
113 os.system(run_command)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
114 flow_name = os.path.split(flow_file)[1]
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
115 outfile = os.path.join(output_dir, f_names[nm] + ".flowclr")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
116 outputs[outfile] = f_names[nm]
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
117 with open(flow_file, "r") as flowf, open("population_id.txt", "r") as popf, open(outfile, "w") as outf:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
118 f_line = flowf.readline()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
119 f_line = f_line.rstrip()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
120 f_line = f_line + "\tPopulation\n"
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
121 outf.write(f_line)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
122
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
123 for line in flowf:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
124 line = line.rstrip()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
125 pop_line = popf.readline()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
126 pop_line = pop_line.rstrip()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
127 line = line + "\t" + pop_line + "\n"
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
128 outf.write(line)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
129 get_pop_prop(outputs, summary_stat, mfi_stats, markers, mfi_calc)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
130 return
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
131
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
132
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
133 def generate_CS_stats(mfi_stats, all_stats):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
134 df = pd.read_table(mfi_stats)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
135 means = df.groupby('Population').mean().round(decimals=2)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
136 medians = df.groupby('Population').median().round(decimals=2)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
137 stdev = df.groupby('Population').std().round(decimals=2)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
138 all_markers = []
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
139 with open(mfi_stats, "r") as ms:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
140 ms_fl = ms.readline().strip()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
141 all_markers = ms_fl.split("\t")[0:-2]
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
142
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
143 with open(all_stats, "w") as mstats:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
144 hdgs = ["\t".join(["_".join([mrs, "mean"]), "_".join([mrs, "median"]), "_".join([mrs, "stdev"])]) for mrs in all_markers]
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
145 mstats.write("Population\t")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
146 mstats.write("\t".join(hdgs) + "\n")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
147 for pops in set(df.Population):
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
148 tmp_line = []
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
149 for mar in all_markers:
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
150 tmp_line.append("\t".join([str(means.loc[pops, mar]), str(medians.loc[pops, mar]), str(stdev.loc[pops, mar])]))
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
151 mstats.write(str(pops) + "\t")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
152 mstats.write("\t".join(tmp_line) + "\n")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
153
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
154
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
155 if __name__ == "__main__":
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
156 parser = ArgumentParser(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
157 prog="runCrossSample",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
158 description="Run CrossSample on Flow file")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
159
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
160 parser.add_argument(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
161 '-i',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
162 dest="input_files",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
163 required=True,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
164 action='append',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
165 help="File locations for flow text files.")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
166
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
167 parser.add_argument(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
168 '-n',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
169 dest="filenames",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
170 required=True,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
171 action='append',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
172 help="Filenames")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
173
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
174 parser.add_argument(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
175 '-m',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
176 dest="mfi",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
177 required=True,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
178 help="File location for the MFI text file.")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
179
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
180 parser.add_argument(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
181 '-o',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
182 dest="out_path",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
183 required=True,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
184 help="Path to the directory for the output files.")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
185
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
186 parser.add_argument(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
187 '-M',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
188 dest="mfi_calc",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
189 required=True,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
190 help="what to calculate for centroids.")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
191
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
192 parser.add_argument(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
193 '-s',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
194 dest="sstat",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
195 required=True,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
196 help="File location for the summary statistics.")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
197
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
198 parser.add_argument(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
199 '-S',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
200 dest="mfi_stat",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
201 required=True,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
202 help="File location for the MFI summary statistics.")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
203
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
204 parser.add_argument(
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
205 '-a',
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
206 dest="all_stats",
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
207 required=True,
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
208 help="File location for stats on all markers.")
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
209
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
210 args = parser.parse_args()
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
211
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
212 input_files = [f for f in args.input_files]
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
213 input_names = [n for n in args.filenames]
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
214 compare_MFIs(input_files, input_names, args.mfi)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
215 run_cross_sample(input_files, input_names, args.mfi, args.out_path, args.sstat, args.mfi_stat, args.mfi_calc)
e80b0f62ffb3 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cross_sample commit e7eab2dca0c1f73f580362f61425a78d4c8892ce"
azomics
parents:
diff changeset
216 generate_CS_stats(args.mfi_stat, args.all_stats)