Draws one row per subject and one point per collection event (or per aliquot), placed at its collection date, so you can see at a glance how often and how regularly each subject was sampled, which sample types were collected, and when. Each row is labelled with the subject and its number of collection events (or aliquots).
Arguments
- data
LIMS report(s), in any form
lims_aggregate()reads, or the aliquot-level output oflims_aggregate().- unit
"collection_event"(the default) or"aliquot": what each point is, and what each subject's label counts.- color_var
What the point colours show: a level or column (see Details);
"sample_type"by default.NULLgives each subject its own colour, with no legend.- color_label
Legend title for the colours. Defaults to the column name, tidied (
"sample_type"becomes "Sample type").- shape_var
Optional level or column shown by point shape (at most five values), e.g.
"aliquot_type".- facet_var
Optional level or column to split the timeline into panels, one above the other, e.g.
"study"or"sample_type". Each panel shows only its own subjects, and its height follows their number.- x_axis
What the x axis shows:
"subject-day"(the default)days since each subject's first collection, so every subject starts at day 0.
"study-day"days since the first collection in
data, across all subjects, so each subject starts on the day they entered."calendar-day"calendar dates.
Can be abbreviated, e.g.
"study".- show_counts
If
TRUE(the default), each subject's label includes its number of collection events (or aliquots).- size_by_aliquots
If
TRUE, point size shows each point's number of aliquots.- point_size
Size of the points (the largest size, with
size_by_aliquots = TRUE).- palette
A viridis palette option (
"turbo","viridis","magma", ...) for the point colours.- ...
Column arguments passed to
lims_aggregate()whendatais a report, e.g.subject_col = "Participant".
Value
A ggplot object. Add to or modify it as usual, and save it with
ggplot2::ggsave().
Details
data is read with lims_aggregate(), so it can be one or more LIMS
reports (paths, a directory or data frames) or the aliquot-level output
of lims_aggregate(); aliquots listed in more than one report count
once.
Points. With unit = "collection_event" (the default), each point is
a collection event: one subject, sample type and collection date,
however many aliquots it was split into. size_by_aliquots = TRUE
scales each point by its number of aliquots. With unit = "aliquot",
each aliquot is its own point. A collection event whose aliquots differ
in the variable shown by colour, shape or panel (for example a swab from
which two species were cultured, with color_var = "microbial_species")
is drawn as one point for each value. Points from the same subject and
day are spread out vertically so that none is hidden.
Colours, shapes and panels. color_var, shape_var and facet_var
take a level or column of the aliquot table: "sample_type",
"aliquot_type" (e.g. the specimen itself, its DNA, or an isolate),
"microbial_species" (isolates coloured by species, aliquots without a
species in grey), "study", or any other column, such as a subject
feature you have joined to the report (treatment arm, outcome). Numeric
columns get a continuous colour scale. With a facet, a subject has a row
in each panel it has points in.
Aliquots whose subject or collection date is missing are left out, with a warning.
Examples
# collection events, coloured by sample type
lims_timeline(lims_example("gol"))
# both studies, one panel each, on the calendar
lims_timeline(lims_example(), facet_var = "study",
x_axis = "calendar-day")
# sized by number of aliquots
lims_timeline(lims_example("facemdro"), size_by_aliquots = TRUE)
# isolates with a species, coloured by species
fac <- lims_aggregate(lims_example("facemdro"))
lims_timeline(fac[!is.na(fac$microbial_species), ], unit = "aliquot",
color_var = "microbial_species")