Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

get_dim_names and get_identifiers added in dataset

This commit is contained in:
Arnar Flatberg 2006-04-24 11:23:30 +00:00
parent a2e4392a72
commit 6356e2ebd6
2 changed files with 19 additions and 14 deletions

View File

@ -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]
def get_identifiers(self,dim):
"""Returns identifiers aling dim, sorted by position (index)"""
items = self._map[dim].items()
backitems=[ [v[1],v[0]] for v in items]
backitems.sort()
sorted_ids=[ backitems[i][1] for i in range(0,len(backitems))]
return tuple(sorted_ids)
# ensure correct order
# this has correct dims but not identifiers
ids = []
for dim in self._dims:
ids.append((dim,self._map[dim].keys()))
return ids
class CategoryDataset(Dataset): class CategoryDataset(Dataset):
"""The category dataset class. """The category dataset class.

View File

@ -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