コード例 #1
0
 def __call__(self, pt):
     """
     """
     pt = _matrix([[pt.x], [pt.y], [1]])
     pt = _dot(self.matrix, pt)
     x, y, w = pt[0,0], pt[1,0], pt[2,0]
     
     return Point(x/w, y/w)
コード例 #2
0
    def __call__(self, pt):
        """
        """
        pt = _matrix([[pt.x], [pt.y], [1]])
        pt = _dot(self.matrix, pt)
        x, y, w = pt[0, 0], pt[1, 0], pt[2, 0]

        return Point(x / w, y / w)
コード例 #3
0
def _pca_data(e_, model_keys, pc_filter):
    if e_.shape[1] == 2:
        return e_, model_keys, 1, 1, 1
    #numpy.svd can't handle typical data size in UK Biobank. So we do PCA through the covariance matrix
    # That is: we compute ths SVD of a covariance matrix, and use those coefficients to get the SVD of input data
    # Shamelessly designed from https://stats.stackexchange.com/questions/134282/relationship-between-svd-and-pca-how-to-use-svd-to-perform-pca
    # In numpy.cov, each row is a variable and each column an observation. Exactly opposite to standard PCA notation: it is transposed, then.
    Xc_t = _get_pc_input(e_, model_keys)
    k = numpy.cov(Xc_t)
    u, s, vt = numpy.linalg.svd(k)
    # we want to keep only those components with significant variance, to reduce dimensionality
    selected = pc_filter(s)
    Xc_t_ = _dot(vt[selected], Xc_t)
    _data = {"pc{}".format(i): x for i, x in enumerate(Xc_t_)}
    pca_keys = _data.keys()
    _data["pheno"] = e_.pheno
    pca_data = pandas.DataFrame(_data)
    return pca_data, pca_keys, numpy.max(s), numpy.min(s), numpy.min(
        s[selected])
コード例 #4
0
 def multiply(self, other):
     """
     """
     return matrix2transform(_dot(other.matrix, self.matrix))
コード例 #5
0
 def multiply(self, other):
     """
     """
     return matrix2transform(_dot(other.matrix, self.matrix))