@@ -601,6 +601,9 @@ def _parse_indfile(self, indfile):
601601 self ._sort_qvals_pop (indarray = indarray )
602602 indarray = indarray [indarray [:, 1 ].argsort ()]
603603
604+ self .indv = indarray [:, 0 ]
605+ self .number_indv = len (self .indv )
606+
604607 # Set self.pops attribute
605608 pop_counts = Counter (indarray [:, 1 ])
606609 pop_sums = np .cumsum ([np .count_nonzero (indarray == x )
@@ -797,13 +800,15 @@ def plotk(self, kvals, output_dir):
797800 with open (filepath , "w" ) as fh :
798801 fh .write (ploty_html (pdiv ))
799802
800- def plotk_static (self , kval , output_dir , bw = False ):
803+ def plotk_static (self , kval , output_dir , bw = False , use_ind = False ):
801804 """
802805 Generates a structure plot in svg format.
803806 :param kval: (int) Must match the K value from self.kvals
804807 :param output_dir: (string) Path of the plot file
805- :param bw: If True, plots will be generated with patterns instead of
808+ :param bw: (bool) If True, plots will be generated with patterns instead of
806809 colors to distinguish k groups.
810+ :param show_ind: (bool) If True, and if individual labels were provided
811+ with the --ind option, use those labels instead of population labels
807812 """
808813
809814 qvalues = self .kvals [kval ].qvals
@@ -854,8 +859,7 @@ def plotk_static(self, kval, output_dir, bw=False):
854859 former_q = former_q + qvalues [:, i ]
855860
856861 # Annotate population info
857- if self .pops :
858-
862+ if self .pops and not use_ind :
859863 pop_lines = list (OrderedDict .fromkeys (
860864 [x for y in self .pops_xrange for x in y ]))[1 :- 1 ]
861865
@@ -872,7 +876,7 @@ def plotk_static(self, kval, output_dir, bw=False):
872876
873877 for pos in range (self .number_indv ):
874878 axe .text (pos , - 0.05 , self .indv [pos ],
875- rotation = 45 , va = "top" , ha = "right" , fontsize = 10 )
879+ rotation = 45 , va = "top" , ha = "right" , fontsize = 8 )
876880
877881 for axis in ["top" , "bottom" , "left" , "right" ]:
878882 axe .spines [axis ].set_linewidth (2 )
@@ -897,7 +901,7 @@ def plotk_static(self, kval, output_dir, bw=False):
897901
898902
899903def main (result_files , fmt , outdir , bestk = None , popfile = None , indfile = None ,
900- filter_k = None , bw = False ):
904+ filter_k = None , bw = False , use_ind = False ):
901905 """
902906 Wrapper function that generates one plot for each K value.
903907 :return:
@@ -919,7 +923,7 @@ def main(result_files, fmt, outdir, bestk=None, popfile=None, indfile=None,
919923
920924 if k >= 1 and k in filter_k :
921925 klist .plotk ([k ], outdir )
922- klist .plotk_static (k , outdir , bw = bw )
926+ klist .plotk_static (k , outdir , bw = bw , use_ind = use_ind )
923927
924928 # If a sequence of multiple bestk is provided, plot all files in a single
925929 # plot
0 commit comments