Skip to content

Commit 488fc91

Browse files
committed
Added bestK barplot function. #63
1 parent 575b174 commit 488fc91

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

structure_threader/plotter/structplot.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Create color pallete
4040
c = cl.scales["12"]["qual"]["Set3"]
41-
41+
plt.style.use("ggplot")
4242

4343
class PlotK:
4444
"""
@@ -848,8 +848,6 @@ def plotk_static(self, kval, output_dir, bw=False, use_ind=False):
848848
with the --ind option, use those labels instead of population labels
849849
"""
850850

851-
plt.style.use("ggplot")
852-
853851
numinds = self.number_indv
854852

855853
clist = [[i / 255. for i in x] for x in cl.to_numeric(c)]
@@ -944,6 +942,23 @@ def plotk_static(self, kval, output_dir, bw=False, use_ind=False):
944942
plt.close()
945943

946944

945+
def plot_normalization(norm_dict, outdir):
946+
947+
plt.clf()
948+
949+
keys = ["norm_mean", "lower_limit", "upper_limit"]
950+
951+
data = [(k, [vals[x] for x in keys]) for k, vals in norm_dict.items()]
952+
953+
means = [x[1][0] for x in data]
954+
lower_limit = [x[1][0] - x[1][1] for x in data]
955+
upper_limit = [x[1][2] - x[1][0] for x in data]
956+
957+
plt.bar(range(len(means)), means, yerr=[lower_limit, upper_limit])
958+
959+
plt.savefig(join(outdir, "bestK", "bestk_evidence.svg"), dpi=200)
960+
961+
947962
def main(result_files, fmt, outdir, bestk=None, popfile=None, indfile=None,
948963
filter_k=None, bw=False, use_ind=False):
949964
"""

structure_threader/wrappers/maverick_wrapper.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626

2727
try:
2828
import colorer.colorer as colorer
29+
from plotter.structplot import plot_normalization
2930
except ImportError:
3031
import structure_threader.colorer.colorer as colorer
31-
32+
from structure_threader.plotter.structplot import plot_normalization
3233

3334
def mav_cli_generator(arg, k_val, mav_params):
3435
"""
@@ -145,8 +146,9 @@ def ti_test(outdir, norm_evidence, ti_in_use):
145146
bestk_file.write(output_text)
146147
bestk_file.close()
147148

149+
plot_normalization(criteria, outdir)
150+
148151
return [int(bestk)]
149-
# TODO: Draw a plot!
150152

151153

152154
def maverick_merger(outdir, k_list, mav_params, no_tests):

0 commit comments

Comments
 (0)