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

Temporal Axis Error #130

Closed
Dhihram opened this issue May 8, 2022 · 12 comments
Closed

Temporal Axis Error #130

Dhihram opened this issue May 8, 2022 · 12 comments

Comments

@Dhihram
Copy link

Dhihram commented May 8, 2022

No description provided.

@Dhihram
Copy link
Author

Dhihram commented May 8, 2022

Hi, I ever utilized the temporal axis for transmission chain in https://epirhandbook.com/en/transmission-chains.html for several months ago. However, today I utilized the same command
plot(
sub,
x_axis = "date_onset",
node_color = "outcome",
col_pal = c(Death = "firebrick", Recover = "green"),
arrow_size = 0.5,
node_size = 13,
label = FALSE,
height = 700,
width = 700
)
and It was error. How to solve this problem. Thank you.

@Dhihram
Copy link
Author

Dhihram commented May 8, 2022

Fyi, I was using pacman::p_install_gh("reconhub/epicontacts@timeline") for the temporal axis.

@finlaycampbell
Copy link
Collaborator

Hi Dhihram - thanks for pointing that out. I just pushed an update that might fix the issue, could you re-download the package and let me know if it works now?

@Dhihram
Copy link
Author

Dhihram commented May 13, 2022

Hi Mr. Campbell, several days ago I have installed reconhub/epicontacts@ttree and its work. Thank you.

@finlaycampbell
Copy link
Collaborator

The timeline branch is more updated and is stable (and should hopefully work now) so I would suggest installing that!

@Dhihram
Copy link
Author

Dhihram commented May 13, 2022

thank you

@mllstrm
Copy link

mllstrm commented Mar 22, 2023

Hi! I have a similar problem with the x_axis.

This error always comes up when I try to do a temporal axis om the transmission chain:

"Error in fix.by(by.x, x) : 'by' must specify uniquely valid columns"

Example code:

library(outbreaks)
library(epicontacts)

head(mers_korea_2015[[1]])
head(mers_korea_2015[[2]])

x <- make_epicontacts(linelist=mers_korea_2015[[1]],
contacts = mers_korea_2015[[2]],
directed=TRUE)

vis_epicontacts(x, x_axis = "dt_onset", thin = FALSE)

How do I solve this?

@finlaycampbell
Copy link
Collaborator

Hi - sorry for the delay in replying to this, I was out of office for a long time.

This is a mysterious error and one I still can't replicate on my end. Could you print the output from the following commands, which might help in tracking down the error (running your example code above first)?

nodes <- data.frame(id = get_id(x, "all"), stringsAsFactors = FALSE)
head(nodes)

head(x$linelist)

nodes <- merge(nodes, x$linelist, by = "id", all = TRUE, sort = FALSE)

Thanks!

@nistara
Copy link
Member

nistara commented Mar 29, 2023

Hey Finlay,

This is what I got when I ran your code:

>     id
1 SK_1
2 SK_2
3 SK_3
4 SK_4
5 SK_5
6 SK_6
> >     id age age_class sex        place_infect reporting_ctry
1 SK_1  68     60-69   M         Middle East    South Korea
2 SK_2  63     60-69   F Outside Middle East    South Korea
3 SK_3  76     70-79   M Outside Middle East    South Korea
4 SK_4  46     40-49   F Outside Middle East    South Korea
5 SK_5  50     50-59   M Outside Middle East    South Korea
6 SK_6  71     70-79   M Outside Middle East    South Korea
                                             loc_hosp   dt_onset  dt_report
1 Pyeongtaek St. Mary, Hospital, Pyeongtaek, Gyeonggi 2015-05-11 2015-05-19
2 Pyeongtaek St. Mary, Hospital, Pyeongtaek, Gyeonggi 2015-05-18 2015-05-20
3 Pyeongtaek St. Mary, Hospital, Pyeongtaek, Gyeonggi 2015-05-20 2015-05-20
4 Pyeongtaek St. Mary, Hospital, Pyeongtaek, Gyeonggi 2015-05-25 2015-05-26
5                           365 Yeollin Clinic, Seoul 2015-05-25 2015-05-27
6 Pyeongtaek St. Mary, Hospital, Pyeongtaek, Gyeonggi 2015-05-24 2015-05-28
  week_report dt_start_exp dt_end_exp    dt_diag outcome   dt_death
1     2015_21   2015-04-18 2015-05-04 2015-05-20   Alive       <NA>
2     2015_21   2015-05-15 2015-05-20 2015-05-20   Alive       <NA>
3     2015_21   2015-05-16 2015-05-16 2015-05-21    Dead 2015-06-04
4     2015_22   2015-05-16 2015-05-20 2015-05-26   Alive       <NA>
5     2015_22   2015-05-17 2015-05-17 2015-05-26   Alive       <NA>
6     2015_22   2015-05-15 2015-05-17 2015-05-28    Dead 2015-06-01

I think the error's coming from this line in the vis_epicontacts' code. At least, that's where I came across it when I tried to rerun the function code.

@finlaycampbell
Copy link
Collaborator

Hi everyone, I see what the issue is - the x_axis feature is only available on the timeline development branch of epicontacts, but there was still a relic of the old code hidden in the CRAN version that I didn't realise existed, hence the error instead of a warning message telling you to install the correct version. You can install it using remotes::install_github("reconhub/epicontacts@timeline"), let me know if that works.

I've pushed a fix to the main branch to throw a more informative error. Apologies for the confusion, I thought we were all talking about the same version!

@mllstrm
Copy link

mllstrm commented Mar 31, 2023

Hi! I have been away from keybord a couple of days. I installed the new version; remotes::install_github("reconhub/epicontacts@timeline") and it works after that! Thanks!

But I have to use plot-argument to get the x-axis to work, vis_epicontacs does not arrange the network along the x-axis.

The same code again:

`library(outbreaks)
library(epicontacts)

head(mers_korea_2015[[1]])
head(mers_korea_2015[[2]])

x <- make_epicontacts(linelist=mers_korea_2015[[1]],
contacts = mers_korea_2015[[2]],
directed=TRUE)

vis_epicontacts(x, x_axis = "dt_onset", thin = FALSE)

plot(x, x_axis = "dt_onset", thin = FALSE)`

This is the result from plot(x, x_axis = "dt_onset", thin = FALSE) :
image

And this is the result from vis_epicontacts(x, x_axis = "dt_onset", thin = FALSE)
image

Thanks again! I wish you all trevlig helg (a realy nice weekend in Swedish)

@finlaycampbell
Copy link
Collaborator

Great, glad to hear it works!

Yes, vis_epicontacts is not really supposed to be called directly, as it only plots the free network without the axis. The plot function makes sure the appropriate plotting method is called depending on the function arguments.

Wish you a trevlig helg too!

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

No branches or pull requests

4 participants