diff --git a/ipyrad/analysis/pca.py b/ipyrad/analysis/pca.py index 29608f72..2a858c9e 100644 --- a/ipyrad/analysis/pca.py +++ b/ipyrad/analysis/pca.py @@ -199,7 +199,7 @@ def __init__( index=self.names, columns=["missing"]) # impute missing data - if self._mvals: + if (self.impute_method is not False) and self._mvals: self._impute_data() @@ -231,6 +231,7 @@ def _impute_data(self): elif self.impute_method == "random": missing = self.snps == 9 + self.snps[missing] = 0 self.snps[missing] += np.random.choice([0,1,2], self.snps.shape)[missing].astype(np.uint64) self._print( "Imputation (Random; sets to ~U[0,1,2]): {:.1f}%, {:.1f}%, {:.1f}%" @@ -238,7 +239,8 @@ def _impute_data(self): ) else: - self.snps[self.snps == 9] = 0 + missing = self.snps == 9 + self.snps[missing] = 0 self._print( "Imputation (null; sets to 0): {:.1f}%, {:.1f}%, {:.1f}%" .format(100, 0, 0)