Therapeutic-Area Extensions¶
Fleet ships eight TA extensions accessible via df.adam.<ta>, inspired by the admiral TA packages. They are not ports: a verb can give other values than its admiral counterpart. Each verb docstring names its source under References.
Every TA namespace inherits the shared ADaM verbs, so autocomplete shows about
45 names. To list only the verbs a TA namespace adds, filter verbs() on its
origin:
import fleet
import polars as pl
df = pl.DataFrame({"x": [1]})
df.adam.vaccine.verbs().filter(pl.col("origin") == "adam.vaccine")
A TA verb is a clinical verb: it encodes a rule a programmer would otherwise
copy from a standard or a SAP, and its docstring cites that rule under
References. A new clinical verb must pass the admission bar of
ADR-0009: if it were
deleted, a programmer who rewrites it inline must be able to get a wrong answer,
not only type more.
Oncology — df.adam.onco¶
fleet.adam.OncoNamespace
¶
Bases: SharedADaMVerbsMixin
Immutable pipeline builder for ADaM oncology derivations.
Inherits shared verbs from SharedADaMVerbsMixin.
Each verb returns a new OncoNamespace instance;
to_frame() materialises the result.
Source code in src/fleet/adam/onco_namespace.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | |
aval_resp
¶
Map RECIST response text to numeric codes.
Mapping: CR=1, PR=2, SD=3, NON-CR/NON-PD=4, PD=5, NE=6, MISSING=7. Other/null values produce null.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output numeric column. |
required |
source
|
str
|
Column containing RECIST response text. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Map overall response to a numeric code::
adrs = (
rs_raw.adam.onco
.aval_resp("AVAL", source="OVRLRESP")
.to_frame()
)
References
RECIST 1.1: Eisenhauer EA et al. New response evaluation criteria in solid
tumours. Eur J Cancer. 2009;45(2):228-247. The numeric ranks follow
admiralonco aval_resp (pharmaverse).
Source code in src/fleet/adam/onco_namespace.py
tumor_response_flag
¶
Flag records where source matches a target response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output flag column. |
required |
source
|
str
|
Column containing response text. |
required |
responses
|
list[str] | None
|
Values to flag (default |
None
|
flag_value
|
str
|
Value to assign for matching records (default |
'Y'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Flag objective responders (CR or PR)::
adrs = (
rs_raw.adam.onco
.tumor_response_flag("RSPFL", source="OVRLRESP")
.to_frame()
)
Source code in src/fleet/adam/onco_namespace.py
best_overall_response
¶
Derive best overall response (BOR) per group.
The most favourable response is the one with the lowest RECIST rank
(CR < PR < SD < NON-CR/NON-PD < PD < NE < MISSING). An SD or
NON-CR/NON-PD assessed before reference_date + min_sd_days, or
with a null date, counts as NE. The verb reads every record: it does
not remove records after the first PD or after new anti-cancer
therapy. Run filter_pd on a copy first and join BOR back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
source
|
str
|
Column containing RECIST response text. |
required |
date_col
|
str
|
Assessment date column (Date or ISO text). |
required |
reference_date
|
str
|
Start of the SD minimum, for example RANDDT or TRTSDT. |
required |
min_sd_days
|
int
|
Protocol minimum duration of SD, in days. |
required |
by
|
list[str] | None
|
Partition columns (default |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Raises:
| Type | Description |
|---|---|
DerivationError
|
If min_sd_days is negative. |
Examples:
Derive BOR per subject up to the first PD, with a 42-day SD minimum::
bor = (
adrs.adam.onco
.filter_pd(response_col="OVRLRESP", date_col="ADT",
by=["USUBJID"])
.best_overall_response("BOR", source="OVRLRESP",
date_col="ADT",
reference_date="RANDDT",
min_sd_days=42, by=["USUBJID"])
.to_frame()
.select("USUBJID", "BOR")
.unique()
)
adrs = adrs.join(bor, on="USUBJID", how="left")
References
RECIST 1.1 (Eisenhauer EA et al. Eur J Cancer. 2009;45(2):228-247),
section 4.4: best overall response is the best response up to
progression; section 4.4.3: SD must meet a protocol-specified
minimum time from the reference date, else BOR is NE or PD. The
ordering CR < PR < SD < NON-CR/NON-PD < PD < NE follows admiralonco
derive_param_bor (ADT >= reference + minimum). This verb does
not apply the confirmation requirement; see
confirmed_response_flag. ADR-0031.
Source code in src/fleet/adam/onco_namespace.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
confirmed_response_flag
¶
confirmed_response_flag(
target,
*,
source,
date_col,
confirmation_days=28,
responses=None,
by=None,
flag_value="Y",
max_nr_ne=1,
max_nr_sd=0
)
Flag each CR or PR record that a later assessment confirms.
A CR is confirmed by a CR at least confirmation_days later. A PR is
confirmed by a CR or PR at least confirmation_days later. All
assessments after the record, up to and including the first
confirming one, must be CR or NE for a CR, and CR, PR, NE or SD for a
PR, with at most max_nr_ne NE and at most max_nr_sd SD. For a PR,
no PR may follow a CR in that window. Assessments after the first PD
of a group are not read, so a filter_pd before the verb changes
nothing. Only the confirmed record is flagged.
The verb warns, with the group values, when a CR is followed by a PR or SD, when two assessments of a group have the same date, and when source is null.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output flag column. |
required |
source
|
str
|
Column containing response text. |
required |
date_col
|
str
|
Assessment date column (Date or ISO text). |
required |
confirmation_days
|
int
|
Minimum gap in days (default |
28
|
responses
|
list[str] | None
|
Responses to confirm: |
None
|
by
|
list[str] | None
|
Partition columns (default |
None
|
flag_value
|
str
|
Value to assign (default |
'Y'
|
max_nr_ne
|
int | None
|
Maximum number of NE assessments in the window
(default |
1
|
max_nr_sd
|
int | None
|
Maximum number of SD assessments in the window of a
PR (default |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
A fresh namespace wrapping the updated frame. |
Raises:
| Type | Description |
|---|---|
DerivationError
|
If responses holds a value other than CR or PR. |
Examples:
Flag confirmed CR/PR responses::
adrs = (
rs_raw.adam.onco
.confirmed_response_flag(
"CRSPFL", source="OVRLRESP", date_col="ADT",
confirmation_days=28, by=["USUBJID"])
.to_frame()
)
References
RECIST 1.1 (Eisenhauer EA et al. Eur J Cancer. 2009;45(2):228-247),
section 4.4.3 Table 3, section 4.4.4 and the Appendix FAQ: a CR or PR
is confirmed by a repeat assessment no less than 4 weeks later. The
rules for NE and SD between the two follow the admiralonco
crsp_y_cr and crsp_y_pr events (pharmaverse); SD between
two PR is the accept_sd option of the deprecated
derive_param_confirmed_resp. RECIST does not fix them: check the
SAP. ADR-0030.
Source code in src/fleet/adam/onco_namespace.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
filter_pd
¶
Keep records up to and including the first PD per group.
Groups without any PD observation are fully retained. Materialises the pipeline before filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response_col
|
str
|
Column containing response text. |
required |
date_col
|
str
|
Assessment date column. |
required |
by
|
list[str] | None
|
Partition columns (default |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
A fresh namespace wrapping the filtered frame. |
Examples:
Filter to records up to first progressive disease::
adrs = (
rs_raw.adam.onco
.filter_pd(response_col="OVRLRESP", date_col="ADT",
by=["USUBJID"])
.to_frame()
)
References
admiralonco filter_pd (pharmaverse): records up to and including the
first progressive disease, as RECIST 1.1 uses for response endpoints.
Source code in src/fleet/adam/onco_namespace.py
options: show_root_heading: true heading_level: 3 filters: ["!^_"]
Ophthalmology — df.adam.ophtha¶
fleet.adam.OphthaNamespace
¶
Bases: SharedADaMVerbsMixin
Immutable pipeline builder for ADaM ophthalmology derivations.
Inherits shared verbs from SharedADaMVerbsMixin.
Source code in src/fleet/adam/ophtha_namespace.py
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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
etdrs_to_logmar
¶
Convert an ETDRS letter score to LogMAR units.
Formula (Beck et al.): logMAR = -0.02 × ETDRS + 1.7.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
source
|
str
|
Column containing the ETDRS letter score. |
required |
round_digits
|
int | None
|
Decimal places to round to (default |
4
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Convert ETDRS to LogMAR::
adbcva = (
bcva_raw.adam.ophtha
.etdrs_to_logmar("LOGMAR", source="ETDRS")
.to_frame()
)
References
Beck RW et al. A computerized method of visual acuity testing. Am J
Ophthalmol. 2003;135(2):194-205. admiralophtha
convert_etdrs_to_logmar (pharmaverse) applies the same formula.
Source code in src/fleet/adam/ophtha_namespace.py
logmar_to_etdrs
¶
Convert a LogMAR value back to ETDRS letter score.
Inverse of the Beck formula: ETDRS = (1.7 - logMAR) / 0.02.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
source
|
str
|
Column containing the LogMAR value. |
required |
round_digits
|
int | None
|
Decimal places to round to (default |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Convert LogMAR back to ETDRS::
adbcva = (
bcva_raw.adam.ophtha
.logmar_to_etdrs("ETDRS", source="LOGMAR")
.to_frame()
)
References
Beck RW et al. A computerized method of visual acuity testing. Am J
Ophthalmol. 2003;135(2):194-205. admiralophtha
convert_logmar_to_etdrs (pharmaverse) applies the same formula.
Source code in src/fleet/adam/ophtha_namespace.py
study_eye
¶
Map SC FOCID laterality codes to study eye labels.
OS → LEFT, OD → RIGHT, OU → BILATERAL, other → null.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
source
|
str
|
Column containing the FOCID code. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive study eye from SC domain::
adbcva = (
bcva_raw.adam.ophtha
.study_eye("STUDYEYE", source="SCSTRESC")
.to_frame()
)
References
Ophthalmic convention: OD = oculus dexter (right), OS = oculus sinister
(left), OU = oculus uterque (both). CDISC SDTM controlled terminology for
laterality uses LEFT, RIGHT and BILATERAL. admiralophtha
derive_var_studyeye (pharmaverse) applies the same mapping.
Source code in src/fleet/adam/ophtha_namespace.py
affected_eye
¶
Derive Affected Eye (AFEYE) from laterality and study eye.
Maps laterality/study-eye combinations to "Study Eye",
"Fellow Eye", or "Both Eyes".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
loc_col
|
str
|
Column containing the anatomical location. |
required |
lat_col
|
str
|
Column containing the laterality. |
required |
study_eye_col
|
str
|
Study eye column (default |
'STUDYEYE'
|
loc_values
|
list[str] | None
|
Valid location values (default |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive AFEYE for AE records::
adae = (
ae_raw.adam.ophtha
.affected_eye("AFEYE", loc_col="AELOC",
lat_col="AELAT")
.to_frame()
)
References
admiralophtha derive_var_afeye (pharmaverse): the Study Eye, Fellow
Eye and Both Eyes rule from laterality, location and study eye.
Source code in src/fleet/adam/ophtha_namespace.py
bcva_criterion
¶
Flag records meeting a BCVA criterion threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output flag column. |
required |
value_col
|
str
|
Column containing the BCVA score. |
required |
threshold
|
float
|
Numeric threshold value. |
required |
direction
|
str
|
Comparison — |
'ge'
|
flag_value
|
str
|
Value to assign (default |
'Y'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Flag records with ETDRS >= 70::
adbcva = (
bcva_raw.adam.ophtha
.bcva_criterion("BCVACR1FL", value_col="ETDRS",
threshold=70, direction="ge")
.to_frame()
)
Source code in src/fleet/adam/ophtha_namespace.py
options: show_root_heading: true heading_level: 3 filters: ["!^_"]
Pediatrics — df.adam.peds¶
fleet.adam.PedsNamespace
¶
Bases: SharedADaMVerbsMixin
Immutable pipeline builder for paediatric ADaM derivations.
Inherits shared verbs from SharedADaMVerbsMixin.
Source code in src/fleet/adam/peds_namespace.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
age_days
¶
Compute age in whole days.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
birth_date
|
str
|
Column containing the date of birth. |
required |
analysis_date
|
str
|
Column containing the reference date. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive age in days from birth and reference dates::
adsl = (
dm_raw.adam.peds
.age_days("AGEDAYS", birth_date="BRTHDT",
analysis_date="RFSTDTC")
.to_frame()
)
Source code in src/fleet/adam/peds_namespace.py
age_months
¶
Compute age in whole months (floor of days / 30.4375).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
birth_date
|
str
|
Column containing the date of birth. |
required |
analysis_date
|
str
|
Column containing the reference date. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive age in months::
adsl = (
dm_raw.adam.peds
.age_months("AGEMOS", birth_date="BRTHDT",
analysis_date="RFSTDTC")
.to_frame()
)
References
admiral derive_vars_duration (pharmaverse): one month = 30.4375 days
(365.25 / 12). A month of 30 days gives a different answer.
Source code in src/fleet/adam/peds_namespace.py
age_years
¶
Compute age from two date columns, in completed years by default.
Same rule as adsl.age_from_dates: unit="years" gives whole
completed years (Int64), so a child is 4 on the day before the 5th
birthday. A 29 February birthday is reached on 1 March in a non-leap
year; a reference date before birth gives a negative age.
unit="decimal" gives days / 365.25 at full precision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
birth_date
|
str
|
Column containing the date of birth. |
required |
analysis_date
|
str
|
Column containing the reference date. |
required |
unit
|
Literal['years', 'decimal']
|
|
'years'
|
round_digits
|
int | None
|
Decimal places for |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Raises:
| Type | Description |
|---|---|
VerbUsageError
|
When round_digits is given with
|
Examples:
Derive age in completed years::
adsl = (
dm_raw.adam.peds
.age_years("AAGE", birth_date="BRTHDT",
analysis_date="RFSTDT")
.to_frame()
)
References
admiral derive_vars_aage (pharmaverse) and SAS
FLOOR(YRDIF(BRTHDT, RFSTDT, 'AGE')): completed years. ICH E11 age
bands use completed years. Decimal: one year = 365.25 days. ADR-0025.
Source code in src/fleet/adam/peds_namespace.py
corrected_age
¶
Compute gestational-corrected age in decimal years.
Corrected age = chronological age − (term_weeks − gestational_weeks) / 52.18. No correction when gestational weeks >= term_weeks. A null or NaN gestational age gives a null result; if the SAP assumes term birth, fill the column with term_weeks before the call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
age_days_col
|
str
|
Column containing age in days. |
required |
gestational_weeks_col
|
str
|
Column containing gestational age in weeks. |
required |
term_weeks
|
int
|
Full-term threshold (default |
40
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive corrected age for preterm infants::
adsl = (
dm_raw.adam.peds
.corrected_age("CORAGE", age_days_col="AGEDAYS",
gestational_weeks_col="GESTAG")
.to_frame()
)
References
American Academy of Pediatrics, Committee on Fetus and Newborn. Age terminology during the perinatal period. Pediatrics. 2004;114(5):1362-1364: corrected age = chronological age minus the weeks born before 40 weeks. 52.18 weeks per year = 365.25 / 7.
Source code in src/fleet/adam/peds_namespace.py
prematurity_flag
¶
Flag infants born before threshold gestational weeks.
Default threshold of 37 weeks matches the clinical definition of prematurity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output flag column. |
required |
gestational_weeks_col
|
str
|
Column containing gestational age in weeks. |
required |
threshold
|
int
|
Weeks below which prematurity is flagged (default |
37
|
flag_value
|
str
|
Value to assign (default |
'Y'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive prematurity flag::
adsl = (
dm_raw.adam.peds
.prematurity_flag("PREMFL",
gestational_weeks_col="GESTAG")
.to_frame()
)
References
WHO: preterm birth is birth before 37 completed weeks of gestation (ICD-10 P07; WHO preterm birth fact sheet).
Source code in src/fleet/adam/peds_namespace.py
bmi_percentile_category
¶
bmi_percentile_category(
target,
*,
bmi_col,
age_months_col,
sex_col,
reference,
sex_male_value="M",
sex_female_value="F"
)
Classify a child's BMI by age and sex with the CDC 2000 or WHO 2007 reference.
reference="CDC2000" (ages 24 to < 240 months) takes the table row
of the completed month (row 60.5 for 60.0 to 60.99 months) and gives
Underweight (< P5), Healthy weight (P5 to < P85), Overweight (P85 to
< P95) or Obesity (>= P95).
reference="WHO2007" (ages 61 to 228 months) interpolates L, M and
S linearly between the two whole months around the age, as WHO
AnthroPlus, computes the z-score ((BMI / M) ** L - 1) / (L * S)
rounded to 2 decimals, and gives Severe thinness (z < -3), Thinness
(z < -2), Normal (-2 to +1), Overweight (> +1 to +2) or Obesity
(z > +2).
A null, NaN or infinite BMI, a null age, an age out of the range of the reference, or a sex that is neither sex_male_value nor sex_female_value gives null. Check the SAP for the reference and for the age rule (completed months or exact age).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
bmi_col
|
str
|
Column containing BMI in kg/m2. |
required |
age_months_col
|
str
|
Column containing age in months at the measurement (whole or decimal months). |
required |
sex_col
|
str
|
Column containing the sex code. |
required |
reference
|
Literal['CDC2000', 'WHO2007']
|
|
required |
sex_male_value
|
str
|
Value indicating male (default |
'M'
|
sex_female_value
|
str
|
Value indicating female (default |
'F'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Raises:
| Type | Description |
|---|---|
VerbUsageError
|
When reference is not |
Examples:
Classify BMI-for-age with the CDC 2000 charts::
adsl = (
adsl_raw.adam.peds
.bmi_percentile_category("BMICG", bmi_col="BMI",
age_months_col="AGEMOS",
sex_col="SEX",
reference="CDC2000")
.to_frame()
)
References
CDC NCHS, 2000 CDC growth charts, BMI-for-age LMS and percentile file
bmiagerev.csv; CDC "Child and Teen BMI Categories": < 5th, 5th to
< 85th, 85th to < 95th, >= 95th percentile.
WHO 2007 growth reference 5-19 years, BMI-for-age expanded LMS tables
(de Onis M et al. Bull World Health Organ. 2007;85:660-667): thinness
< -2 SD, severe thinness < -3 SD, overweight > +1 SD, obesity > +2 SD.
WHO anthroplus R package: linear interpolation of L, M and S, z
rounded to 2 decimals. Source files and SHA-256:
fleet/adam/data/growth/README.md. ADR-0026.
Source code in src/fleet/adam/peds_namespace.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
options: show_root_heading: true heading_level: 3 filters: ["!^_"]
Vaccine — df.adam.vaccine¶
fleet.adam.VaccineNamespace
¶
Bases: SharedADaMVerbsMixin
Immutable pipeline builder for ADaM vaccine derivations.
Inherits shared verbs from SharedADaMVerbsMixin.
Source code in src/fleet/adam/vaccine_namespace.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
fever_flag
¶
Set target to flag_value when temp_col is at or above threshold.
The default 38.0 °C is the start of grade 1 fever on the FDA 2007
toxicity grading scale, so a record of exactly 38.0 °C gets the flag.
inclusive=False flags strictly above threshold, for a SAP limit
such as FDA grade 4 (> 40.0 °C). With inclusive=False and the
default threshold, a record of 38.0 °C gets no flag.
Example::
.fever_flag("FEVFL", temp_col="TEMP")
.fever_flag("G4FEVFL", temp_col="TEMP", threshold=40.0, inclusive=False)
References
FDA, Guidance for Industry: Toxicity Grading Scale for Healthy Adult and
Adolescent Volunteers Enrolled in Preventive Vaccine Clinical Trials
(2007): grade 1 fever starts at 38.0 °C; grade 4 is > 40 °C. Brighton
Collaboration fever case definition (Marcy SM et al. Vaccine.
2004;22:551-556): >= 38.0 °C. admiralvaccine derive_fever_records:
VSSTRESN >= 38. ADR-0027.
Source code in src/fleet/adam/vaccine_namespace.py
seroconversion_flag
¶
seroconversion_flag(
target,
*,
aval_col,
base_col,
lloq_col,
fold_rise=4.0,
seronegative_fold=None,
flag_value="Y"
)
Flag seroconversion: a fold_rise rise from baseline, with an LLOQ rule.
lloq_col has no default, so the call states the rule of the SAP:
lloq_col="ISLLOQ"(two-arm rule, FDA CBER 2007): when BASE is below the LLOQ, the flag needsAVAL >= seronegative_fold × LLOQ(HI: pre < 1:10 needs post >= 1:40); when BASE is at or above the LLOQ, it needsAVAL >= fold_rise × BASE. Null when AVAL, BASE or the LLOQ is null. lloq_col must hold the LLOQ of the baseline record.lloq_col=None(plain ratio):AVAL / BASE >= fold_rise, for a SAP that states the ratio only. Null when BASE is null or zero.
Rows that do not meet the rule get null.
Example::
.seroconversion_flag("SRCONVFL", aval_col="AVAL", base_col="BASE",
lloq_col="ISLLOQ")
.seroconversion_flag("SRCONV2FL", aval_col="AVAL", base_col="BASE",
lloq_col=None, fold_rise=2.0)
References
FDA CBER, Guidance for Industry: Clinical Data Needed to Support the Licensure of Seasonal Inactivated Influenza Vaccines (2007): seroconversion is a pre-vaccination HI titre < 1:10 and a post-vaccination titre
= 1:40, or a pre-vaccination titre >= 1:10 and a >= 4-fold rise. EMA CHMP, CPMP/BWP/214/96, states the same criterion. Some SAPs use the plain ratio. ADR-0027.
Source code in src/fleet/adam/vaccine_namespace.py
seroresponse_flag
¶
Set target to flag_value when aval_col ≥ threshold.
Example::
.seroresponse_flag("SRSFL", aval_col="AVAL", threshold=40.0)
Source code in src/fleet/adam/vaccine_namespace.py
aval_adis
¶
aval_adis(
target,
*,
stresn_col="ISSTRESN",
lloq_col="ISLLOQ",
uloq_col="ISULOQ",
orres_col="ISORRES",
lloq_rule="half",
round_digits=None
)
Derive AVAL for the ADIS domain following limit-of-quantification rules.
Rules (based on admiralvaccine::derive_var_aval_adis):
- If stresn_col is missing:
- If orres_col starts with
">"and uloq_col is present → use uloq_col value. - If orres_col starts with
"<"→ use lloq_col × factor ("half"= ÷2,"lloq"= lloq_col itself). - Otherwise → null.
- If stresn_col < lloq_col → use lloq_col × factor.
- If uloq_col present and stresn_col > uloq_col → use uloq_col.
- Otherwise → use stresn_col.
lloq_rule: "half" (LLOQ ÷ 2) or "lloq" (retain LLOQ value).
Any other text raises DerivationError.
Example::
.aval_adis("AVAL", stresn_col="ISSTRESN",
lloq_col="ISLLOQ", uloq_col="ISULOQ",
orres_col="ISORRES")
References
admiralvaccine derive_var_aval_adis (pharmaverse): the rule set this
verb is based on. No CDISC standard fixes the LLOQ/2 imputation; it is an
analysis convention. Check the SAP for the rule in force.
Source code in src/fleet/adam/vaccine_namespace.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
event_flag
¶
event_flag(
target,
*,
aval_col,
cutoff,
by,
severity_col="AVALC",
severity_values=None,
flag_value="Y",
no_event_value="N"
)
Flag whether a reactogenicity event occurred at least once per by group.
A record has an event if aval_col > cutoff, or severity_col is
in severity_values (default ["Y", "MILD", "MODERATE", "SEVERE"];
[] means no value counts). Every record of a group with an event
gets flag_value. In a group with no event, a record gets
no_event_value when it shows no event (aval_col <= cutoff, or
severity_col is "N"), and null when it has no assessable data
(both missing). So a diary with only missing records gets null, not
no_event_value.
by has no default: one event must not spread to the other FAOBJ or
ATPTREF of the subject. severity_col=None uses aval_col only.
Materialises the current pipeline.
Based on admiralvaccine::derive_vars_event_flag (new_var1 behaviour).
Example::
.event_flag("EVENTFL", aval_col="AVAL", cutoff=2.5,
by=["USUBJID", "FAOBJ", "ATPTREF"])
References
admiralvaccine derive_vars_event_flag (pharmaverse), new_var1:
AVALC in Y, MILD, MODERATE, SEVERE; no default by_vars; a record
with missing AVAL and AVALC gets NA. FDA toxicity grading scale (2007)
for the severity grades. ADR-0027.
Source code in src/fleet/adam/vaccine_namespace.py
options: show_root_heading: true heading_level: 3 filters: ["!^_"]
Metabolic — df.adam.metabolic¶
fleet.adam.MetabolicNamespace
¶
Bases: SharedADaMVerbsMixin
Immutable pipeline builder for ADaM metabolic / cardiometabolic derivations.
Inherits shared verbs from SharedADaMVerbsMixin.
Source code in src/fleet/adam/metabolic_namespace.py
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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
waist_hip_ratio
¶
Derive waist-to-hip ratio: waist_col / hip_col.
Both columns must be in the same unit. A hip circumference of 0 gives null.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
waist_col
|
str
|
Column containing waist circumference. |
required |
hip_col
|
str
|
Column containing hip circumference. |
required |
round_digits
|
int | None
|
Decimal places to round to (default |
3
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive waist-to-hip ratio::
advs = (
vs_raw.adam.metabolic
.waist_hip_ratio("WAISTHIP", waist_col="WSTCIR",
hip_col="HIPCIR")
.to_frame()
)
Source code in src/fleet/adam/metabolic_namespace.py
waist_height_ratio
¶
Derive waist-to-height ratio: waist_col / height_col.
Both columns must be in the same unit. A height of 0 gives null.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
waist_col
|
str
|
Column containing waist circumference. |
required |
height_col
|
str
|
Column containing height. |
required |
round_digits
|
int | None
|
Decimal places to round to (default |
3
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive waist-to-height ratio::
advs = (
vs_raw.adam.metabolic
.waist_height_ratio("WAISTHGT", waist_col="WSTCIR",
height_col="HEIGHT")
.to_frame()
)
Source code in src/fleet/adam/metabolic_namespace.py
body_fat_pct
¶
body_fat_pct(
target,
*,
bmi_col,
age_col,
sex_col,
sex_male_value="M",
sex_female_value="F",
round_digits=1
)
Estimate body fat percentage using the Deurenberg formula.
BF% = 1.2 × BMI + 0.23 × age − 10.8 × sex_num − 5.4
where sex_num = 1 (male) or 0 (female). Any other sex value (null,
U, UNDIFFERENTIATED) gives null, because the equation has no
value for it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
bmi_col
|
str
|
Column containing BMI. |
required |
age_col
|
str
|
Column containing age in years. |
required |
sex_col
|
str
|
Column containing sex code. |
required |
sex_male_value
|
str
|
Value indicating male (default |
'M'
|
sex_female_value
|
str
|
Value indicating female (default |
'F'
|
round_digits
|
int | None
|
Decimal places to round to (default |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Estimate body fat percentage::
advs = (
vs_raw.adam.metabolic
.body_fat_pct("BFPCT", bmi_col="BMI", age_col="AGE",
sex_col="SEX")
.to_frame()
)
References
Deurenberg P, Weststrate JA, Seidell JC. Body mass index as a measure of body fatness: age- and sex-specific prediction formulas. Br J Nutr. 1991;65(2):105-114. Constants 1.2, 0.23, 10.8 and 5.4 are the adult equation; admiralmetabolic ships the same rule. CDISC CT C66731 (SEX) also holds U and UNDIFFERENTIATED, for which the equation has no value.
Source code in src/fleet/adam/metabolic_namespace.py
visceral_fat_flag
¶
visceral_fat_flag(
target,
*,
waist_col,
sex_col,
sex_male_value="M",
sex_female_value="F",
male_threshold=102.0,
female_threshold=88.0,
flag_value="Y"
)
Flag subjects with abdominal obesity by waist circumference.
Default ATP III / NCEP thresholds: male ≥ 102 cm, female ≥ 88 cm.
Any other sex value (null, U, UNDIFFERENTIATED) gets no flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output flag column. |
required |
waist_col
|
str
|
Column containing waist circumference in cm. |
required |
sex_col
|
str
|
Column containing sex code. |
required |
sex_male_value
|
str
|
Value indicating male (default |
'M'
|
sex_female_value
|
str
|
Value indicating female (default |
'F'
|
male_threshold
|
float
|
Threshold for males (default |
102.0
|
female_threshold
|
float
|
Threshold for females (default |
88.0
|
flag_value
|
str
|
Value to assign (default |
'Y'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Flag abdominal obesity::
advs = (
vs_raw.adam.metabolic
.visceral_fat_flag("ABDFL", waist_col="WSTCIR",
sex_col="SEX")
.to_frame()
)
References
Grundy SM et al. Diagnosis and management of the metabolic syndrome: an AHA/NHLBI scientific statement. Circulation. 2005;112:2735-2752: waist circumference >= 102 cm (men) and >= 88 cm (women). NCEP ATP III (2001) states the same cut-offs as strictly greater; IDF (2005) uses 94 and 80 cm for Europids. Check the SAP for the population.
Source code in src/fleet/adam/metabolic_namespace.py
bmi_category_adult
¶
Categorise an adult BMI with the WHO cut-offs.
Default classes: Underweight (< 18.5), Normal weight (18.5 to < 25.0),
Overweight (25.0 to < 30.0), Obese (>= 30.0). A null, NaN or infinite
BMI gets null. For a child, use peds.bmi_percentile_category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
bmi_col
|
str
|
Column containing the BMI value. |
required |
labels
|
dict[str, float] | None
|
Optional |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
References
WHO. Obesity: preventing and managing the global epidemic. WHO Technical
Report Series 894 (2000): adult classes at 18.5, 25.0 and 30.0 kg/m2.
admiral derive_vars_cat: a missing value gets no class.
ADR-0026: the adult rule lives in metabolic.
Examples:
Categorise an adult BMI::
adsl = (
dm_raw.adam.metabolic
.bmi_category_adult("BMICG", bmi_col="BMI")
.to_frame()
)
Source code in src/fleet/adam/metabolic_namespace.py
options: show_root_heading: true heading_level: 3 filters: ["!^_"]
Neuroscience — df.adam.neuro¶
fleet.adam.NeuroNamespace
¶
Bases: SharedADaMVerbsMixin
Immutable pipeline builder for ADaM neuroscience derivations.
Inherits shared verbs from SharedADaMVerbsMixin.
Source code in src/fleet/adam/neuro_namespace.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
centiloid
¶
centiloid(
target,
*,
suvr_col,
slope=None,
intercept=None,
tracer=None,
pipeline=None,
ref_region="Whole Cerebellum",
round_digits=2
)
Convert amyloid PET SUVR to the Centiloid scale.
Centiloid = slope * SUVR + intercept. Provide either slope and
intercept directly or tracer + pipeline for a built-in lookup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
suvr_col
|
str
|
Column containing the SUVR value. |
required |
slope
|
float | None
|
Calibration slope (provide with intercept). |
None
|
intercept
|
float | None
|
Calibration intercept. |
None
|
tracer
|
str | None
|
Tracer name for built-in lookup. |
None
|
pipeline
|
str | None
|
Pipeline name for built-in lookup. |
None
|
ref_region
|
str
|
Reference region (default |
'Whole Cerebellum'
|
round_digits
|
int | None
|
Decimal places to round to (default |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Convert SUVR to Centiloid with custom parameters::
adapet = (
pet_raw.adam.neuro
.centiloid("CLV", suvr_col="SUVR",
slope=183.07, intercept=-177.26)
.to_frame()
)
References
Klunk WE et al. The Centiloid Project: standardizing quantitative amyloid
plaque estimation by PET. Alzheimers Dement. 2015;11(1):1-15. The built-in
tracer and pipeline calibrations follow admiralneuro
derive_param_centiloid (pharmaverse).
Source code in src/fleet/adam/neuro_namespace.py
mmse_category
¶
mmse_category(
target,
*,
score_col,
normal_threshold=24,
mild_threshold=19,
moderate_threshold=10
)
Categorise MMSE total score into severity levels.
Defaults: Normal >= 24, Mild 19-23, Moderate 10-18, Severe 0-9. Each lower bound is an argument, so a SAP that uses other bands passes its own cut-offs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
score_col
|
str
|
Column containing the MMSE total score. |
required |
normal_threshold
|
int
|
Lower bound for Normal (default |
24
|
mild_threshold
|
int
|
Lower bound for Mild (default |
19
|
moderate_threshold
|
int
|
Lower bound for Moderate (default |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive MMSE category::
adcog = (
cog_raw.adam.neuro
.mmse_category("MMSECG", score_col="AVAL")
.to_frame()
)
Use the bands of a SAP that puts Mild at 21-26::
adcog = (
cog_raw.adam.neuro
.mmse_category("MMSECG", score_col="AVAL",
normal_threshold=27, mild_threshold=21)
.to_frame()
)
References
Folstein MF, Folstein SE, McHugh PR. Mini-mental state. J Psychiatr Res. 1975;12:189-198 (the instrument). Default bands: Tombaugh TN, McIntyre NJ. The Mini-Mental State Examination: a comprehensive review. J Am Geriatr Soc. 1992;40:922-935 (24-30 normal, 19-23 mild, 10-18 moderate, 9 and below severe). Other schemes are in use, for example mild 21-26 and moderate 10-20; take the cut-offs from the SAP.
Source code in src/fleet/adam/neuro_namespace.py
cdrsob_total
¶
Compute CDR Sum of Boxes (CDR-SoB) from domain box scores.
Standard domains: Memory, Orientation, Judgment, Community Affairs, Home & Hobbies, Personal Care (6 boxes, each 0–3).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
domain_cols
|
list[str]
|
List of CDR domain score columns. |
required |
round_digits
|
int | None
|
Decimal places to round to (default |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive CDR-SoB total from 6 domains::
adcog = (
cog_raw.adam.neuro
.cdrsob_total("CDRSOB", domain_cols=[
"CDRMEM", "CDRORNT", "CDRJDGM",
"CDRCOMM", "CDRHOME", "CDRPERS"])
.to_frame()
)
Source code in src/fleet/adam/neuro_namespace.py
moca_category
¶
Categorise MoCA total score into Normal / MCI / Impaired.
Defaults: Normal ≥ 26, MCI 18–25, Impaired < 18.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
score_col
|
str
|
Column containing the MoCA total score. |
required |
normal_threshold
|
int
|
Lower bound for Normal (default |
26
|
mci_threshold
|
int
|
Lower bound for MCI (default |
18
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive MoCA category::
adcog = (
cog_raw.adam.neuro
.moca_category("MOACG", score_col="AVAL")
.to_frame()
)
References
Nasreddine ZS et al. The Montreal Cognitive Assessment, MoCA. J Am Geriatr Soc. 2005;53:695-699: a total of 26 or more is normal. The MCI lower bound of 18 is not fixed by the instrument; check the SAP.
Source code in src/fleet/adam/neuro_namespace.py
panss_total
¶
Compute PANSS total = positive + negative + general subscales.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
positive_col
|
str
|
Column containing the positive subscale total. |
required |
negative_col
|
str
|
Column containing the negative subscale total. |
required |
general_col
|
str
|
Column containing the general subscale total. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive PANSS total score::
adnpi = (
npi_raw.adam.neuro
.panss_total("PANSSTOT", positive_col="PANSSPOS",
negative_col="PANSSNEG",
general_col="PANSSGEN")
.to_frame()
)
Source code in src/fleet/adam/neuro_namespace.py
options: show_root_heading: true heading_level: 3 filters: ["!^_"]
Pharmacokinetics — df.adam.pk¶
fleet.adam.PKNamespace
¶
Bases: SharedADaMVerbsMixin, MultiRowMixin
Immutable pipeline builder for PK (pharmacokinetics) derivations.
Covers concentration-time datasets such as ADPC and parameter datasets such as ADPP.
Inherits shared verbs from SharedADaMVerbsMixin
(source, derivation, assign, recode, case_when,
whereclauses, merge_adsl) and MultiRowMixin (seq), and adds
PK-specific verbs for BLQ handling, time derivation, and
dose normalisation.
Source code in src/fleet/adam/pk_namespace.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | |
blq_flag
¶
blq_flag(
target,
*,
conc_col,
lloq_col,
text_col="PCSTRESC",
blq_text=BLQ_TEXT,
numeric_below_lloq=True
)
Flag records below the LLOQ ("Y", else null).
A record is BLQ when conc_col is below lloq_col, or conc_col is
null and text_col matches blq_text ("<0.1", "BLQ").
"ALQ", ">1000" and a missed sample are not BLQ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output flag column. |
required |
conc_col
|
str
|
Numeric concentration column ( |
required |
lloq_col
|
str
|
Column containing the lower limit of quantification. |
required |
text_col
|
str | None
|
Character result column (default |
'PCSTRESC'
|
blq_text
|
str
|
Regular expression of the BLQ texts. The default
matches a text that starts with |
BLQ_TEXT
|
numeric_below_lloq
|
bool
|
Count a number below the LLOQ as BLQ
(default |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Raises:
| Type | Description |
|---|---|
DerivationError
|
When text_col is not in the frame. |
References
SDTMIG 3.4 PC (PCSTRESC holds every result as text, PCSTRESN numeric results only); ADaMIG-NCA 1.0 and ADaM popPK 1.0 BLQFL.
Examples:
Derive BLQ flag from PC data::
adpc = (
pc_raw.adam.pk
.blq_flag("BLQFL", conc_col="PCSTRESN",
lloq_col="PCLLOQ")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
blq_impute
¶
blq_impute(
target,
*,
conc_col,
lloq_col,
method="half_lloq",
text_col="PCSTRESC",
blq_text=BLQ_TEXT,
numeric_below_lloq=True
)
Impute BLQ concentrations with a standard substitution method.
BLQ follows :meth:blq_flag. Other records keep conc_col.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output numeric column. |
required |
conc_col
|
str
|
Numeric concentration column ( |
required |
lloq_col
|
str
|
Column containing the LLOQ. |
required |
method
|
str
|
One of |
'half_lloq'
|
text_col
|
str | None
|
Character result column; see :meth: |
'PCSTRESC'
|
blq_text
|
str
|
BLQ texts; see :meth: |
BLQ_TEXT
|
numeric_below_lloq
|
bool
|
See :meth: |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Raises:
| Type | Description |
|---|---|
DerivationError
|
When method is unknown or text_col is not in the frame. |
Examples:
Impute BLQ values with half the LLOQ::
adpc = (
pc_raw.adam.pk
.blq_impute("AVAL", conc_col="PCSTRESN",
lloq_col="PCLLOQ", method="half_lloq")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
nominal_time
¶
Derive nominal elapsed time from a planned timepoint column.
Applies a unit conversion from input_unit to output_unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
from_col
|
str
|
Source column of nominal time values (numeric). |
required |
input_unit
|
str
|
Unit of from_col — |
'h'
|
output_unit
|
str
|
Desired unit of target (same choices). |
'h'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Copy nominal time in hours::
adpc = (
pc_raw.adam.pk
.nominal_time("NTIME", from_col="PCTPTNUM")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
predose_flag
¶
Flag pre-dose samples within an allowable window before dosing.
Sets target to "Y" when -window_hrs <= time_col < 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output flag column. |
required |
time_col
|
str
|
Column containing elapsed time relative to dose. |
required |
window_hrs
|
float
|
Size of the pre-dose window (default |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Flag pre-dose samples within 1 hour::
adpc = (
pc_raw.adam.pk
.predose_flag("PREDFL", time_col="ATIME")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
dose_normalized
¶
Dose-normalise concentration: target = conc / dose.
Returns null when dose_col is null or zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
conc_col
|
str
|
Column containing the concentration. |
required |
dose_col
|
str
|
Column containing the administered dose. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive dose-normalised concentration::
adpc = (
pc_raw.adam.pk
.dose_normalized("AVALDNM", conc_col="AVAL",
dose_col="DOSE")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
evid
¶
Derive Event ID (EVID) for Population PK datasets.
When from_col is provided, casts and aliases it. Otherwise assigns conc_indicator to every row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column (default |
'EVID'
|
from_col
|
str | None
|
Existing integer column encoding EVID. |
None
|
conc_indicator
|
int
|
Value for concentration records (default |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Assign EVID=0 to all concentration records::
adpc = (
pc_raw.adam.pk
.evid("EVID")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
mrrlt
¶
Derive Modified Relative Time (MRRLT): max(ARRLT, 0).
Clips negative pre-dose times to zero so they align with the reference dose timepoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
arrlt_col
|
str
|
Column containing the actual relative time (ARRLT). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Clip pre-dose relative times to zero::
adpc = (
pc_raw.adam.pk
.mrrlt("MRRLT", arrlt_col="ARRLT")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
blqfn
¶
blqfn(
target,
*,
conc_col,
lloq_col,
text_col="PCSTRESC",
blq_text=BLQ_TEXT,
numeric_below_lloq=True
)
Derive a numeric BLQ flag (1 / 0).
Complements :meth:blq_flag which returns character "Y"/null;
BLQ follows the same rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
conc_col
|
str
|
Numeric concentration column ( |
required |
lloq_col
|
str
|
Column containing the LLOQ. |
required |
text_col
|
str | None
|
Character result column; see :meth: |
'PCSTRESC'
|
blq_text
|
str
|
BLQ texts; see :meth: |
BLQ_TEXT
|
numeric_below_lloq
|
bool
|
See :meth: |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Raises:
| Type | Description |
|---|---|
DerivationError
|
When text_col is not in the frame. |
Examples:
Derive numeric BLQ indicator::
adpc = (
pc_raw.adam.pk
.blqfn("BLQFN", conc_col="PCSTRESN",
lloq_col="PCLLOQ")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
log_conc
¶
Derive the logarithm of concentration.
Returns null when conc_col is null or <= 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
conc_col
|
str
|
Column containing the numeric concentration. |
required |
base
|
str
|
Logarithm base — |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive natural log of DV::
adpc = (
pc_raw.adam.pk
.log_conc("DVL", conc_col="DV")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
mdv
¶
Derive MDV (Missing Dependent Variable) for PopPK datasets.
MDV = 1 when the dependent variable is missing or the record is
a dosing record; 0 otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column (default |
'MDV'
|
conc_col
|
str | None
|
Concentration column (null → |
None
|
evid_col
|
str | None
|
Event ID column ( |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive MDV from concentration and EVID::
adpc = (
pc_raw.adam.pk
.mdv("MDV", conc_col="DV", evid_col="EVID")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
amt
¶
Derive AMT (dose amount) for PopPK / NONMEM-style datasets.
Sets target to the dose on dosing records (EVID = 1) and null
on observation records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column (default |
'AMT'
|
dose_col
|
str
|
Column containing the administered dose amount. |
required |
evid_col
|
str
|
Column containing the Event ID (default |
'EVID'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Derive AMT from the exposure dose::
adpc = (
pc_raw.adam.pk
.amt("AMT", dose_col="EXDOSE", evid_col="EVID")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
cmt
¶
Derive CMT (compartment number) for PopPK datasets.
Assigns dose_cmt on dosing records and conc_cmt on observation records, following NONMEM convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column (default |
'CMT'
|
evid_col
|
str
|
Column containing the Event ID (default |
'EVID'
|
dose_cmt
|
int
|
Compartment number for dosing records (default |
1
|
conc_cmt
|
int
|
Compartment number for concentration records (default |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Assign compartment numbers::
adpc = (
pc_raw.adam.pk
.cmt("CMT", evid_col="EVID", dose_cmt=1, conc_cmt=2)
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
avalcat
¶
avalcat(
target,
*,
conc_col,
lloq_col=None,
blq_label="BLQ",
text_col="PCSTRESC",
blq_text=BLQ_TEXT,
numeric_below_lloq=True
)
Derive a listing-ready categorised analysis value (AVALCAT1).
A BLQ record (as :meth:blq_flag) gets blq_label. Another record
gets its number as text (15 significant digits, no .0 end, so
5.0 gives "5"), else the text_col text (">1000",
"NQ"), else null (a missed sample).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output column. |
required |
conc_col
|
str
|
Concentration column (numeric, or text that holds numbers). |
required |
lloq_col
|
str | None
|
Optional LLOQ column for the numeric BLQ check. |
None
|
blq_label
|
str
|
Label for BLQ records (default |
'BLQ'
|
text_col
|
str | None
|
Character result column; see :meth: |
'PCSTRESC'
|
blq_text
|
str
|
BLQ texts; see :meth: |
BLQ_TEXT
|
numeric_below_lloq
|
bool
|
See :meth: |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Raises:
| Type | Description |
|---|---|
DerivationError
|
When text_col is not in the frame. |
Examples:
Derive AVALCAT1 from concentration and LLOQ::
adpc = (
pc_raw.adam.pk
.avalcat("AVALCAT1", conc_col="PCSTRESN",
lloq_col="PCLLOQ")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
anl_flag
¶
Derive an analysis flag variable (ANL01FL, ANL02FL, etc.).
When exclude_dtype is False (default), all records get "Y".
When True, only records with null dtype_col get "Y".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Name of the output flag column. |
required |
exclude_dtype
|
bool
|
When True, exclude DTYPE records. |
False
|
dtype_col
|
str
|
Column to inspect (default |
'DTYPE'
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The namespace with target appended. |
Examples:
Flag all records for analysis::
adpc = (
pc_raw.adam.pk
.anl_flag("ANL01FL")
.to_frame()
)
Source code in src/fleet/adam/pk_namespace.py
options: show_root_heading: true heading_level: 3 filters: ["!^_"]
Time-to-event — df.adam.tte¶
fleet.adam.TTENamespace
¶
Bases: SharedADaMVerbsMixin
Immutable pipeline builder for ADTTE (time-to-event) derivations.
Inherits shared verbs from SharedADaMVerbsMixin; each verb returns a
new TTENamespace; to_frame() materialises the result.
Source code in src/fleet/adam/tte_namespace.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
param
¶
param(
paramcd,
param=None,
*,
start,
events,
censors=None,
stop_at=None,
by=None,
set_values_to=None,
subject_keys=None,
create_datetime=False,
retain="drop",
explain=False
)
Derive one time-to-event parameter and append its rows.
Each source is a plain frame with the subject keys and ADT.
The stop date of a subject is the earliest non-null stop_at date
in ADSL; event and censor records after it are dropped. The first
event left wins: CNSR = 0 and EVNTDESC = its key. A subject
without an event is censored at the last censor record left:
CNSR = its key (on a date tie, the frame given last wins). A
subject with no record left is dropped with a warning. STARTDT
comes from ADSL (the pinned ADSL, else the base frame). An event or
censor date before it is set to it (admiral: ADT = max(ADT,
STARTDT)); the CNSR does not change. AVAL comes from :meth:aval.
A source frame may also carry EVNTDESC (censors only),
CNSDTDSC, SRCDOM, SRCVAR and SRCSEQ; they go onto the
selected row, and SRCSEQ breaks a tie on one date. A censor
frame without an EVNTDESC column gives a null EVNTDESC and a
warning that names the frame: the reason of the censoring is study
text, so Fleet does not invent it.
Without param (and without PARAM in set_values_to), PARAM is
the decode of paramcd in the study CT: the codelist of the
PARAMCD variable in the ADaM define.yaml of the first
study_config.yaml in the working directory or above it (ADTTE
first). CDISC ADaM CT has no time-to-event PARAMCD codelist. If no
decode is found, param() raises and names the places searched.
For a favorable event (admiral event_type = "positive"), censor
at the stop date: add {1: adsl.select("USUBJID",
ADT=pl.min_horizontal("EOSDT", "NACTDT"))} to censors.
The first param() call replaces the pipeline frame with the
derived rows; later calls append, so one chain builds the whole
ADTTE. STUDYID is carried from ADSL as the first column. Other ADSL
variables come from join_adsl() after the last param().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paramcd
|
str
|
PARAMCD of the new parameter. |
required |
param
|
str | None
|
PARAM label (or give PARAM in set_values_to). When neither is given, the study CT gives it (see above). |
None
|
start
|
str
|
Date column in ADSL that starts the clock ( |
required |
events
|
dict[str, DataFrame | LazyFrame]
|
|
required |
censors
|
dict[int, DataFrame | LazyFrame] | None
|
|
None
|
stop_at
|
list[str] | None
|
Date columns in ADSL. The earliest non-null one ends the observation: records after it are dropped. |
None
|
by
|
list[str] | None
|
Stratum columns, present in every source frame. Give a per-stratum PARAMCD as an expression in set_values_to. |
None
|
set_values_to
|
dict[str, Any] | None
|
Extra constant or expression columns on the new rows (PARAMN, PARCAT1, ...). A static PARAMCD with several strata raises (1:1 guard). |
None
|
subject_keys
|
list[str] | None
|
Subject identifiers (default: the ADSL pin's join
key, usually |
None
|
create_datetime
|
bool
|
Give |
False
|
retain
|
Literal['drop', 'censor_at_start']
|
|
'drop'
|
explain
|
bool
|
Log the decision trace per subject (every candidate, the selected one and the reason) through the fleet logger. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
TTENamespace |
TTENamespace
|
A fresh namespace whose frame contains the
accumulated ADTTE rows; call |
Raises:
| Type | Description |
|---|---|
DerivationError
|
On unknown columns (with did-you-mean), date columns that are not Date/Datetime, bad dict keys, PARAMCD collisions, by-group 1:1 violations, or no PARAM label. |
References
admiral 1.5 derive_param_tte (end_dates,
event_type = "negative": records after the first end date
are not used; ADT = max(ADT, STARTDT); censor_source has no
default EVNTDESC). ADaM BDS-TTE v1.0: EVNTDESC is permissible
free text with no codelist. ADaMIG v1.3: PARAM and PARAMCD map
one to one. ADR-0043
(docs/adr/0043-tte-censors-at-the-last-record-before-the-stop-date.md).
Examples:
PFS censored at the last assessment before new therapy::
last_assessment = adrs.select(
"USUBJID", "ADT", EVNTDESC=pl.lit("NO PROGRESSION"),
CNSDTDSC=pl.lit("LAST ASSESSMENT"),
)
adtte = (
adsl.adam.tte
.param(
"PFS",
"Progression-Free Survival",
start="TRTSDT",
events={"PD": adrs.filter(pl.col("AVALC") == "PD")},
censors={2: last_assessment, 3: adsl.select("USUBJID", ADT="TRTSDT")},
stop_at=["EOSDT", "NACTDT"],
)
.aval(unit="days")
.to_frame()
)
Source code in src/fleet/adam/tte_namespace.py
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 248 249 250 251 252 | |
aval
¶
Derive AVAL (and AVALU) from STARTDT/ADT.
AVAL = (ADT − STARTDT [+ 1 day]) / unit using the CDISC
conventions (7, 30.4375, 365.25 days per week/month/year). The
+ 1 inclusive convention matches admiral's
derive_vars_duration(add_one=TRUE). Each row takes its end as
the date of ADTM, else ADT, and its start as the date of
STARTDTM, else STARTDT, so one chain can mix date and
date-time parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
Literal['days', 'weeks', 'months', 'years']
|
Output unit (default |
'days'
|
add_one
|
bool
|
Include both endpoints (CDISC day convention). |
True
|
avalu
|
bool
|
Also stamp the |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
TTENamespace |
TTENamespace
|
The namespace with |
Examples:
Analysis value in months::
adtte = (
adsl.adam.tte
.param("OS", "Overall Survival", start="TRTSDT",
events={"DEATH": adsl.filter(pl.col("DTHFL") == "Y")
.select("USUBJID", ADT="DTHDT")},
censors={1: adsl.select("USUBJID", ADT="LSTALVDT",
EVNTDESC=pl.lit("ALIVE"))})
.aval(unit="months")
.to_frame()
)
Source code in src/fleet/adam/tte_namespace.py
km_data
¶
Return the (duration, event) frame survival libraries consume.
duration = AVAL and event = CNSR == 0 — exactly the inputs of
lifelines.KaplanMeierFitter.fit / scikit-survival, with optional
grouping columns carried through. No new dependency: just the shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paramcd
|
str | None
|
Restrict to one parameter (required when the frame holds several). |
None
|
by
|
list[str] | None
|
Grouping columns to carry (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: |
Raises:
| Type | Description |
|---|---|
DerivationError
|
When AVAL/CNSR are missing (call |
Examples:
Fit a KM curve per treatment arm::
km = adtte_ns.km_data("OS", by=["TRT01P"])
# lifelines: kmf.fit(km["duration"], km["event"])
Source code in src/fleet/adam/tte_namespace.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
options: show_root_heading: true heading_level: 3 filters: ["!^_"]
fleet.adam.tte
¶
Time-to-event (ADTTE) selection engine behind df.adam.tte.param().
Each event or censor source is a plain Polars frame with the subject keys and
an ADT column. :func:select_tte selects one record per subject: the
first event on or before the first stop date (CNSR = 0), else the last
censor record on or before it (CNSR = the key of its frame). It also
returns a decision trace that tells why each record was selected.
param_label
¶
Return the PARAM of paramcd from the study's controlled terminology.
The study is the first study_config.yaml in the working directory
or above it. The label is the decode of the paramcd item in a
codelist that a PARAMCD variable of the ADaM define.yaml
references (the domain dataset first, then the others). fleet init
ct writes the CDISC CT preferred terms as these decodes, so a PARAMCD
in a pinned CDISC CT codelist resolves here too.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paramcd
|
str
|
The parameter code, for example |
required |
domain
|
str
|
The dataset whose |
'ADTTE'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The decode, for example |
Raises:
| Type | Description |
|---|---|
DerivationError
|
When no source gives a label. The message names
paramcd, the places searched and the fix ( |
References
ADaMIG v1.3, BDS analysis parameter variables: PARAM and PARAMCD map one to one. CDISC ADaM CT (NCI EVS) has no time-to-event PARAMCD codelist; its parameter codelists are questionnaire and scale codes. ADR-0043.
Examples:
The label of OS in a study whose ADTTE.PARAMCD has a codelist::
label = param_label("OS") # "Overall Survival"
Source code in src/fleet/adam/tte.py
select_tte
¶
select_tte(
*,
universe,
start,
events,
censors,
subject_keys,
stop_at=None,
by=None,
create_datetime=False,
retain="drop"
)
Select one time-to-event record per subject (per stratum).
The stop date of a subject is the earliest non-null stop_at date in
universe. Event and censor records after it are dropped. The first
event left wins (CNSR = 0, EVNTDESC = its key). A subject
without an event takes the last censor record left (CNSR = its
key); on a date tie the censor frame given last wins. An event or
censor date before the start date is set to the start date; the CNSR
does not change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
universe
|
DataFrame
|
Subject-level frame (ADSL) with start, stop_at and the subject keys. |
required |
start
|
str
|
Date column in universe that starts the clock
( |
required |
events
|
dict[str, DataFrame | LazyFrame]
|
|
required |
censors
|
dict[int, DataFrame | LazyFrame]
|
|
required |
subject_keys
|
list[str]
|
Subject identifier columns (usually |
required |
stop_at
|
list[str] | None
|
Date columns in universe; the earliest non-null one ends the observation of the subject. |
None
|
by
|
list[str] | None
|
Stratum columns, present in every source frame. |
None
|
create_datetime
|
bool
|
Give |
False
|
retain
|
Literal['drop', 'censor_at_start']
|
|
'drop'
|
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, DataFrame]
|
tuple[pl.DataFrame, pl.DataFrame]: The selected rows, and the
decision trace (one row per candidate: |
Raises:
| Type | Description |
|---|---|
DerivationError
|
On a missing column (with a did-you-mean hint), a date column that is not Date/Datetime, or a bad dict key. |
References
admiral 1.5 derive_param_tte (end_dates,
event_type = "negative"); ADR-0043
(docs/adr/0043-tte-censors-at-the-last-record-before-the-stop-date.md).
Examples:
PFS, censored at the last assessment before new therapy::
rows, trace = select_tte(
universe=adsl,
start="TRTSDT",
events={"PD": adrs.filter(pl.col("AVALC") == "PD")},
censors={2: adrs.select("USUBJID", "ADT")},
subject_keys=["USUBJID"],
stop_at=["EOSDT", "NACTDT"],
)
Source code in src/fleet/adam/tte.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
options: show_root_heading: true heading_level: 3 members_order: source show_source: false