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