Stackable Regimen
Source code in phenex/phenotypes/factory/stackable_regimen.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
|
__init__(phenotypes, regimen_keys=None, name='sr')
Often we want to see how drugs are utilized; are people taking a single drug, a combination, and if so, which ones? StackableRegimens can be used to answer this question. Given a list of input phenotypes, it generates a list of phenotypes computing all possible combinations of those inputs.
Generates all possible combinations of regimens from size 1 up to max_combination_size of 10.
For example, with three phenotypes named ['c1', 'c2', 'c3'] stackable regimens will create all combinations :
Regimen Type | Logic Expression |
---|---|
stack 1 phenotypes i.e. "single" regimen | c1 & ~(c2 | c3) |
c2 & ~(c1 | c3) | |
c3 & ~(c1 | c2) | |
stack 2 phenotypes i.e. "dual" regimen | (c1 & c2) & ~c3 |
(c1 & c3) & ~c2 | |
(c2 & c3) & ~c1 | |
stack 3 phenotypes i.e. "triple" regimen | c1 & c2 & c3 |
To use, create a StackableRegimen class, passing it the input phenotypes. The stackable regimes are then accessible as properties of the StackableRegimen object as either a list or dictionary in output_phenotypes and output_phenotypes_dict, respectively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
phenotypes
|
List[Any]
|
List of phenotypes to create combinations from |
required |
regimen_keys
|
Optional[List[str]]
|
List of keys corresponding to phenotypes. If None, the phenotype names will be used. This is for convenience if phenotype names are very long and a shorter version is desired. For visibility purposes, it is suggested that names do not contain spaces or underscores. |
None
|
name
|
str
|
Prefix added to every stackable regimen. Format of output phenotype names is prefix, stack size, and phenotype names that are true in that stack (stack size = n phenotype names) separated by underscores i.e. {name}{stack2}{phenotypename1}_{phenotype2} |
'sr'
|
Attributes:
Name | Type | Description |
---|---|---|
output_phenotypes |
Flat list of phenotypes generated by the regimen |
|
output_phenotypes_dict |
Dictionary mapping stack size (i.e. how many phenotypes are true, stack1, stack2... stack n) to lists of phenotypes |
Example:
# create a list of all the (input) phenotypes that you wish to see combinations of
pts = []
for cl in cls:
pt = CodelistPhenotype(
name=cl, domain="CONDITION_OCCURRENCE", codelist=Codelist([cl])
)
pts.append(pt)
# create a StackableRegimen class, passing it the input phenotypes
stackable_regimen = StackableRegimen(
phenotypes=pts,
regimen_keys=["betablockers", "calciumchannelblockers", "arbs", "aceinhibitors"]
)
list_of_stackable_combinations = stackable_regimen.output_phenotypes