def _get_indices(self,element,labels,return_indices,mode): r''' This is the actual method for getting indices, but should not be called directly. ''' if mode == 'union': union = sp.zeros_like(self._get_info(element=element,label='all'),dtype=bool) for item in labels: #iterate over labels list and collect all indices union = union + self._get_info(element=element,label=item) ind = union elif mode == 'intersection': intersect = sp.ones_like(self._get_info(element=element,label='all'),dtype=bool) for item in labels: #iterate over labels list and collect all indices intersect = intersect*self._get_info(element=element,label=item) ind = intersect elif mode == 'not_intersection': not_intersect = sp.zeros_like(self._get_info(element=element,label='all'),dtype=int) for item in labels: #iterate over labels list and collect all indices info = self._get_info(element=element,label=item) not_intersect = not_intersect + sp.int8(info) ind = (not_intersect == 1) elif mode == 'none': none = sp.zeros_like(self._get_info(element=element,label='all'),dtype=int) for item in labels: #iterate over labels list and collect all indices info = self._get_info(element=element,label=item) none = none - sp.int8(info) ind = (none == 0) if return_indices: ind = sp.where(ind==True)[0] return ind
def get_incidence_matrix(self): ets = sp.array(self.ecotypes) unique_ets = [] i = 0 while i < len(ets): et = ets[i] unique_ets.append(et) while i < len(ets) and ets[i] == et: #The ecotypes are assumed to be sorted i += 1 Z = sp.int8(sp.mat(ets).T == sp.mat(unique_ets)) return Z
def get_incidence_matrix(self): ets = sp.array(self.ecotypes) unique_ets = [] i = 0 while i < len(ets): et = ets[i] unique_ets.append(et) while i < len(ets) and ets[ i] == et: #The ecotypes are assumed to be sorted i += 1 Z = sp.int8(sp.mat(ets).T == sp.mat(unique_ets)) return Z
def get_incidence_matrix(self, pid): ets = sp.array(self.phen_dict[pid]['ecotypes']) unique_ets = [] i = 0 while i < len(ets): et = ets[i] unique_ets.append(et) while i < len(ets) and ets[i] == et: #The ecotypes are assumed to be sorted i += 1 # unique_ets = sp.mat(sp.unique(ets)) Z = sp.int8(sp.mat(ets).T == sp.mat(unique_ets)) #print Z return Z