-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 104 2 #106
Fix 104 2 #106
Conversation
finlaycampbell
commented
Jun 6, 2019
- no longer going from epicontacts -> igraph -> epicontacts which was causing a bunch of issues
- using the native square bracket subsetting instead and keeping all linelist and contact elements associated with a given cluster
- using 'either' not 'both' so that all contact elements of interested are returned, even if one of them is not in the linelist
- added functional tests to ensure the correct clusters are being returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests work now and it is much easier to follow the logic of the tests for subsetting.
It should note that this also fixes #100:
library(epicontacts)
library(outbreaks)
x <- make_epicontacts(ebola_sim$linelist, ebola_sim$contacts,
id="case_id", to="case_id", from="infector",
directed=TRUE)
x
#>
#> /// Epidemiological Contacts //
#>
#> // class: epicontacts
#> // 5,888 cases in linelist; 3,800 contacts; directed
#>
#> // linelist
#>
#> # A tibble: 5,888 x 11
#> id generation date_of_infecti… date_of_onset date_of_hospita…
#> <chr> <int> <date> <date> <date>
#> 1 d1fa… 0 NA 2014-04-07 2014-04-17
#> 2 5337… 1 2014-04-09 2014-04-15 2014-04-20
#> 3 f5c3… 1 2014-04-18 2014-04-21 2014-04-25
#> 4 6c28… 2 NA 2014-04-27 2014-04-27
#> 5 0f58… 2 2014-04-22 2014-04-26 2014-04-29
#> 6 4973… 0 2014-03-19 2014-04-25 2014-05-02
#> 7 f914… 3 NA 2014-05-03 2014-05-04
#> 8 881b… 3 2014-04-26 2014-05-01 2014-05-05
#> 9 e66f… 2 NA 2014-04-21 2014-05-06
#> 10 20b6… 3 NA 2014-05-05 2014-05-06
#> # … with 5,878 more rows, and 6 more variables: date_of_outcome <date>,
#> # outcome <fct>, gender <fct>, hospital <fct>, lon <dbl>, lat <dbl>
#>
#> // contacts
#>
#> # A tibble: 3,800 x 3
#> from to source
#> <chr> <chr> <fct>
#> 1 d1fafd 53371b other
#> 2 cac51e f5c3d8 funeral
#> 3 f5c3d8 0f58c4 other
#> 4 0f58c4 881bd4 other
#> 5 8508df 40ae5f other
#> 6 127d83 f547d6 funeral
#> 7 f5c3d8 d58402 other
#> 8 20b688 d8a13d other
#> 9 2ae019 a3c8b8 other
#> 10 20b688 974bc1 other
#> # … with 3,790 more rows
id <- "cac51e" ## it can be a vector of id as well
## subset based on cluster to which "cac51e" belongs
x_subset <- subset_clusters_by_id(x, id)
x_subset
#>
#> /// Epidemiological Contacts //
#>
#> // class: epicontacts
#> // 5 cases in linelist; 5 contacts; directed
#>
#> // linelist
#>
#> # A tibble: 5 x 11
#> id generation date_of_infecti… date_of_onset date_of_hospita…
#> <chr> <int> <date> <date> <date>
#> 1 f5c3… 1 2014-04-18 2014-04-21 2014-04-25
#> 2 0f58… 2 2014-04-22 2014-04-26 2014-04-29
#> 3 881b… 3 2014-04-26 2014-05-01 2014-05-05
#> 4 d584… 2 2014-04-23 2014-05-01 2014-05-10
#> 5 9000… 3 2014-05-09 2014-05-14 2014-05-17
#> # … with 6 more variables: date_of_outcome <date>, outcome <fct>,
#> # gender <fct>, hospital <fct>, lon <dbl>, lat <dbl>
#>
#> // contacts
#>
#> # A tibble: 5 x 3
#> from to source
#> <chr> <chr> <fct>
#> 1 cac51e f5c3d8 funeral
#> 2 f5c3d8 0f58c4 other
#> 3 0f58c4 881bd4 other
#> 4 f5c3d8 d58402 other
#> 5 d58402 900021 other
Created on 2019-06-06 by the reprex package (v0.3.0)
Hi, I'm in the middle of hosting a workshop right now, so please go ahead and make the changes you think will fix things. This bug may/may not be related as well: #97 which I'd worked on fixing a while ago. |
@finlaycampbell, merge when ready. |