Skip to content

Commit 9609208

Browse files
committed
refactor: calculate days after the first sample consistently
1 parent 28d55d2 commit 9609208

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

workflow/scripts/calculate_dnds.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ variants <- read_delim(
2929
log_info("Reading metadata table")
3030
metadata <- read_delim(snakemake@input[["metadata"]]) %>%
3131
mutate(
32-
interval = as.numeric(
33-
as.Date(CollectionDate) - min(as.Date(CollectionDate))
34-
)
32+
interval = difftime(
33+
as.Date(CollectionDate),
34+
min(as.Date(CollectionDate)),
35+
units = "days"
36+
) |> as.numeric()
3537
) %>%
3638
select(ID, interval) %>%
3739
rename(SAMPLE = ID)

workflow/scripts/report/time_signal_data.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ time.signal <- distRoot(
4444
by = "ID"
4545
) %>%
4646
mutate(
47-
date_interval = as.numeric(
48-
as.Date(CollectionDate) - min(as.Date(CollectionDate))
49-
)
47+
date_interval = difftime(
48+
as.Date(CollectionDate),
49+
min(as.Date(CollectionDate)),
50+
units = "days"
51+
) |> as.numeric()
5052
)
5153

5254
# Save table

0 commit comments

Comments
 (0)