fill in missing values in the SNP matrix by the mean value
        optionally center the data and unit-variance it

        Args:
            X:      scipy.array of SNP values. If dtype=='int8' the missing values are -9, 
                    otherwise the missing values are scipy.nan
            center: Boolean indicator if data should be mean centered
                    Not supported in C-based parser
            unit:   Boolean indicator if data should be normalized to have unit variance
                    Not supported in C-based parser
            betaNotUnitVariance:    use Beta(betaA,betaB) standardization instead of unit variance 
                                    (only with C-based parser) (default: False)
            betaA:  shape parameter for Beta(betaA,betaB) standardization (only with C-based parser)
            betaB:  scale parameter for Beta(betaA,betaB) standardization (only with C-based parser)

        Returns:
            X:      scipy.array of standardized SNPs with scipy.float64 values

def _imputeMissing(X, center=True, unit=True, betaNotUnitVariance=False, betaA=1.0, betaB=1.0):
        '''
        fill in missing values in the SNP matrix by the mean value
        optionally center the data and unit-variance it

        Args:
            X:      scipy.array of SNP values. If dtype=='int8' the missing values are -9, 
                    otherwise the missing values are scipy.nan
            center: Boolean indicator if data should be mean centered
                    Not supported in C-based parser
            unit:   Boolean indicator if data should be normalized to have unit variance
                    Not supported in C-based parser
            betaNotUnitVariance:    use Beta(betaA,betaB) standardization instead of unit variance 
                                    (only with C-based parser) (default: False)
            betaA:  shape parameter for Beta(betaA,betaB) standardization (only with C-based parser)
            betaB:  scale parameter for Beta(betaA,betaB) standardization (only with C-based parser)

        Returns:
            X:      scipy.array of standardized SNPs with scipy.float64 values
        '''
        typeX=X.dtype
        if typeX!=SP.int8:
            iNanX = X!=X
        else:
            iNanX = X==-9
        if iNanX.any() or betaNotUnitVariance:
            if cparser:
                print("using C-based imputer")
                if X.flags["C_CONTIGUOUS"] or typeX!=SP.float32:
                    X = SP.array(X, order="F", dtype=SP.float32)
                    if typeX==SP.int8:
                        X[iNanX]=SP.nan
                    parser.standardize(X,betaNotUnitVariance=betaNotUnitVariance,betaA=betaA,betaB=betaB)
                    X=SP.array(X,dtype=SP.float64)
                else:
                    parser.standardize(X,betaNotUnitVariance=betaNotUnitVariance,betaA=betaA,betaB=betaB)
                X=SP.array(X,dtype=SP.float64)
            else:
                if betaNotUnitVariance:
                    raise NotImplementedError("Beta(betaA,betaB) standardization only in C-based parser, but not found")
                nObsX = (~iNanX).sum(0)
                if typeX!=SP.float64:
                    X=SP.array(X,dtype=SP.float64)
                X[iNanX] = 0.0
                sumX = (X).sum(0)                
                meanX = sumX/nObsX
                if center:
                    X-=meanX
                    X[iNanX] = 0.0
                    X_=X
                else:
                    mean=SP.tile(meanX,(X.shape[0],1))
                    X[iNanX]=mean[iNanX]
                    X_=X-mean
                if unit:
                    stdX = SP.sqrt((X_*X_).sum(0)/nObsX)
                    stdX[stdX==0.0]=1.0
                    X/=stdX
        else:
            if X.dtype!=SP.float64:
                X=SP.array(X,dtype=SP.float64)
            if center:
                X-= X.mean(axis=0)
            if unit:
                stdX= X.std(axis=0)
                stdX[stdX==0.0]=1.0
                X/=stdX
        return X