get_dim_names and get_identifiers added in dataset
This commit is contained in:
parent
a2e4392a72
commit
6356e2ebd6
|
@ -157,19 +157,25 @@ class Dataset:
|
||||||
self.has_array = True
|
self.has_array = True
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
|
"""Returns dataset name"""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
def get_all_dims(self):
|
def get_all_dims(self):
|
||||||
|
"""Returns all dimensions in project"""
|
||||||
return self._all_dims
|
return self._all_dims
|
||||||
|
|
||||||
def get_identifiers(self):
|
def get_dim_names(self):
|
||||||
#return [n for n in self._map.iteritems()]
|
"""Returns dim names"""
|
||||||
|
return [dim for dim in self._dims]
|
||||||
|
|
||||||
# ensure correct order
|
def get_identifiers(self,dim):
|
||||||
# this has correct dims but not identifiers
|
"""Returns identifiers aling dim, sorted by position (index)"""
|
||||||
ids = []
|
items = self._map[dim].items()
|
||||||
for dim in self._dims:
|
backitems=[ [v[1],v[0]] for v in items]
|
||||||
ids.append((dim,self._map[dim].keys()))
|
backitems.sort()
|
||||||
return ids
|
sorted_ids=[ backitems[i][1] for i in range(0,len(backitems))]
|
||||||
|
return tuple(sorted_ids)
|
||||||
|
|
||||||
|
|
||||||
class CategoryDataset(Dataset):
|
class CategoryDataset(Dataset):
|
||||||
"""The category dataset class.
|
"""The category dataset class.
|
||||||
|
|
|
@ -93,13 +93,12 @@ class PCAFunction(Function):
|
||||||
singel_def = ('1',('s'))
|
singel_def = ('1',('s'))
|
||||||
|
|
||||||
# pull out input identifiers:
|
# pull out input identifiers:
|
||||||
data_ids = []
|
row_ids = data.get_identifiers('genes')
|
||||||
for dim in data:
|
col_ids = data.get_identifiers('samples')
|
||||||
data_ids.append((dim,data[dim].keys()))
|
|
||||||
|
|
||||||
T = dataset.Dataset(T,(data_ids[0],comp_def))
|
T = dataset.Dataset(T,[('samples',col_ids) ,comp_def])
|
||||||
P = dataset.Dataset(P,[data_ids[1],comp_def])
|
P = dataset.Dataset(P,[('genes',row_ids),comp_def])
|
||||||
E = dataset.Dataset(E,data_ids)
|
E = dataset.Dataset(E,[('samples',col_ids),'genes',(row_ids)])
|
||||||
#tsq = dataset.Dataset(tsq,[singel_def,data_ids[1])
|
#tsq = dataset.Dataset(tsq,[singel_def,data_ids[1])
|
||||||
|
|
||||||
## plots
|
## plots
|
||||||
|
|
Reference in New Issue