PhenopacketTable
This class creates a table with a summary of all phenopackets in a cohort of individuals Create Individual objects and transform them into phenopackets, or import GA4GH phenopackets and display them.
from IPython.display import HTML, display
phenopackets = [i.to_ga4gh_phenopacket(metadata=metadata) for i in individuals]
table = PhenopacketTable.from_phenopackets(phenopacket_list=phenopackets)
display(HTML(table.to_html()))
Alternatively,
table = PhenopacketTable.from_individuals(individual_list=individuals, metadata=metadata)
display(HTML(table.to_html()))
Source code in pyphetools/visualization/phenopacket_table.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
__init__(phenopacket_list=None, individual_list=None, metadata=None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
phenopacket_list
|
List[Phenopacket]
|
List of GA4GH phenopackets to be displayed |
None
|
individual_list
|
List[Individual]
|
List of Indidivual objects to be displayed |
None
|
metadata
|
MetaData
|
metadata about the individuals |
None
|
Source code in pyphetools/visualization/phenopacket_table.py
from_individuals(individual_list, metadata)
staticmethod
Initialize PhenopacketTable from list of GA4GH Phenopackets
Parameters:
Name | Type | Description | Default |
---|---|---|---|
phenopacket_list
|
List[PPKt.Phenopacket]
|
list of GA4GH Phenopackets |
required |
Returns:
Type | Description |
---|---|
PhenopacketTable
|
PhenopacketTable for displaying information about a cohort |
Source code in pyphetools/visualization/phenopacket_table.py
from_phenopackets(phenopacket_list)
staticmethod
Initialize PhenopacketTable from list of GA4GH Phenopackets
Parameters:
Name | Type | Description | Default |
---|---|---|---|
phenopacket_list
|
List[Phenopacket]
|
list of GA4GH Phenopackets |
required |
Returns:
Type | Description |
---|---|
PhenopacketTable
|
PhenopacketTable for displaying information about a cohort |
Source code in pyphetools/visualization/phenopacket_table.py
get_hpo_cell(term_by_age_dict)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
term_by_age_dict
|
Dict[str, HpTerm]
|
A dictionary with key - ISO8601 string, value - list of HpTerm objects |
required |
Returns:
Type | Description |
---|---|
str
|
HTML code for the HTML cell |
Source code in pyphetools/visualization/phenopacket_table.py
get_sorted_age2data_list(ages)
staticmethod
Create a sorted list of Age2Day objects that we use to display the age in the HTML output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ages
|
Set[str]
|
A set of ISO 8601 age strings |
required |
Returns:
Type | Description |
---|---|
List[Age2Day]
|
A list of sorted Age2Day objects |
Source code in pyphetools/visualization/phenopacket_table.py
iso_to_days(iso_age)
staticmethod
Transform the ISO8601 age strings (e.g., P3Y2M) into the corresponding number of days to facilitate sorting.
Note that if age is not provided we want to sort it to the end of the list so we transform to a very high number of days.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iso_age
|
str
|
ISO8601 age string (e.g., P3Y2M) |
required |
Returns:
Type | Description |
---|---|
int
|
number of days |
Source code in pyphetools/visualization/phenopacket_table.py
to_html()
create an HTML table with patient ID, age, sex, genotypes, and PhenotypicFeatures