eds_scikit.plot.event_sequences
plot_event_sequences
plot_event_sequences(df_events: pd.DataFrame, event_col: Optional[str] = 'event', event_start_datetime_col: Optional[str] = 'event_start_datetime', event_end_datetime_col: Optional[str] = 'event_end_datetime', dim_mapping: Optional[Dict[str, Dict[str, Union[Tuple[int], str]]]] = None, index_date_col: Optional[str] = None, family_col: Optional[str] = None, family_to_index: Optional[Dict[str, int]] = None, list_person_ids: Optional[List[str]] = None, same_x_axis_scale: Optional[bool] = False, subplot_height: Optional[int] = 200, subplot_width: Optional[int] = 500, point_size: Optional[int] = 400, bar_height: Optional[int] = 20, title: Optional[str] = None, seed: Optional[int] = 0) -> alt.VConcatChart
Plots individual sequences from an events DataFrame. Each event must be recorded with a start date, a name and a person_id
.
Events can be both one-time (only start date given) or longitudinal (both start and end dates).
Events can also be aggregated in families using the family_col
argument.
Finally, events labelling and colors can be manually set by providing a dim_mapping
dictionary.
PARAMETER | DESCRIPTION |
---|---|
df_events |
DataFrame gathering the events information. Must contain at least
TYPE:
|
event_col |
Column name of the events.
TYPE:
|
event_start_datetime_col |
Column name of the event start datetime.
TYPE:
|
event_end_datetime_col |
Column name of the event end datetime.
TYPE:
|
dim_mapping |
Mapping dictionary to provide plotting details on events. Must be of type :
TYPE:
|
index_date_col |
Column name of the index date to compute relative datetimes for events. For example, it could be the date of inclusion for each patient.
TYPE:
|
family_col |
Column name of family events. Events of a given family will be plot on the same row.
TYPE:
|
family_to_index |
Dictionary mapping event family names to ordering indices.
TYPE:
|
list_person_ids |
List of person_ids to plot. If None given, only the first three individual sequences will be plot.
TYPE:
|
same_x_axis_scale |
Whether to use the same axis scale for all sequences.
TYPE:
|
subplot_height |
Height of each plot.
TYPE:
|
subplot_width |
Width of each plot.
TYPE:
|
point_size |
Size of points for one-time events.
TYPE:
|
bar_height |
Height of bars for continuous events.
TYPE:
|
title |
Chart title.
TYPE:
|
seed |
Seed to randomly draw colors when not provided.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
chart
|
Chart with the plotted individual event sequences.
TYPE:
|
Source code in eds_scikit/plot/event_sequences.py
10 11 12 13 14 15 16 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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|