Mercurial > repos > jay > pdaug_peptide_sequence_analysis
annotate PDAUG_Fishers_Plot/PDAUG_Fishers_Plot.py @ 5:d11a54691a2f draft
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit ac4353ca5c0ac9ce60df9f4bf160ed08b99fbee3"
author | jay |
---|---|
date | Thu, 28 Jan 2021 02:41:47 +0000 |
parents | e59674e3a391 |
children |
rev | line source |
---|---|
0
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
1 import matplotlib |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
2 matplotlib.use('Agg') |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
3 import os |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
4 import sys |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
5 sys.path.insert(0, os.path.abspath('..')) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
6 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
7 import quantiprot |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
8 from quantiprot.utils.io import load_fasta_file |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
9 from quantiprot.utils.feature import Feature, FeatureSet |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
10 from quantiprot.metrics.aaindex import get_aa2volume, get_aa2hydropathy |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
11 from quantiprot.metrics.basic import average |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
12 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
13 from matplotlib import pyplot as plt |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
14 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
15 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
16 from math import log10, floor |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
17 import numpy as np |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
18 from matplotlib import pyplot as plt |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
19 from scipy.stats import fisher_exact |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
20 from quantiprot.utils.sequence import SequenceSet, compact |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
21 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
22 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
23 def _count_frame(data, frame_range, num_bins): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
24 """ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
25 Count instances in a 2D frame |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
26 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
27 The function discretizes the feature space into a grid of cells. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
28 Then it counts the number of instances that fall into each cell. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
29 An efficient method for counting instances is used. It performs parallel |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
30 logical comparisons of data instances to vectors that hold information on |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
31 grid lines. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
32 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
33 Args: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
34 data (numpy.matrix): a Nx2 data matrix |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
35 frame_range (numpy.matrix): a 2x2 matrix which defines feature ranges |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
36 num_bins (list): a pair defining the resolution of the 2D grid |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
37 Returns: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
38 cell_counts (numpy.matrix): a matrix holding counts of instances in |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
39 each grid cell |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
40 bin_ranges (tuple): a pair of numpy matrices holding information on |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
41 bin(grid_cell) ranges |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
42 """ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
43 grid_x = np.linspace(start=frame_range[0, 0], stop=frame_range[1, 0],\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
44 num=num_bins[0]+1, endpoint=True) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
45 grid_y = np.linspace(start=frame_range[0, 1], stop=frame_range[1, 1],\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
46 num=num_bins[1]+1, endpoint=True) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
47 # copy because we add ones in the next lines |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
48 bin_ranges = (np.copy(grid_x), np.copy(grid_y)) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
49 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
50 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
51 #Count points in each grid cell |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
52 grid_x[-1] += 1 # the last cell has to contain data at the border |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
53 grid_y[-1] += 1 # the last cell has to contain data at the border |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
54 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
55 gte_x = np.matrix(data[:, 0] >= grid_x, dtype='float64') |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
56 lt_x = np.matrix(data[:, 0] < grid_x, dtype='float64') |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
57 gte_y = np.matrix(data[:, 1] >= grid_y, dtype='float64') |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
58 lt_y = np.matrix(data[:, 1] < grid_y, dtype='float64') |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
59 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
60 dif_x = gte_x - lt_x |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
61 dif_y = gte_y - lt_y |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
62 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
63 bins_x = dif_x.argmin(axis=1) - 1 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
64 bins_y = dif_y.argmin(axis=1) - 1 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
65 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
66 coords = np.concatenate((bins_x, bins_y), axis=1) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
67 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
68 cell_counts = np.zeros(shape=(len(grid_x)-1, len(grid_y)-1)) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
69 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
70 for i in range(coords.shape[0]): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
71 cell_counts[coords[i, 0], coords[i, 1]] += 1 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
72 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
73 return cell_counts, bin_ranges |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
74 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
75 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
76 def local_fisher_2d(set1, set2, features=None, \ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
77 windows_per_frame=10, overlap_factor=1, frame_range=None): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
78 """ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
79 Compare local and global distribution of samples from two populations |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
80 in the 2d feature space using the Fisher's exact test. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
81 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
82 The function performs the Fisher Exact Test for comparing local and global |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
83 ratia of instance counts from two different populations. It uses the |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
84 '_count_frame' function to discretize the feature space and get instance |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
85 counts. Then it scans the 2d feature space with a sliding window and |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
86 performs the Fisher Exact test. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
87 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
88 Args: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
89 set1 (SequenceSet or numpy.matrix): the first set with at least |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
90 2 sequence features. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
91 set2 (SequenceSet or numpy.matrix): the second set with at least |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
92 2 sequence features. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
93 features (tuple or list): strings with feature names for running |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
94 the 2d Fisher test. If None then the first two features are |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
95 used. Relevant only if 'set1' or 'set2' are SequenceSets. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
96 windows_per_frame (int): ratio between the whole feature space and |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
97 the sliding window (default 10). |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
98 overlap_factor (int):ratio between the size of a sliding window |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
99 and a discretization grid cell (default 1). |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
100 frame_range(numpy.matrix): 2x2 matrix with range of features |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
101 in both dimensions. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
102 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
103 Returns final_res (dict): a dictionary including: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
104 'odds_ratio' (numpy.matrix): a matrix of odds_ratios obtained |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
105 in each sliding window position. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
106 'p_value' (numpy.matrix): a matrix containing Fisher test outcome |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
107 pvalues in each sliding window position. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
108 'w_counts1' (numpy.matrix): a matrix with first population instance |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
109 counts in each sliding window position. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
110 'w_counts2' (numpy.matrix): a matrix with second population instance |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
111 counts in each sliding window position. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
112 'w_center_x' (numpy.matrix): matrix containing coordinates of window |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
113 centers in the X dimension. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
114 'w_center_y' (numpy.matrix): matrix containing coordinates of window |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
115 centers in the Y dimension. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
116 '_bin_ranges_x' (numpy.matrix): matrix containing bin(grid_cell) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
117 ranges in the X dimension. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
118 '_bin_ranges_y' (numpy.matrix): matrix containing bin(grid_cell) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
119 ranges in the Y dimension. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
120 """ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
121 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
122 if isinstance(set1, SequenceSet): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
123 mat1 = np.transpose(np.matrix(compact(set1, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
124 features=features).columns())) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
125 if isinstance(set2, SequenceSet): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
126 mat2 = np.transpose(np.matrix(compact(set2, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
127 features=features).columns())) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
128 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
129 #Deal with window_per_frame and overlap_factor |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
130 #given either as a scalar or as a list-like |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
131 if not hasattr(windows_per_frame, "__len__"): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
132 w_per_frame = (windows_per_frame, windows_per_frame) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
133 else: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
134 w_per_frame = (windows_per_frame[0], windows_per_frame[1]) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
135 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
136 if not hasattr(overlap_factor, "__len__"): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
137 w_size = (overlap_factor, overlap_factor) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
138 else: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
139 w_size = (overlap_factor[0], overlap_factor[1]) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
140 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
141 num_bins = (w_per_frame[0]*w_size[0], w_per_frame[1]*w_size[1]) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
142 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
143 if frame_range is None: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
144 #Evaluate the range of features in both populations. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
145 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
146 frame_range = np.concatenate((np.minimum(mat1.min(0), mat2.min(0)),\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
147 np.maximum(mat1.max(0), mat2.max(0)))) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
148 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
149 margin_x = (frame_range[1, 0] - frame_range[0, 0])/w_per_frame[0] |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
150 margin_y = (frame_range[1, 1] - frame_range[0, 1])/w_per_frame[1] |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
151 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
152 frame_range[0, 0] -= margin_x |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
153 frame_range[1, 0] += margin_x |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
154 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
155 frame_range[0, 1] -= margin_y |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
156 frame_range[1, 1] += margin_y |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
157 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
158 #Discretize feature space into NxM grid, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
159 #where N = w_per_frame[0]*w_size[0]. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
160 # M = w_per_frame[1]*w_size[1]. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
161 #count instances of population1 and population2 in each grid cell. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
162 #both bin ranges are always the same because the frame range is common. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
163 cell_counts1, bin_ranges = _count_frame(mat1, frame_range=frame_range,\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
164 num_bins=num_bins) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
165 cell_counts2, _ = _count_frame(mat2, frame_range=frame_range,\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
166 num_bins=num_bins) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
167 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
168 #Number of windows that fit in a single row/column of a frame |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
169 w_number = (cell_counts1.shape[0]-w_size[0]+1, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
170 cell_counts1.shape[1]-w_size[1]+1) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
171 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
172 #Initialize matrices holding counts at scanning window positions. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
173 window_counts1 = np.zeros(shape=w_number) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
174 window_counts2 = np.zeros(shape=w_number) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
175 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
176 #Initialize matrices holding window coordinates |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
177 window_center_x = np.zeros(shape=w_number[0]) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
178 window_center_y = np.zeros(shape=w_number[1]) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
179 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
180 #Initialize matrices holding Fisher Exact test results |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
181 fisher_pv = np.ones(shape=w_number) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
182 odds_ratio = np.ones(shape=w_number) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
183 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
184 #Calculate population totals in the whole feature space |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
185 all1 = cell_counts1.sum() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
186 all2 = cell_counts2.sum() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
187 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
188 #Calculate window centers |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
189 for start_x in range(0, w_number[0]): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
190 window_center_x[start_x] = (bin_ranges[0][start_x]+ \ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
191 bin_ranges[0][start_x+w_size[0]])/2 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
192 for start_y in range(0, w_number[1]): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
193 window_center_y[start_y] = (bin_ranges[1][start_y]+ \ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
194 bin_ranges[1][start_y+w_size[1]])/2 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
195 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
196 #Scan the feature space with a step of 1 cell. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
197 for start_x in range(0, w_number[0]): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
198 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
199 for start_y in range(0, w_number[1]): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
200 #Count instances of each population in the window |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
201 window_counts1[start_x, start_y] = \ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
202 cell_counts1[start_x:(start_x+w_size[0]), \ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
203 start_y:(start_y+w_size[1])].sum() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
204 window_counts2[start_x, start_y] = \ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
205 cell_counts2[start_x:(start_x+w_size[0]), \ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
206 start_y:(start_y+w_size[1])].sum() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
207 #Perform the Fisher Exact Test against |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
208 #h0: population ratio in the window the same as in the whole space. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
209 odds_ratio[start_x, start_y], fisher_pv[start_x, start_y] =\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
210 fisher_exact([[all1, window_counts1[start_x, start_y]],\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
211 [all2, window_counts2[start_x, start_y]]]) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
212 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
213 fisher_res = {'p_value':fisher_pv, 'odds_ratio':odds_ratio,\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
214 'w_counts1':window_counts1, 'w_counts2':window_counts2,\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
215 'w_center_x':window_center_x, 'w_center_y':window_center_y,\ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
216 '_bin_ranges_x':bin_ranges[0], '_bin_ranges_y':bin_ranges[1]} |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
217 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
218 return fisher_res |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
219 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
220 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
221 def _plot_local_fisher_2d(fisher_res, xlabel="feat_1", ylabel="feat_2", |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
222 pop1_label="pop_1", pop2_label="pop_2", out_file_path=None, fig_width=8, fig_hight=8, fig_hspace=0.35, fig_wspace=0.25): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
223 """ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
224 Plot results of the local Fisher's extact test in the 2d space. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
225 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
226 Args: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
227 fisher_res (dict): output from 'fisher_local_2d'. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
228 xlabel (str): name of the 1st feature to appear in the plots |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
229 (default: "feat_1") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
230 ylabel (str): name of the 2nd feature to appear in the plots |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
231 (default: "feat_2") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
232 pop1_label (str): name of the 1st population to appear in the plots |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
233 (default: "pop_1") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
234 pop2_label (str): name of the 2nd population to appear in the plots |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
235 (default: "pop_2") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
236 """ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
237 fisher_or = fisher_res["odds_ratio"] |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
238 fisher_c1 = fisher_res["w_counts1"] |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
239 fisher_c2 = fisher_res["w_counts2"] |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
240 fisher_pv = fisher_res["p_value"] |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
241 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
242 for pos_x in range(len(fisher_or)): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
243 for pos_y in range(len(fisher_or[0])): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
244 if fisher_c1[pos_x][pos_y] == 0 and fisher_c2[pos_x][pos_y] == 0: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
245 fisher_or[pos_x][pos_y] = np.nan |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
246 elif fisher_c1[pos_x][pos_y] == 0: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
247 fisher_or[pos_x][pos_y] = np.inf |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
248 elif fisher_c2[pos_x][pos_y] == 0: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
249 fisher_or[pos_x][pos_y] = -np.inf |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
250 elif fisher_or[pos_x][pos_y] < 1: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
251 fisher_or[pos_x][pos_y] = -1.0/fisher_or[pos_x][pos_y] |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
252 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
253 vmax_abs = np.nanmax(np.abs([x for x in np.array(fisher_or).flatten() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
254 if x > -np.inf and x < np.inf])) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
255 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
256 for pos_x in range(len(fisher_or)): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
257 for pos_y in range(len(fisher_or[0])): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
258 if abs(fisher_or[pos_x][pos_y]) == np.inf: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
259 fisher_or[pos_x][pos_y] = np.sign(fisher_or[pos_x][pos_y])*vmax_abs |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
260 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
261 ##### Extra Fig perimeters added ################################ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
262 plt.figure(figsize=(fig_width, fig_hight)) # Figure size |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
263 plt.subplots_adjust(hspace = fig_hspace, wspace = fig_wspace) # space between the subplots. |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
264 ################################################################## |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
265 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
266 plt.subplot(221) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
267 plt.pcolormesh(fisher_res["w_center_x"], fisher_res["w_center_y"], |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
268 np.ma.masked_invalid(fisher_c1).T, cmap="Reds") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
269 plt.colorbar() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
270 plt.xlabel(xlabel) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
271 plt.ylabel(ylabel) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
272 plt.title("Counts "+pop1_label) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
273 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
274 plt.subplot(222) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
275 plt.pcolormesh(fisher_res["w_center_x"], fisher_res["w_center_y"], |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
276 np.ma.masked_invalid(fisher_c2).T, cmap="Reds") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
277 plt.colorbar() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
278 plt.xlabel(xlabel) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
279 plt.ylabel(ylabel) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
280 plt.title("Counts "+pop2_label) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
281 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
282 cmap = plt.get_cmap('RdBu') |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
283 cmap.set_bad(color='k', alpha=1.) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
284 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
285 cbar_lo = 1.0/vmax_abs |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
286 cbar_lo_places = max(0, -floor(log10(cbar_lo))+1) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
287 cbar_hi = vmax_abs |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
288 cbar_hi_places = max(0, -floor(log10(cbar_hi))+1) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
289 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
290 plt.subplot(223) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
291 plt.pcolormesh(fisher_res["w_center_x"], fisher_res["w_center_y"], |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
292 np.ma.masked_invalid(fisher_or).T, cmap=cmap, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
293 vmin=-vmax_abs, vmax=vmax_abs) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
294 cbar = plt.colorbar(ticks=([-vmax_abs, 0, vmax_abs])) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
295 cbar.ax.set_yticklabels(['< '+str(round(cbar_lo, int(cbar_lo_places))), '1', |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
296 '> '+str(round(cbar_hi, int(cbar_hi_places)))]) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
297 plt.xlabel(xlabel) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
298 plt.ylabel(ylabel) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
299 plt.title("Odds ratio") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
300 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
301 plt.subplot(224) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
302 plt.pcolormesh(fisher_res["w_center_x"], fisher_res["w_center_y"], |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
303 np.log10(np.ma.masked_invalid(fisher_pv)).T, cmap="RdGy") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
304 plt.colorbar() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
305 plt.xlabel(xlabel) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
306 plt.ylabel(ylabel) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
307 plt.title("Fisher test\np-value (logarithm of 10)") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
308 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
309 #Savefig function added with preserving default behavior |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
310 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
311 if out_file_path==None: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
312 plt.show() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
313 else: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
314 plt.savefig(out_file_path,dpi=300) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
315 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
316 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
317 def HTML_Gen(html): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
318 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
319 out_html = open(html,'w') |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
320 part_1 = """ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
321 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
322 <!DOCTYPE html> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
323 <html lang="en"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
324 <head> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
325 <title>Bootstrap Example</title> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
326 <meta charset="utf-8"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
327 <meta name="viewport" content="width=device-width, initial-scale=1"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
328 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
329 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
330 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
331 <body> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
332 <style> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
333 div.container_1 { |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
334 width:600px; |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
335 margin: auto; |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
336 padding-right: 10; |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
337 } |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
338 div.table { |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
339 width:600px; |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
340 margin: auto; |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
341 padding-right: 10; |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
342 } |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
343 </style> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
344 </head> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
345 <div class="jumbotron text-center"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
346 <h1> Fisher's Plot </h1> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
347 </div> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
348 <div class="container"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
349 <div class="row"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
350 <div class="col-sm-4"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
351 <img src="1.png" alt="Smiley face" height="800" width="800"> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
352 </div> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
353 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
354 </div> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
355 </div> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
356 </body> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
357 </html> |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
358 """ |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
359 out_html.write(part_1) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
360 out_html.close() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
361 # Load sets of amyloidogenic and non-amyloidogenic peptides: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
362 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
363 def run(Fasta1, Fasta2, windows_per_frame, overlap_factor, xlabel, ylabel, pop1_label, pop2_label, htmlOutDir, htmlFname, Workdirpath): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
364 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
365 if not os.path.exists(htmlOutDir): |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
366 os.makedirs(htmlOutDir) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
367 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
368 amyload_pos_seq = load_fasta_file(Fasta1) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
369 amyload_neg_seq = load_fasta_file(Fasta2) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
370 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
371 # Calculate quantitive features: volume and hydropathy |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
372 mean_volume = Feature(get_aa2volume()).then(average) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
373 mean_hydropathy = Feature(get_aa2hydropathy()).then(average) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
374 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
375 fs = FeatureSet("volume'n'hydropathy") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
376 fs.add(mean_volume) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
377 fs.add(mean_hydropathy) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
378 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
379 amyload_pos_conv_seq = fs(amyload_pos_seq) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
380 amyload_neg_conv_seq = fs(amyload_neg_seq) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
381 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
382 # Do local Fisher: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
383 result = local_fisher_2d(amyload_pos_conv_seq, amyload_neg_conv_seq, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
384 windows_per_frame=int(windows_per_frame), overlap_factor=int(overlap_factor)) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
385 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
386 # Plot local Fisher: |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
387 _plot_local_fisher_2d(result, xlabel=xlabel, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
388 ylabel=ylabel, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
389 pop1_label=pop1_label, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
390 pop2_label=pop2_label, |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
391 out_file_path =os.path.join(os.getcwd(), "out.png") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
392 ) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
393 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
394 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
395 # plt.savefig(os.path.join(Workdirpath, htmlOutDir, "1.png")) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
396 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
397 HTML_Gen(os.path.join(Workdirpath, htmlOutDir, htmlFname)) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
398 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
399 if __name__=="__main__": |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
400 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
401 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
402 import argparse |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
403 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
404 parser = argparse.ArgumentParser() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
405 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
406 parser.add_argument("-f1", "--Fasta1", required=True, default=None, help="First fasta file ") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
407 parser.add_argument("-f2", "--Fasta2", required=True, default=None, help="Second fasta file") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
408 parser.add_argument("-o", "--overlap_factor", required=False, default=5, help="Overlap factor") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
409 parser.add_argument("-w", "--windows_per_frame", required=False, default=5, help="Windows per frame") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
410 parser.add_argument("-x", "--xlabel", required=True, default=None, help="X label") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
411 parser.add_argument("-y", "--ylabel", required=True, default=None, help="Y label") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
412 parser.add_argument("-p1", "--pop1_label", required=True, default=None, help="First population label") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
413 parser.add_argument("-p2", "--pop2_label", required=True, default=None, help="Second population label") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
414 parser.add_argument("--htmlOutDir", required=False, default=os.path.join(os.getcwd(),'report_dir'), help="Path to html dir") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
415 parser.add_argument("--htmlFname", required=False, help="html output file", default="report.html") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
416 parser.add_argument("--Workdirpath", required=False, default=os.getcwd(), help="Path to output Working Directory") |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
417 args = parser.parse_args() |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
418 |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
419 run(args.Fasta1, args.Fasta2, args.windows_per_frame, args.overlap_factor, args.xlabel, args.ylabel, args.pop1_label, args.pop2_label, args.htmlOutDir, args.htmlFname, args.Workdirpath) |
e59674e3a391
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit 6f53ad797ec1af02b41510063a86bec7d121abf3"
jay
parents:
diff
changeset
|
420 |