Skip to content

Commit 5dd9429

Browse files
committed
Starts to implement a plotting function for ALStructure
1 parent 7523a93 commit 5dd9429

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

structure_threader/plotter/structplot.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/python3
22

3-
# Copyright 2015-2018 Francisco Pina Martins <[email protected]>
3+
# Copyright 2015-2019 Francisco Pina Martins <[email protected]>
44
# and Diogo N. Silva <[email protected]>
55
# This file is part of structure_threader.
66
# structure_threader is free software: you can redistribute it and/or modify
@@ -100,7 +100,8 @@ def __init__(self, kfile, fmt, get_indv=False):
100100

101101
parse_methods = {"structure": self._parse_structure,
102102
"faststructure": self._parse_faststructure,
103-
"maverick": self._parse_maverick}
103+
"maverick": self._parse_maverick,
104+
"alstructure": self._parse_alstructure}
104105

105106
# Let the parsing begin
106107
parse_methods[self.fmt]()
@@ -302,6 +303,22 @@ def _parse_maverick(self):
302303
dtype="|U20",
303304
skip_header=1).T[1].T)
304305

306+
def _parse_alstructure(self):
307+
"""
308+
Parses the meanQ array of a single ALStructure output file
309+
Sets the qvals array, the number of individual taxa (nind)
310+
and number of clusters (k)
311+
"""
312+
313+
self.qvals = np.genfromtxt(self.file_path)
314+
self.qvals = np.delete(self.qvals, 0, 0)
315+
self.qvals = np.delete(self.qvals, 0, 1)
316+
317+
try:
318+
self.nind, self.k = self.qvals.shape
319+
except ValueError:
320+
self.k = 1
321+
305322

306323
class PlotList(AuxSanity):
307324
"""

structure_threader/structure_threader.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ def create_plts(wrapped_prog, bestk, arg):
218218
plt_files = [os.path.join(os.path.join(arg.outpath, "mav_K" + str(i)),
219219
"outputQmatrix_ind_K" + str(i) + ".csv")
220220
for i in arg.k_list]
221+
elif wrapped_prog == "alstructure":
222+
plt_files = [os.path.join(os.path.join(arg.outpath, "alstr_K" + str(i)))
223+
for i in arg.k_list]
221224

222225
else:
223226
plt_files = [os.path.join(arg.outpath, "fS_run_K.") + str(i) + ".meanQ"
@@ -288,9 +291,9 @@ def full_run(arg):
288291
wrapped_prog = "structure"
289292
elif "-als" in sys.argv:
290293
wrapped_prog = "alstructure"
291-
arg.threads = 1
292-
arg.notests = True
293-
arg.k_list = [x for x in arg.k_list if x != 1]
294+
arg.threads = 1 # Depencency handling forces this
295+
arg.notests = True # No way to perform K tests with ALS
296+
arg.k_list = [x for x in arg.k_list if x != 1] # ALS can't have K=1
294297

295298
structure_threader(wrapped_prog, arg)
296299

0 commit comments

Comments
 (0)