Skip to content
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

Merged
merged 2 commits into from
Jun 11, 2019
Merged

Fix 104 2 #106

merged 2 commits into from
Jun 11, 2019

Conversation

finlaycampbell
Copy link
Collaborator

  • 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

@zkamvar zkamvar requested review from nistara and zkamvar June 6, 2019 14:54
@zkamvar
Copy link
Member

zkamvar commented Jun 6, 2019

Note that this will fix #104 and #100

Copy link
Member

@zkamvar zkamvar left a 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)

@nistara
Copy link
Member

nistara commented Jun 8, 2019

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.

@zkamvar
Copy link
Member

zkamvar commented Jun 10, 2019

@finlaycampbell, merge when ready.

@finlaycampbell finlaycampbell merged commit 7f5f401 into master Jun 11, 2019
@finlaycampbell finlaycampbell temporarily deployed to github-pages June 11, 2019 08:41 Inactive
@finlaycampbell finlaycampbell deleted the fix-104-2 branch April 28, 2020 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants