Added categorygetter for PhenotypeDataset.
This commit is contained in:
@@ -231,6 +231,7 @@ class PhenotypeDataset(dataset.Dataset):
|
||||
col_names = rows[0][1:]
|
||||
phenotypes = []
|
||||
categories = {}
|
||||
self._categories = set()
|
||||
|
||||
for col_name, column in zip(col_names, columns[1:]):
|
||||
try:
|
||||
@@ -247,8 +248,8 @@ class PhenotypeDataset(dataset.Dataset):
|
||||
|
||||
entries[entry].append(i)
|
||||
|
||||
|
||||
for key in keys:
|
||||
self._categories.add(key)
|
||||
z = zeros(len(column))
|
||||
for i in entries[key]:
|
||||
z[i] = 1
|
||||
@@ -269,6 +270,14 @@ class PhenotypeDataset(dataset.Dataset):
|
||||
('phenotypes', phenotypes)],
|
||||
shape=(len(cel_names),len(phenotypes)), name="Phenotype Data")
|
||||
|
||||
|
||||
def get_phenotype_table(self):
|
||||
"""Get string based table of phenotypes as read from file."""
|
||||
return self._table
|
||||
|
||||
def get_categories(self):
|
||||
"""Get categories of factors.
|
||||
|
||||
If factor 'sick' had possibilites Y/N, and 'sex' M/F, the
|
||||
categories would be Y, N, M and F.
|
||||
"""
|
||||
return self._categories
|
||||
|
Reference in New Issue
Block a user