Skip to content

Commit c3060e1

Browse files
committed
Fixed qvalue sorting when indfile has only two columns
1 parent 1c34963 commit c3060e1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

structure_threader/plotter/structplot.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,16 @@ def _sort_qvals_pop(self, poparray=None, indarray=None):
455455
index_array = np.c_[sorted_array["original_order"],
456456
qvals]
457457
elif indarray is not None:
458-
index = indarray[:, 2].astype(np.float64)
459-
index_array = np.c_[index, qvals]
458+
if indarray.shape[1] == 3:
459+
index = indarray[:, 2].astype(np.float64)
460+
index_array = np.c_[index, qvals]
461+
else:
462+
index = indarray[:, 1]
463+
index_array = np.c_[index, qvals]
464+
460465
# Sort indexed array
461466
sorted_qvals = index_array[index_array[:, 0].argsort()]
462-
kobj.qvals = sorted_qvals[:, 1:]
467+
kobj.qvals = sorted_qvals[:, 1:].astype(np.float64)
463468

464469
def _parse_popfile(self, popfile):
465470
"""
@@ -593,6 +598,7 @@ def _parse_indfile(self, indfile):
593598
else:
594599
# Sort the individuals alphabetically per population if no
595600
# order column was provided
601+
self._sort_qvals_pop(indarray=indarray)
596602
indarray = indarray[indarray[:, 1].argsort()]
597603

598604
# Set self.pops attribute

0 commit comments

Comments
 (0)