Last updated: 2022-01-24

Checks: 7 0

Knit directory: genes-to-foodweb-stability/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200205) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 18d1722. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    code/.Rhistory
    Ignored:    output/.Rapp.history

Untracked files:
    Untracked:  output/all.mar1.brm.adj.rds
    Untracked:  output/all.mar1.brm.unadj.ar2.lag.rds
    Untracked:  output/all.mar1.brm.unadj.noBRBRonLYER.rds
    Untracked:  output/all.mar1.brm.unadj.rds
    Untracked:  output/all.mar1.brm.unadj.xAOP2.rds
    Untracked:  output/initial.mar1.brm.adj.rds
    Untracked:  output/initial.mar1.brm.unadj.rds

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/foodweb-transitions.Rmd) and HTML (docs/foodweb-transitions.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
html c802852 mabarbour 2021-06-24 Build website
Rmd a054471 mabarbour 2021-06-24 Update location of .rds files to Release v2.1
Rmd f467085 mabarbour 2021-06-24 Revise analysis to address reviewer’s comments

Wrangle data

# Load and manage data
df <- read_csv("data/InsectAbundanceSurvival.csv") %>%
  # renaming for brevity
  rename(cage = Cage, 
         com = Composition,
         week = Week,
         temp = Temperature,
         rich = Richness) %>%
  mutate(cage = as.character(cage),
         fweek = factor(ifelse(week < 10, paste("0", week, sep=""), week)),
         temp = ifelse(temp=="20 C", 0, 1)) %>%
  arrange(cage, week)

# create data for multi-state survival analysis
state_df <- df %>%
  # counter information is not relevant (because it is the same), so we summarise across it
  group_by(cage, fweek, week, temp, rich, Col, gsm1, AOP2, AOP2.gsoh, com) %>% 
  summarise_at(vars(BRBR_Survival, LYER_Survival, Mummy_Ptoids_Survival), list(mean)) %>% 
  ungroup() %>%
  # create possible food-web states
  mutate(BRBR = ifelse(BRBR_Survival == 1, "BRBR", ifelse(BRBR_Survival == 0, "0", NA)),
         LYER = ifelse(LYER_Survival == 1, "LYER", ifelse(LYER_Survival == 0, "0", NA)),
         Ptoid = ifelse(Mummy_Ptoids_Survival == 1, "Ptoid", ifelse(Mummy_Ptoids_Survival == 0, "0", NA))) %>%
  mutate(state = paste(BRBR, LYER, Ptoid, sep = "-"),
         cage = as.character(cage)) %>%
  # these variables are no longer needed
  select(-BRBR, -LYER, -Ptoid) %>%
  # remove all instances where all species have been labelled extinct for more than 1 week "NA-NA-NA".
  # also, only keep observations after 2 weeks when we added the parasitoid (full community)
  filter(state != "NA-NA-NA", week > 2) %>%
  mutate(week_since = week - 2) 

# replace NA with zeros for state variable
state_df$state <- gsub("NA","0", state_df$state)

# everything appears in order
arrange(state_df, cage, week_since) %>% select(cage, week_since, BRBR_Survival, LYER_Survival, Mummy_Ptoids_Survival, state) 
# A tibble: 710 × 6
   cage  week_since BRBR_Survival LYER_Survival Mummy_Ptoids_Survival state     
   <chr>      <dbl>         <dbl>         <dbl>                 <dbl> <chr>     
 1 1              1             1             1                     1 BRBR-LYER…
 2 1              2             1             1                     1 BRBR-LYER…
 3 1              3             1             1                     1 BRBR-LYER…
 4 1              4             1             1                     1 BRBR-LYER…
 5 1              5             0             0                     1 0-0-Ptoid 
 6 1              6            NA            NA                     0 0-0-0     
 7 10             1             1             1                     1 BRBR-LYER…
 8 10             2             1             1                     1 BRBR-LYER…
 9 10             3             1             1                     1 BRBR-LYER…
10 10             4             1             1                     1 BRBR-LYER…
# … with 700 more rows

Multi-state Markov model with msm

# state transitions for all cages and time points
msm::statetable.msm(state = state, subject = cage, data = state_df)
                 to
from              0-0-0 0-0-Ptoid 0-LYER-0 0-LYER-Ptoid BRBR-LYER-Ptoid
  0-0-Ptoid          22         7        0            0               0
  0-LYER-0            1         0      129            0               0
  0-LYER-Ptoid        5        12       25          245               0
  BRBR-LYER-Ptoid     0        10        0           50             144
# turn state into numeric values, which is necessary for the analysis
state_df$state_type <- with(state_df, ifelse(state == "BRBR-LYER-Ptoid", 1,
                                             ifelse(state == "0-LYER-Ptoid", 2,
                                                    ifelse(state == "0-LYER-0", 3,
                                                           ifelse(state == "0-0-Ptoid", 4,
                                                                  ifelse(state == "0-0-0", 5, NA))))))
# no NAs
which(is.na(state_df$state_type) == T)
integer(0)
# inspect states
statetable.msm(state = state_type, subject = cage, data = state_df)
    to
from   1   2   3   4   5
   1 144  50   0  10   0
   2   0 245  25  12   5
   3   0   0 129   0   1
   4   0   0   0   7  22
# specify allowed transitions
Q <- rbind(c(0,1,0,1,0),
           c(0,0,1,1,0),
           c(0,0,0,0,1), 
           c(0,0,0,0,1), 
           c(0,0,0,0,0))

# give informative labels
rownames(Q) <- colnames(Q) <- c("1-1-1","0-1-1","0-1-0","0-0-1","0-0-0")

# everything appears in order
Q
      1-1-1 0-1-1 0-1-0 0-0-1 0-0-0
1-1-1     0     1     0     1     0
0-1-1     0     0     1     1     0
0-1-0     0     0     0     0     1
0-0-1     0     0     0     0     1
0-0-0     0     0     0     0     0
# we use this initial transition matrix by specifying "gen.inits = T" in msm model
crudeinits.msm(state_type ~ week_since, subject = cage, data = state_df, qmatrix = Q)
           1-1-1      0-1-1        0-1-0       0-0-1       0-0-0
1-1-1 -0.2941176  0.2450980  0.000000000  0.04901961 0.000000000
0-1-1  0.0000000 -0.1289199  0.087108014  0.04181185 0.000000000
0-1-0  0.0000000  0.0000000 -0.007692308  0.00000000 0.007692308
0-0-1  0.0000000  0.0000000  0.000000000 -0.75862069 0.758620690
0-0-0  0.0000000  0.0000000  0.000000000  0.00000000 0.000000000
# fit model
AOP2_foodweb.msm <- msm(state_type ~ week_since, 
                         subject = cage, 
                         data = state_df, 
                         qmatrix = Q, 
                         gen.inits = TRUE,
                         # for "3-5" (aphid alone to collapse) and "4-5" (ptoid alone to collapse), 
                         # I don't expect there to be any genetic effects, because the aphid alone 
                         # will likely persist regardless of plant genetics. similarly, a parasitoid
                         # population without any aphids will inevitably go extinct. 
                          covariates = list("1-2" =~ I(Col+gsm1) + I(AOP2+AOP2.gsoh),
                                            "1-4" =~ I(Col+gsm1) + I(AOP2+AOP2.gsoh),
                                            "2-3" =~ I(Col+gsm1) + I(AOP2+AOP2.gsoh),
                                            "2-4" =~ I(Col+gsm1) + I(AOP2+AOP2.gsoh)),
                          obstype = 1)

# hazard ratios for each food-web transition
hazard.msm(AOP2_foodweb.msm)
$`I(Col + gsm1)`
                     HR         L         U
1-1-1 - 0-1-1 0.9441871 0.6251596 1.4260188
1-1-1 - 0-0-1 0.9221935 0.2982043 2.8518729
0-1-1 - 0-1-0 0.8436281 0.4622919 1.5395217
0-1-1 - 0-0-1 0.3266901 0.1466822 0.7276028
0-1-0 - 0-0-0 1.0000000 1.0000000 1.0000000
0-0-1 - 0-0-0 1.0000000 1.0000000 1.0000000

$`I(AOP2 + AOP2.gsoh)`
                     HR         L        U
1-1-1 - 0-1-1 0.9732280 0.6506217 1.455796
1-1-1 - 0-0-1 1.2267487 0.3884284 3.874362
0-1-1 - 0-1-0 0.8512696 0.4646743 1.559501
0-1-1 - 0-0-1 0.7404948 0.2924983 1.874653
0-1-0 - 0-0-0 1.0000000 1.0000000 1.000000
0-0-1 - 0-0-0 1.0000000 1.0000000 1.000000

Reproduce Fig. S4

# for coxph analysis (multistate), this may not be completely necessary
AJ_state_df <- state_df %>%
  # convert Ptoid only state to collapsed state, which is inevitable
  mutate(state_adj = ifelse(state == "0-0-Ptoid", "0-0-0", state)) %>%
  # convert state into a factor for analysis
  mutate(fstate = factor(state_adj, levels = c("BRBR-LYER-Ptoid","0-LYER-Ptoid","0-LYER-0","0-0-0"))) %>%
  mutate(rich_temp = paste(rich, temp, sep = "_")) %>%
  mutate(aop2_genotypes = factor(Col+gsm1, levels = c(0,1,2), labels = c("AOP2\u2013 = 0", "AOP2\u2013 = 1", "AOP2\u2013 = 2")))

# get food-web transitions as a function of number of aop2 genotypes
aop2_AJ <- survfit(Surv(I(week_since-1), week_since, fstate) ~ aop2_genotypes, data = AJ_state_df, id = cage)
tidy_aop2_AJ <- tidy(aop2_AJ)
tidy_aop2_AJ$strata <- sub(pattern = "aop2_genotypes=", replacement = "", x = tidy_aop2_AJ$strata)

# plot
plot_aop2_genotypes_multistate <- ggplot(tidy_aop2_AJ, aes(x = time + 2, y = estimate)) +
  geom_area(aes(fill = state)) +
  facet_wrap(~strata) +
  scale_fill_viridis_d(name = "Food-web state", labels = c("Arabidopsis only","Aphid only","Food chain","Initial")) +
  xlab("Week of experiment") +
  ylab("Proportion")
x11(); plot_aop2_genotypes_multistate
#ggsave(plot = plot_aop2_genotypes_multistate, filename = "figures/aop2-genotypes-multistate.pdf", width = 6, height = 5, device=cairo_pdf)

Version Author Date
c802852 mabarbour 2021-06-24

Assess robustness of AOP2 effect on food chain persistence

## Organize data for analysis

# LYER-Ptoid cages at least at one time point
LP_cages <- unique(filter(state_df, state == "0-LYER-Ptoid")$cage)
# should be 50 cages, and it is
length(LP_cages)
[1] 50
# filter and manage data
LP_transit_df <- state_df %>% 
  filter(cage %in% LP_cages, state != "BRBR-LYER-Ptoid") %>%
  # omit BRBR from consideration
  select(-BRBR_Survival) %>% 
  # omit rows where we already know either LYER or Ptoid went extinct
  na.omit() %>% 
  mutate(# assume these two states are the same, i.e. to get to 0-0-0, had to go through 0-0-Ptoid
         state_adj = ifelse(state %in% c("0-0-Ptoid","0-0-0"), "0-0-Ptoid", state))

# confirm levels
unique(LP_transit_df$state_adj) #fstate)
[1] "0-LYER-Ptoid" "0-LYER-0"     "0-0-Ptoid"   
# get start times after BRBR went extinct
get_LP_transit_start <- LP_transit_df %>%
  group_by(cage) %>%
  arrange(week_since) %>%
  mutate(start = first(week_since)) 

# all looks in order
get_LP_transit_start %>% arrange(cage) %>% data.frame()
    cage fweek week temp rich Col gsm1 AOP2 AOP2.gsoh            com
1     12    07    7    0    4   1    1    1         1           Poly
2     12    08    8    0    4   1    1    1         1           Poly
3     12    09    9    0    4   1    1    1         1           Poly
4     12    10   10    0    4   1    1    1         1           Poly
5     12    11   11    0    4   1    1    1         1           Poly
6     12    12   12    0    4   1    1    1         1           Poly
7     12    13   13    0    4   1    1    1         1           Poly
8     12    14   14    0    4   1    1    1         1           Poly
9     12    15   15    0    4   1    1    1         1           Poly
10    12    16   16    0    4   1    1    1         1           Poly
11    12    17   17    0    4   1    1    1         1           Poly
12    13    06    6    0    4   1    1    1         1           Poly
13    13    07    7    0    4   1    1    1         1           Poly
14    13    08    8    0    4   1    1    1         1           Poly
15    13    09    9    0    4   1    1    1         1           Poly
16    13    10   10    0    4   1    1    1         1           Poly
17    13    11   11    0    4   1    1    1         1           Poly
18    13    12   12    0    4   1    1    1         1           Poly
19    13    13   13    0    4   1    1    1         1           Poly
20    13    14   14    0    4   1    1    1         1           Poly
21    13    15   15    0    4   1    1    1         1           Poly
22    13    16   16    0    4   1    1    1         1           Poly
23    13    17   17    0    4   1    1    1         1           Poly
24    14    08    8    0    1   1    0    0         0            Col
25    14    09    9    0    1   1    0    0         0            Col
26    14    10   10    0    1   1    0    0         0            Col
27    15    07    7    0    1   0    0    0         1      AOP2.gsoh
28    15    08    8    0    1   0    0    0         1      AOP2.gsoh
29    15    09    9    0    1   0    0    0         1      AOP2.gsoh
30    15    10   10    0    1   0    0    0         1      AOP2.gsoh
31    15    11   11    0    1   0    0    0         1      AOP2.gsoh
32    15    12   12    0    1   0    0    0         1      AOP2.gsoh
33    15    13   13    0    1   0    0    0         1      AOP2.gsoh
34    15    14   14    0    1   0    0    0         1      AOP2.gsoh
35    15    15   15    0    1   0    0    0         1      AOP2.gsoh
36    17    08    8    0    2   0    1    1         0      gsm1_AOP2
37    17    09    9    0    2   0    1    1         0      gsm1_AOP2
38    18    07    7    0    2   1    0    0         1  Col_AOP2.gsoh
39    18    08    8    0    2   1    0    0         1  Col_AOP2.gsoh
40    18    09    9    0    2   1    0    0         1  Col_AOP2.gsoh
41    18    10   10    0    2   1    0    0         1  Col_AOP2.gsoh
42    18    11   11    0    2   1    0    0         1  Col_AOP2.gsoh
43    18    12   12    0    2   1    0    0         1  Col_AOP2.gsoh
44    18    13   13    0    2   1    0    0         1  Col_AOP2.gsoh
45    18    14   14    0    2   1    0    0         1  Col_AOP2.gsoh
46    18    15   15    0    2   1    0    0         1  Col_AOP2.gsoh
47    18    16   16    0    2   1    0    0         1  Col_AOP2.gsoh
48    20    07    7    0    2   0    1    1         0      gsm1_AOP2
49    20    08    8    0    2   0    1    1         0      gsm1_AOP2
50    20    09    9    0    2   0    1    1         0      gsm1_AOP2
51    20    10   10    0    2   0    1    1         0      gsm1_AOP2
52    20    11   11    0    2   0    1    1         0      gsm1_AOP2
53    20    12   12    0    2   0    1    1         0      gsm1_AOP2
54    20    13   13    0    2   0    1    1         0      gsm1_AOP2
55    22    07    7    0    1   0    0    0         1      AOP2.gsoh
56    22    08    8    0    1   0    0    0         1      AOP2.gsoh
57    23    07    7    0    2   0    0    1         1 AOP2_AOP2.gsoh
58    23    08    8    0    2   0    0    1         1 AOP2_AOP2.gsoh
59    23    09    9    0    2   0    0    1         1 AOP2_AOP2.gsoh
60    23    10   10    0    2   0    0    1         1 AOP2_AOP2.gsoh
61    23    11   11    0    2   0    0    1         1 AOP2_AOP2.gsoh
62    23    12   12    0    2   0    0    1         1 AOP2_AOP2.gsoh
63    23    13   13    0    2   0    0    1         1 AOP2_AOP2.gsoh
64    23    14   14    0    2   0    0    1         1 AOP2_AOP2.gsoh
65    23    15   15    0    2   0    0    1         1 AOP2_AOP2.gsoh
66    23    16   16    0    2   0    0    1         1 AOP2_AOP2.gsoh
67    25    06    6    0    1   0    0    1         0           AOP2
68    25    07    7    0    1   0    0    1         0           AOP2
69    25    08    8    0    1   0    0    1         0           AOP2
70    26    07    7    0    1   1    0    0         0            Col
71    26    08    8    0    1   1    0    0         0            Col
72    27    07    7    0    2   1    0    1         0       Col_AOP2
73    27    08    8    0    2   1    0    1         0       Col_AOP2
74    28    06    6    0    2   1    0    0         1  Col_AOP2.gsoh
75    28    07    7    0    2   1    0    0         1  Col_AOP2.gsoh
76    28    08    8    0    2   1    0    0         1  Col_AOP2.gsoh
77    29    06    6    0    2   0    1    0         1 gsm1_AOP2.gsoh
78    29    07    7    0    2   0    1    0         1 gsm1_AOP2.gsoh
79    29    08    8    0    2   0    1    0         1 gsm1_AOP2.gsoh
80    29    09    9    0    2   0    1    0         1 gsm1_AOP2.gsoh
81    29    10   10    0    2   0    1    0         1 gsm1_AOP2.gsoh
82    29    11   11    0    2   0    1    0         1 gsm1_AOP2.gsoh
83    29    12   12    0    2   0    1    0         1 gsm1_AOP2.gsoh
84    29    13   13    0    2   0    1    0         1 gsm1_AOP2.gsoh
85    29    14   14    0    2   0    1    0         1 gsm1_AOP2.gsoh
86    29    15   15    0    2   0    1    0         1 gsm1_AOP2.gsoh
87    30    08    8    0    2   1    1    0         0       Col_gsm1
88    30    09    9    0    2   1    1    0         0       Col_gsm1
89    30    10   10    0    2   1    1    0         0       Col_gsm1
90    30    11   11    0    2   1    1    0         0       Col_gsm1
91    30    12   12    0    2   1    1    0         0       Col_gsm1
92    30    13   13    0    2   1    1    0         0       Col_gsm1
93    30    14   14    0    2   1    1    0         0       Col_gsm1
94    31    07    7    1    2   0    1    1         0      gsm1_AOP2
95    31    08    8    1    2   0    1    1         0      gsm1_AOP2
96    31    09    9    1    2   0    1    1         0      gsm1_AOP2
97    31    10   10    1    2   0    1    1         0      gsm1_AOP2
98    31    11   11    1    2   0    1    1         0      gsm1_AOP2
99    31    12   12    1    2   0    1    1         0      gsm1_AOP2
100   31    13   13    1    2   0    1    1         0      gsm1_AOP2
101   31    14   14    1    2   0    1    1         0      gsm1_AOP2
102   32    05    5    1    1   1    0    0         0            Col
103   32    06    6    1    1   1    0    0         0            Col
104   32    07    7    1    1   1    0    0         0            Col
105   32    08    8    1    1   1    0    0         0            Col
106   32    09    9    1    1   1    0    0         0            Col
107   32    10   10    1    1   1    0    0         0            Col
108   32    11   11    1    1   1    0    0         0            Col
109   32    12   12    1    1   1    0    0         0            Col
110   32    13   13    1    1   1    0    0         0            Col
111   32    14   14    1    1   1    0    0         0            Col
112   32    15   15    1    1   1    0    0         0            Col
113   33    05    5    1    1   1    0    0         0            Col
114   33    06    6    1    1   1    0    0         0            Col
115   33    07    7    1    1   1    0    0         0            Col
116   33    08    8    1    1   1    0    0         0            Col
117   33    09    9    1    1   1    0    0         0            Col
118   33    10   10    1    1   1    0    0         0            Col
119   34    06    6    1    2   1    0    0         1  Col_AOP2.gsoh
120   34    07    7    1    2   1    0    0         1  Col_AOP2.gsoh
121   34    08    8    1    2   1    0    0         1  Col_AOP2.gsoh
122   34    09    9    1    2   1    0    0         1  Col_AOP2.gsoh
123   35    06    6    1    2   0    0    1         1 AOP2_AOP2.gsoh
124   35    07    7    1    2   0    0    1         1 AOP2_AOP2.gsoh
125   36    04    4    1    2   0    1    0         1 gsm1_AOP2.gsoh
126   36    05    5    1    2   0    1    0         1 gsm1_AOP2.gsoh
127   36    06    6    1    2   0    1    0         1 gsm1_AOP2.gsoh
128   36    07    7    1    2   0    1    0         1 gsm1_AOP2.gsoh
129   36    08    8    1    2   0    1    0         1 gsm1_AOP2.gsoh
130   36    09    9    1    2   0    1    0         1 gsm1_AOP2.gsoh
131   36    10   10    1    2   0    1    0         1 gsm1_AOP2.gsoh
132   36    11   11    1    2   0    1    0         1 gsm1_AOP2.gsoh
133   36    12   12    1    2   0    1    0         1 gsm1_AOP2.gsoh
134   36    13   13    1    2   0    1    0         1 gsm1_AOP2.gsoh
135   36    14   14    1    2   0    1    0         1 gsm1_AOP2.gsoh
136   36    15   15    1    2   0    1    0         1 gsm1_AOP2.gsoh
137   37    06    6    1    2   0    1    0         1 gsm1_AOP2.gsoh
138   37    07    7    1    2   0    1    0         1 gsm1_AOP2.gsoh
139   37    08    8    1    2   0    1    0         1 gsm1_AOP2.gsoh
140   37    09    9    1    2   0    1    0         1 gsm1_AOP2.gsoh
141   37    10   10    1    2   0    1    0         1 gsm1_AOP2.gsoh
142   37    11   11    1    2   0    1    0         1 gsm1_AOP2.gsoh
143   37    12   12    1    2   0    1    0         1 gsm1_AOP2.gsoh
144   37    13   13    1    2   0    1    0         1 gsm1_AOP2.gsoh
145   37    14   14    1    2   0    1    0         1 gsm1_AOP2.gsoh
146   37    15   15    1    2   0    1    0         1 gsm1_AOP2.gsoh
147   37    16   16    1    2   0    1    0         1 gsm1_AOP2.gsoh
148   37    17   17    1    2   0    1    0         1 gsm1_AOP2.gsoh
149   38    04    4    1    4   1    1    1         1           Poly
150   38    05    5    1    4   1    1    1         1           Poly
151   38    06    6    1    4   1    1    1         1           Poly
152   38    07    7    1    4   1    1    1         1           Poly
153   38    08    8    1    4   1    1    1         1           Poly
154   38    09    9    1    4   1    1    1         1           Poly
155   38    10   10    1    4   1    1    1         1           Poly
156   38    11   11    1    4   1    1    1         1           Poly
157   38    12   12    1    4   1    1    1         1           Poly
158   38    13   13    1    4   1    1    1         1           Poly
159   38    14   14    1    4   1    1    1         1           Poly
160   39    07    7    1    1   0    1    0         0           gsm1
161   39    08    8    1    1   0    1    0         0           gsm1
162   39    09    9    1    1   0    1    0         0           gsm1
163    4    07    7    0    1   0    0    1         0           AOP2
164    4    08    8    0    1   0    0    1         0           AOP2
165    4    09    9    0    1   0    0    1         0           AOP2
166   40    04    4    1    2   0    1    0         1 gsm1_AOP2.gsoh
167   40    05    5    1    2   0    1    0         1 gsm1_AOP2.gsoh
168   40    06    6    1    2   0    1    0         1 gsm1_AOP2.gsoh
169   40    07    7    1    2   0    1    0         1 gsm1_AOP2.gsoh
170   40    08    8    1    2   0    1    0         1 gsm1_AOP2.gsoh
171   40    09    9    1    2   0    1    0         1 gsm1_AOP2.gsoh
172   40    10   10    1    2   0    1    0         1 gsm1_AOP2.gsoh
173   40    11   11    1    2   0    1    0         1 gsm1_AOP2.gsoh
174   40    12   12    1    2   0    1    0         1 gsm1_AOP2.gsoh
175   40    13   13    1    2   0    1    0         1 gsm1_AOP2.gsoh
176   40    14   14    1    2   0    1    0         1 gsm1_AOP2.gsoh
177   40    15   15    1    2   0    1    0         1 gsm1_AOP2.gsoh
178   40    16   16    1    2   0    1    0         1 gsm1_AOP2.gsoh
179   41    08    8    1    2   1    0    1         0       Col_AOP2
180   41    09    9    1    2   1    0    1         0       Col_AOP2
181   41    10   10    1    2   1    0    1         0       Col_AOP2
182   42    06    6    1    2   1    0    1         0       Col_AOP2
183   42    07    7    1    2   1    0    1         0       Col_AOP2
184   43    06    6    1    4   1    1    1         1           Poly
185   43    07    7    1    4   1    1    1         1           Poly
186   43    08    8    1    4   1    1    1         1           Poly
187   43    09    9    1    4   1    1    1         1           Poly
188   43    10   10    1    4   1    1    1         1           Poly
189   43    11   11    1    4   1    1    1         1           Poly
190   43    12   12    1    4   1    1    1         1           Poly
191   45    06    6    1    2   1    1    0         0       Col_gsm1
192   45    07    7    1    2   1    1    0         0       Col_gsm1
193   45    08    8    1    2   1    1    0         0       Col_gsm1
194   45    09    9    1    2   1    1    0         0       Col_gsm1
195   45    10   10    1    2   1    1    0         0       Col_gsm1
196   45    11   11    1    2   1    1    0         0       Col_gsm1
197   45    12   12    1    2   1    1    0         0       Col_gsm1
198   45    13   13    1    2   1    1    0         0       Col_gsm1
199   45    14   14    1    2   1    1    0         0       Col_gsm1
200   45    15   15    1    2   1    1    0         0       Col_gsm1
201   45    16   16    1    2   1    1    0         0       Col_gsm1
202   45    17   17    1    2   1    1    0         0       Col_gsm1
203   46    06    6    1    4   1    1    1         1           Poly
204   46    07    7    1    4   1    1    1         1           Poly
205   46    08    8    1    4   1    1    1         1           Poly
206   47    04    4    1    2   0    1    1         0      gsm1_AOP2
207   47    05    5    1    2   0    1    1         0      gsm1_AOP2
208   47    06    6    1    2   0    1    1         0      gsm1_AOP2
209   47    07    7    1    2   0    1    1         0      gsm1_AOP2
210   47    08    8    1    2   0    1    1         0      gsm1_AOP2
211   47    09    9    1    2   0    1    1         0      gsm1_AOP2
212   47    10   10    1    2   0    1    1         0      gsm1_AOP2
213   47    11   11    1    2   0    1    1         0      gsm1_AOP2
214   47    12   12    1    2   0    1    1         0      gsm1_AOP2
215   47    13   13    1    2   0    1    1         0      gsm1_AOP2
216   47    14   14    1    2   0    1    1         0      gsm1_AOP2
217   47    15   15    1    2   0    1    1         0      gsm1_AOP2
218   47    16   16    1    2   0    1    1         0      gsm1_AOP2
219   47    17   17    1    2   0    1    1         0      gsm1_AOP2
220   48    06    6    1    2   0    0    1         1 AOP2_AOP2.gsoh
221   48    07    7    1    2   0    0    1         1 AOP2_AOP2.gsoh
222   48    08    8    1    2   0    0    1         1 AOP2_AOP2.gsoh
223   48    09    9    1    2   0    0    1         1 AOP2_AOP2.gsoh
224   49    07    7    1    2   1    1    0         0       Col_gsm1
225   49    08    8    1    2   1    1    0         0       Col_gsm1
226   49    09    9    1    2   1    1    0         0       Col_gsm1
227   49    10   10    1    2   1    1    0         0       Col_gsm1
228   49    11   11    1    2   1    1    0         0       Col_gsm1
229   49    12   12    1    2   1    1    0         0       Col_gsm1
230   49    13   13    1    2   1    1    0         0       Col_gsm1
231    5    08    8    0    1   0    1    0         0           gsm1
232    5    09    9    0    1   0    1    0         0           gsm1
233    5    10   10    0    1   0    1    0         0           gsm1
234    5    11   11    0    1   0    1    0         0           gsm1
235    5    12   12    0    1   0    1    0         0           gsm1
236    5    13   13    0    1   0    1    0         0           gsm1
237    5    14   14    0    1   0    1    0         0           gsm1
238    5    15   15    0    1   0    1    0         0           gsm1
239    5    16   16    0    1   0    1    0         0           gsm1
240   50    06    6    1    2   1    0    1         0       Col_AOP2
241   50    07    7    1    2   1    0    1         0       Col_AOP2
242   50    08    8    1    2   1    0    1         0       Col_AOP2
243   50    09    9    1    2   1    0    1         0       Col_AOP2
244   50    10   10    1    2   1    0    1         0       Col_AOP2
245   50    11   11    1    2   1    0    1         0       Col_AOP2
246   50    12   12    1    2   1    0    1         0       Col_AOP2
247   50    13   13    1    2   1    0    1         0       Col_AOP2
248   50    14   14    1    2   1    0    1         0       Col_AOP2
249   50    15   15    1    2   1    0    1         0       Col_AOP2
250   50    16   16    1    2   1    0    1         0       Col_AOP2
251   50    17   17    1    2   1    0    1         0       Col_AOP2
252   51    05    5    1    1   0    1    0         0           gsm1
253   51    06    6    1    1   0    1    0         0           gsm1
254   51    07    7    1    1   0    1    0         0           gsm1
255   52    05    5    1    1   0    0    1         0           AOP2
256   52    06    6    1    1   0    0    1         0           AOP2
257   52    07    7    1    1   0    0    1         0           AOP2
258   52    08    8    1    1   0    0    1         0           AOP2
259   52    09    9    1    1   0    0    1         0           AOP2
260   52    10   10    1    1   0    0    1         0           AOP2
261   52    11   11    1    1   0    0    1         0           AOP2
262   53    08    8    1    4   1    1    1         1           Poly
263   53    09    9    1    4   1    1    1         1           Poly
264   53    10   10    1    4   1    1    1         1           Poly
265   53    11   11    1    4   1    1    1         1           Poly
266   53    12   12    1    4   1    1    1         1           Poly
267   53    13   13    1    4   1    1    1         1           Poly
268   53    14   14    1    4   1    1    1         1           Poly
269   53    15   15    1    4   1    1    1         1           Poly
270   53    16   16    1    4   1    1    1         1           Poly
271   53    17   17    1    4   1    1    1         1           Poly
272   54    04    4    1    1   0    0    0         1      AOP2.gsoh
273   54    05    5    1    1   0    0    0         1      AOP2.gsoh
274   54    06    6    1    1   0    0    0         1      AOP2.gsoh
275   54    07    7    1    1   0    0    0         1      AOP2.gsoh
276   54    08    8    1    1   0    0    0         1      AOP2.gsoh
277   54    09    9    1    1   0    0    0         1      AOP2.gsoh
278   54    10   10    1    1   0    0    0         1      AOP2.gsoh
279   54    11   11    1    1   0    0    0         1      AOP2.gsoh
280   54    12   12    1    1   0    0    0         1      AOP2.gsoh
281   54    13   13    1    1   0    0    0         1      AOP2.gsoh
282   54    14   14    1    1   0    0    0         1      AOP2.gsoh
283   54    15   15    1    1   0    0    0         1      AOP2.gsoh
284   55    07    7    1    2   1    0    0         1  Col_AOP2.gsoh
285   55    08    8    1    2   1    0    0         1  Col_AOP2.gsoh
286   56    06    6    1    1   0    0    0         1      AOP2.gsoh
287   56    07    7    1    1   0    0    0         1      AOP2.gsoh
288   57    06    6    1    2   0    0    1         1 AOP2_AOP2.gsoh
289   57    07    7    1    2   0    0    1         1 AOP2_AOP2.gsoh
290   58    05    5    1    2   1    0    0         1  Col_AOP2.gsoh
291   58    06    6    1    2   1    0    0         1  Col_AOP2.gsoh
292   58    07    7    1    2   1    0    0         1  Col_AOP2.gsoh
293   58    08    8    1    2   1    0    0         1  Col_AOP2.gsoh
294   58    09    9    1    2   1    0    0         1  Col_AOP2.gsoh
295   58    10   10    1    2   1    0    0         1  Col_AOP2.gsoh
296   58    11   11    1    2   1    0    0         1  Col_AOP2.gsoh
297   58    12   12    1    2   1    0    0         1  Col_AOP2.gsoh
298   58    13   13    1    2   1    0    0         1  Col_AOP2.gsoh
299   58    14   14    1    2   1    0    0         1  Col_AOP2.gsoh
300   58    15   15    1    2   1    0    0         1  Col_AOP2.gsoh
301   58    16   16    1    2   1    0    0         1  Col_AOP2.gsoh
302   58    17   17    1    2   1    0    0         1  Col_AOP2.gsoh
303   59    05    5    1    2   1    1    0         0       Col_gsm1
304   59    06    6    1    2   1    1    0         0       Col_gsm1
305   59    07    7    1    2   1    1    0         0       Col_gsm1
306   59    08    8    1    2   1    1    0         0       Col_gsm1
307   59    09    9    1    2   1    1    0         0       Col_gsm1
308   59    10   10    1    2   1    1    0         0       Col_gsm1
309   59    11   11    1    2   1    1    0         0       Col_gsm1
310   59    12   12    1    2   1    1    0         0       Col_gsm1
311    6    07    7    0    2   1    0    1         0       Col_AOP2
312    6    08    8    0    2   1    0    1         0       Col_AOP2
313    6    09    9    0    2   1    0    1         0       Col_AOP2
314    6    10   10    0    2   1    0    1         0       Col_AOP2
315    6    11   11    0    2   1    0    1         0       Col_AOP2
316    6    12   12    0    2   1    0    1         0       Col_AOP2
317    6    13   13    0    2   1    0    1         0       Col_AOP2
318    6    14   14    0    2   1    0    1         0       Col_AOP2
319    6    15   15    0    2   1    0    1         0       Col_AOP2
320    6    16   16    0    2   1    0    1         0       Col_AOP2
321   60    05    5    1    2   0    1    1         0      gsm1_AOP2
322   60    06    6    1    2   0    1    1         0      gsm1_AOP2
323   60    07    7    1    2   0    1    1         0      gsm1_AOP2
324    7    07    7    0    4   1    1    1         1           Poly
325    7    08    8    0    4   1    1    1         1           Poly
326    8    06    6    0    2   1    0    0         1  Col_AOP2.gsoh
327    8    07    7    0    2   1    0    0         1  Col_AOP2.gsoh
328    8    08    8    0    2   1    0    0         1  Col_AOP2.gsoh
329    9    07    7    0    2   1    1    0         0       Col_gsm1
330    9    08    8    0    2   1    1    0         0       Col_gsm1
331    9    09    9    0    2   1    1    0         0       Col_gsm1
332    9    10   10    0    2   1    1    0         0       Col_gsm1
333    9    11   11    0    2   1    1    0         0       Col_gsm1
334    9    12   12    0    2   1    1    0         0       Col_gsm1
335    9    13   13    0    2   1    1    0         0       Col_gsm1
336    9    14   14    0    2   1    1    0         0       Col_gsm1
337    9    15   15    0    2   1    1    0         0       Col_gsm1
    LYER_Survival Mummy_Ptoids_Survival        state week_since state_type
1               1                     1 0-LYER-Ptoid          5          2
2               1                     1 0-LYER-Ptoid          6          2
3               1                     1 0-LYER-Ptoid          7          2
4               1                     1 0-LYER-Ptoid          8          2
5               1                     1 0-LYER-Ptoid          9          2
6               1                     1 0-LYER-Ptoid         10          2
7               1                     1 0-LYER-Ptoid         11          2
8               1                     1 0-LYER-Ptoid         12          2
9               1                     1 0-LYER-Ptoid         13          2
10              1                     1 0-LYER-Ptoid         14          2
11              1                     1 0-LYER-Ptoid         15          2
12              1                     1 0-LYER-Ptoid          4          2
13              1                     1 0-LYER-Ptoid          5          2
14              1                     1 0-LYER-Ptoid          6          2
15              1                     1 0-LYER-Ptoid          7          2
16              1                     1 0-LYER-Ptoid          8          2
17              1                     1 0-LYER-Ptoid          9          2
18              1                     1 0-LYER-Ptoid         10          2
19              1                     1 0-LYER-Ptoid         11          2
20              1                     1 0-LYER-Ptoid         12          2
21              1                     1 0-LYER-Ptoid         13          2
22              1                     1 0-LYER-Ptoid         14          2
23              1                     1 0-LYER-Ptoid         15          2
24              1                     1 0-LYER-Ptoid          6          2
25              1                     1 0-LYER-Ptoid          7          2
26              1                     0     0-LYER-0          8          3
27              1                     1 0-LYER-Ptoid          5          2
28              1                     1 0-LYER-Ptoid          6          2
29              1                     1 0-LYER-Ptoid          7          2
30              1                     1 0-LYER-Ptoid          8          2
31              1                     1 0-LYER-Ptoid          9          2
32              1                     1 0-LYER-Ptoid         10          2
33              1                     1 0-LYER-Ptoid         11          2
34              1                     1 0-LYER-Ptoid         12          2
35              0                     1    0-0-Ptoid         13          4
36              1                     1 0-LYER-Ptoid          6          2
37              1                     0     0-LYER-0          7          3
38              1                     1 0-LYER-Ptoid          5          2
39              1                     1 0-LYER-Ptoid          6          2
40              1                     1 0-LYER-Ptoid          7          2
41              1                     1 0-LYER-Ptoid          8          2
42              1                     1 0-LYER-Ptoid          9          2
43              1                     1 0-LYER-Ptoid         10          2
44              1                     1 0-LYER-Ptoid         11          2
45              1                     1 0-LYER-Ptoid         12          2
46              1                     1 0-LYER-Ptoid         13          2
47              0                     1    0-0-Ptoid         14          4
48              1                     1 0-LYER-Ptoid          5          2
49              1                     1 0-LYER-Ptoid          6          2
50              1                     1 0-LYER-Ptoid          7          2
51              1                     1 0-LYER-Ptoid          8          2
52              1                     1 0-LYER-Ptoid          9          2
53              1                     1 0-LYER-Ptoid         10          2
54              1                     0     0-LYER-0         11          3
55              1                     1 0-LYER-Ptoid          5          2
56              1                     0     0-LYER-0          6          3
57              1                     1 0-LYER-Ptoid          5          2
58              1                     1 0-LYER-Ptoid          6          2
59              1                     1 0-LYER-Ptoid          7          2
60              1                     1 0-LYER-Ptoid          8          2
61              1                     1 0-LYER-Ptoid          9          2
62              1                     1 0-LYER-Ptoid         10          2
63              1                     1 0-LYER-Ptoid         11          2
64              1                     1 0-LYER-Ptoid         12          2
65              1                     1 0-LYER-Ptoid         13          2
66              1                     0     0-LYER-0         14          3
67              1                     1 0-LYER-Ptoid          4          2
68              1                     1 0-LYER-Ptoid          5          2
69              0                     1    0-0-Ptoid          6          4
70              1                     1 0-LYER-Ptoid          5          2
71              0                     1    0-0-Ptoid          6          4
72              1                     1 0-LYER-Ptoid          5          2
73              0                     1    0-0-Ptoid          6          4
74              1                     1 0-LYER-Ptoid          4          2
75              1                     1 0-LYER-Ptoid          5          2
76              0                     1    0-0-Ptoid          6          4
77              1                     1 0-LYER-Ptoid          4          2
78              1                     1 0-LYER-Ptoid          5          2
79              1                     1 0-LYER-Ptoid          6          2
80              1                     1 0-LYER-Ptoid          7          2
81              1                     1 0-LYER-Ptoid          8          2
82              1                     1 0-LYER-Ptoid          9          2
83              1                     1 0-LYER-Ptoid         10          2
84              1                     1 0-LYER-Ptoid         11          2
85              1                     1 0-LYER-Ptoid         12          2
86              0                     0        0-0-0         13          5
87              1                     1 0-LYER-Ptoid          6          2
88              1                     1 0-LYER-Ptoid          7          2
89              1                     1 0-LYER-Ptoid          8          2
90              1                     1 0-LYER-Ptoid          9          2
91              1                     1 0-LYER-Ptoid         10          2
92              1                     1 0-LYER-Ptoid         11          2
93              1                     0     0-LYER-0         12          3
94              1                     1 0-LYER-Ptoid          5          2
95              1                     1 0-LYER-Ptoid          6          2
96              1                     1 0-LYER-Ptoid          7          2
97              1                     1 0-LYER-Ptoid          8          2
98              1                     1 0-LYER-Ptoid          9          2
99              1                     1 0-LYER-Ptoid         10          2
100             1                     1 0-LYER-Ptoid         11          2
101             1                     0     0-LYER-0         12          3
102             1                     1 0-LYER-Ptoid          3          2
103             1                     1 0-LYER-Ptoid          4          2
104             1                     1 0-LYER-Ptoid          5          2
105             1                     1 0-LYER-Ptoid          6          2
106             1                     1 0-LYER-Ptoid          7          2
107             1                     1 0-LYER-Ptoid          8          2
108             1                     1 0-LYER-Ptoid          9          2
109             1                     1 0-LYER-Ptoid         10          2
110             1                     1 0-LYER-Ptoid         11          2
111             1                     1 0-LYER-Ptoid         12          2
112             1                     0     0-LYER-0         13          3
113             1                     1 0-LYER-Ptoid          3          2
114             1                     1 0-LYER-Ptoid          4          2
115             1                     1 0-LYER-Ptoid          5          2
116             1                     1 0-LYER-Ptoid          6          2
117             1                     1 0-LYER-Ptoid          7          2
118             1                     0     0-LYER-0          8          3
119             1                     1 0-LYER-Ptoid          4          2
120             1                     1 0-LYER-Ptoid          5          2
121             1                     1 0-LYER-Ptoid          6          2
122             1                     0     0-LYER-0          7          3
123             1                     1 0-LYER-Ptoid          4          2
124             1                     0     0-LYER-0          5          3
125             1                     1 0-LYER-Ptoid          2          2
126             1                     1 0-LYER-Ptoid          3          2
127             1                     1 0-LYER-Ptoid          4          2
128             1                     1 0-LYER-Ptoid          5          2
129             1                     1 0-LYER-Ptoid          6          2
130             1                     1 0-LYER-Ptoid          7          2
131             1                     1 0-LYER-Ptoid          8          2
132             1                     1 0-LYER-Ptoid          9          2
133             1                     1 0-LYER-Ptoid         10          2
134             1                     1 0-LYER-Ptoid         11          2
135             1                     1 0-LYER-Ptoid         12          2
136             0                     0        0-0-0         13          5
137             1                     1 0-LYER-Ptoid          4          2
138             1                     1 0-LYER-Ptoid          5          2
139             1                     1 0-LYER-Ptoid          6          2
140             1                     1 0-LYER-Ptoid          7          2
141             1                     1 0-LYER-Ptoid          8          2
142             1                     1 0-LYER-Ptoid          9          2
143             1                     1 0-LYER-Ptoid         10          2
144             1                     1 0-LYER-Ptoid         11          2
145             1                     1 0-LYER-Ptoid         12          2
146             1                     1 0-LYER-Ptoid         13          2
147             1                     1 0-LYER-Ptoid         14          2
148             1                     1 0-LYER-Ptoid         15          2
149             1                     1 0-LYER-Ptoid          2          2
150             1                     1 0-LYER-Ptoid          3          2
151             1                     1 0-LYER-Ptoid          4          2
152             1                     1 0-LYER-Ptoid          5          2
153             1                     1 0-LYER-Ptoid          6          2
154             1                     1 0-LYER-Ptoid          7          2
155             1                     1 0-LYER-Ptoid          8          2
156             1                     1 0-LYER-Ptoid          9          2
157             1                     1 0-LYER-Ptoid         10          2
158             1                     1 0-LYER-Ptoid         11          2
159             1                     0     0-LYER-0         12          3
160             1                     1 0-LYER-Ptoid          5          2
161             1                     1 0-LYER-Ptoid          6          2
162             1                     0     0-LYER-0          7          3
163             1                     1 0-LYER-Ptoid          5          2
164             1                     1 0-LYER-Ptoid          6          2
165             1                     0     0-LYER-0          7          3
166             1                     1 0-LYER-Ptoid          2          2
167             1                     1 0-LYER-Ptoid          3          2
168             1                     1 0-LYER-Ptoid          4          2
169             1                     1 0-LYER-Ptoid          5          2
170             1                     1 0-LYER-Ptoid          6          2
171             1                     1 0-LYER-Ptoid          7          2
172             1                     1 0-LYER-Ptoid          8          2
173             1                     1 0-LYER-Ptoid          9          2
174             1                     1 0-LYER-Ptoid         10          2
175             1                     1 0-LYER-Ptoid         11          2
176             1                     1 0-LYER-Ptoid         12          2
177             1                     1 0-LYER-Ptoid         13          2
178             1                     0     0-LYER-0         14          3
179             1                     1 0-LYER-Ptoid          6          2
180             1                     1 0-LYER-Ptoid          7          2
181             1                     0     0-LYER-0          8          3
182             1                     1 0-LYER-Ptoid          4          2
183             0                     0        0-0-0          5          5
184             1                     1 0-LYER-Ptoid          4          2
185             1                     1 0-LYER-Ptoid          5          2
186             1                     1 0-LYER-Ptoid          6          2
187             1                     1 0-LYER-Ptoid          7          2
188             1                     1 0-LYER-Ptoid          8          2
189             1                     1 0-LYER-Ptoid          9          2
190             1                     0     0-LYER-0         10          3
191             1                     1 0-LYER-Ptoid          4          2
192             1                     1 0-LYER-Ptoid          5          2
193             1                     1 0-LYER-Ptoid          6          2
194             1                     1 0-LYER-Ptoid          7          2
195             1                     1 0-LYER-Ptoid          8          2
196             1                     1 0-LYER-Ptoid          9          2
197             1                     1 0-LYER-Ptoid         10          2
198             1                     1 0-LYER-Ptoid         11          2
199             1                     1 0-LYER-Ptoid         12          2
200             1                     1 0-LYER-Ptoid         13          2
201             1                     1 0-LYER-Ptoid         14          2
202             1                     1 0-LYER-Ptoid         15          2
203             1                     1 0-LYER-Ptoid          4          2
204             1                     1 0-LYER-Ptoid          5          2
205             1                     0     0-LYER-0          6          3
206             1                     1 0-LYER-Ptoid          2          2
207             1                     1 0-LYER-Ptoid          3          2
208             1                     1 0-LYER-Ptoid          4          2
209             1                     1 0-LYER-Ptoid          5          2
210             1                     1 0-LYER-Ptoid          6          2
211             1                     1 0-LYER-Ptoid          7          2
212             1                     1 0-LYER-Ptoid          8          2
213             1                     1 0-LYER-Ptoid          9          2
214             1                     1 0-LYER-Ptoid         10          2
215             1                     1 0-LYER-Ptoid         11          2
216             1                     1 0-LYER-Ptoid         12          2
217             1                     1 0-LYER-Ptoid         13          2
218             1                     1 0-LYER-Ptoid         14          2
219             1                     1 0-LYER-Ptoid         15          2
220             1                     1 0-LYER-Ptoid          4          2
221             1                     1 0-LYER-Ptoid          5          2
222             1                     1 0-LYER-Ptoid          6          2
223             1                     0     0-LYER-0          7          3
224             1                     1 0-LYER-Ptoid          5          2
225             1                     1 0-LYER-Ptoid          6          2
226             1                     1 0-LYER-Ptoid          7          2
227             1                     1 0-LYER-Ptoid          8          2
228             1                     1 0-LYER-Ptoid          9          2
229             1                     1 0-LYER-Ptoid         10          2
230             1                     0     0-LYER-0         11          3
231             1                     1 0-LYER-Ptoid          6          2
232             1                     1 0-LYER-Ptoid          7          2
233             1                     1 0-LYER-Ptoid          8          2
234             1                     1 0-LYER-Ptoid          9          2
235             1                     1 0-LYER-Ptoid         10          2
236             1                     1 0-LYER-Ptoid         11          2
237             1                     1 0-LYER-Ptoid         12          2
238             1                     1 0-LYER-Ptoid         13          2
239             1                     0     0-LYER-0         14          3
240             1                     1 0-LYER-Ptoid          4          2
241             1                     1 0-LYER-Ptoid          5          2
242             1                     1 0-LYER-Ptoid          6          2
243             1                     1 0-LYER-Ptoid          7          2
244             1                     1 0-LYER-Ptoid          8          2
245             1                     1 0-LYER-Ptoid          9          2
246             1                     1 0-LYER-Ptoid         10          2
247             1                     1 0-LYER-Ptoid         11          2
248             1                     1 0-LYER-Ptoid         12          2
249             1                     1 0-LYER-Ptoid         13          2
250             1                     1 0-LYER-Ptoid         14          2
251             1                     1 0-LYER-Ptoid         15          2
252             1                     1 0-LYER-Ptoid          3          2
253             1                     1 0-LYER-Ptoid          4          2
254             0                     1    0-0-Ptoid          5          4
255             1                     1 0-LYER-Ptoid          3          2
256             1                     1 0-LYER-Ptoid          4          2
257             1                     1 0-LYER-Ptoid          5          2
258             1                     1 0-LYER-Ptoid          6          2
259             1                     1 0-LYER-Ptoid          7          2
260             1                     1 0-LYER-Ptoid          8          2
261             1                     0     0-LYER-0          9          3
262             1                     1 0-LYER-Ptoid          6          2
263             1                     1 0-LYER-Ptoid          7          2
264             1                     1 0-LYER-Ptoid          8          2
265             1                     1 0-LYER-Ptoid          9          2
266             1                     1 0-LYER-Ptoid         10          2
267             1                     1 0-LYER-Ptoid         11          2
268             1                     1 0-LYER-Ptoid         12          2
269             1                     1 0-LYER-Ptoid         13          2
270             1                     1 0-LYER-Ptoid         14          2
271             1                     1 0-LYER-Ptoid         15          2
272             1                     1 0-LYER-Ptoid          2          2
273             1                     1 0-LYER-Ptoid          3          2
274             1                     1 0-LYER-Ptoid          4          2
275             1                     1 0-LYER-Ptoid          5          2
276             1                     1 0-LYER-Ptoid          6          2
277             1                     1 0-LYER-Ptoid          7          2
278             1                     1 0-LYER-Ptoid          8          2
279             1                     1 0-LYER-Ptoid          9          2
280             1                     1 0-LYER-Ptoid         10          2
281             1                     1 0-LYER-Ptoid         11          2
282             1                     1 0-LYER-Ptoid         12          2
283             0                     1    0-0-Ptoid         13          4
284             1                     1 0-LYER-Ptoid          5          2
285             0                     1    0-0-Ptoid          6          4
286             1                     1 0-LYER-Ptoid          4          2
287             0                     1    0-0-Ptoid          5          4
288             1                     1 0-LYER-Ptoid          4          2
289             0                     1    0-0-Ptoid          5          4
290             1                     1 0-LYER-Ptoid          3          2
291             1                     1 0-LYER-Ptoid          4          2
292             1                     1 0-LYER-Ptoid          5          2
293             1                     1 0-LYER-Ptoid          6          2
294             1                     1 0-LYER-Ptoid          7          2
295             1                     1 0-LYER-Ptoid          8          2
296             1                     1 0-LYER-Ptoid          9          2
297             1                     1 0-LYER-Ptoid         10          2
298             1                     1 0-LYER-Ptoid         11          2
299             1                     1 0-LYER-Ptoid         12          2
300             1                     1 0-LYER-Ptoid         13          2
301             1                     1 0-LYER-Ptoid         14          2
302             1                     1 0-LYER-Ptoid         15          2
303             1                     1 0-LYER-Ptoid          3          2
304             1                     1 0-LYER-Ptoid          4          2
305             1                     1 0-LYER-Ptoid          5          2
306             1                     1 0-LYER-Ptoid          6          2
307             1                     1 0-LYER-Ptoid          7          2
308             1                     1 0-LYER-Ptoid          8          2
309             1                     1 0-LYER-Ptoid          9          2
310             1                     0     0-LYER-0         10          3
311             1                     1 0-LYER-Ptoid          5          2
312             1                     1 0-LYER-Ptoid          6          2
313             1                     1 0-LYER-Ptoid          7          2
314             1                     1 0-LYER-Ptoid          8          2
315             1                     1 0-LYER-Ptoid          9          2
316             1                     1 0-LYER-Ptoid         10          2
317             1                     1 0-LYER-Ptoid         11          2
318             1                     1 0-LYER-Ptoid         12          2
319             1                     1 0-LYER-Ptoid         13          2
320             0                     0        0-0-0         14          5
321             1                     1 0-LYER-Ptoid          3          2
322             1                     1 0-LYER-Ptoid          4          2
323             0                     1    0-0-Ptoid          5          4
324             1                     1 0-LYER-Ptoid          5          2
325             1                     0     0-LYER-0          6          3
326             1                     1 0-LYER-Ptoid          4          2
327             1                     1 0-LYER-Ptoid          5          2
328             0                     0        0-0-0          6          5
329             1                     1 0-LYER-Ptoid          5          2
330             1                     1 0-LYER-Ptoid          6          2
331             1                     1 0-LYER-Ptoid          7          2
332             1                     1 0-LYER-Ptoid          8          2
333             1                     1 0-LYER-Ptoid          9          2
334             1                     1 0-LYER-Ptoid         10          2
335             1                     1 0-LYER-Ptoid         11          2
336             1                     1 0-LYER-Ptoid         12          2
337             1                     0     0-LYER-0         13          3
       state_adj start
1   0-LYER-Ptoid     5
2   0-LYER-Ptoid     5
3   0-LYER-Ptoid     5
4   0-LYER-Ptoid     5
5   0-LYER-Ptoid     5
6   0-LYER-Ptoid     5
7   0-LYER-Ptoid     5
8   0-LYER-Ptoid     5
9   0-LYER-Ptoid     5
10  0-LYER-Ptoid     5
11  0-LYER-Ptoid     5
12  0-LYER-Ptoid     4
13  0-LYER-Ptoid     4
14  0-LYER-Ptoid     4
15  0-LYER-Ptoid     4
16  0-LYER-Ptoid     4
17  0-LYER-Ptoid     4
18  0-LYER-Ptoid     4
19  0-LYER-Ptoid     4
20  0-LYER-Ptoid     4
21  0-LYER-Ptoid     4
22  0-LYER-Ptoid     4
23  0-LYER-Ptoid     4
24  0-LYER-Ptoid     6
25  0-LYER-Ptoid     6
26      0-LYER-0     6
27  0-LYER-Ptoid     5
28  0-LYER-Ptoid     5
29  0-LYER-Ptoid     5
30  0-LYER-Ptoid     5
31  0-LYER-Ptoid     5
32  0-LYER-Ptoid     5
33  0-LYER-Ptoid     5
34  0-LYER-Ptoid     5
35     0-0-Ptoid     5
36  0-LYER-Ptoid     6
37      0-LYER-0     6
38  0-LYER-Ptoid     5
39  0-LYER-Ptoid     5
40  0-LYER-Ptoid     5
41  0-LYER-Ptoid     5
42  0-LYER-Ptoid     5
43  0-LYER-Ptoid     5
44  0-LYER-Ptoid     5
45  0-LYER-Ptoid     5
46  0-LYER-Ptoid     5
47     0-0-Ptoid     5
48  0-LYER-Ptoid     5
49  0-LYER-Ptoid     5
50  0-LYER-Ptoid     5
51  0-LYER-Ptoid     5
52  0-LYER-Ptoid     5
53  0-LYER-Ptoid     5
54      0-LYER-0     5
55  0-LYER-Ptoid     5
56      0-LYER-0     5
57  0-LYER-Ptoid     5
58  0-LYER-Ptoid     5
59  0-LYER-Ptoid     5
60  0-LYER-Ptoid     5
61  0-LYER-Ptoid     5
62  0-LYER-Ptoid     5
63  0-LYER-Ptoid     5
64  0-LYER-Ptoid     5
65  0-LYER-Ptoid     5
66      0-LYER-0     5
67  0-LYER-Ptoid     4
68  0-LYER-Ptoid     4
69     0-0-Ptoid     4
70  0-LYER-Ptoid     5
71     0-0-Ptoid     5
72  0-LYER-Ptoid     5
73     0-0-Ptoid     5
74  0-LYER-Ptoid     4
75  0-LYER-Ptoid     4
76     0-0-Ptoid     4
77  0-LYER-Ptoid     4
78  0-LYER-Ptoid     4
79  0-LYER-Ptoid     4
80  0-LYER-Ptoid     4
81  0-LYER-Ptoid     4
82  0-LYER-Ptoid     4
83  0-LYER-Ptoid     4
84  0-LYER-Ptoid     4
85  0-LYER-Ptoid     4
86     0-0-Ptoid     4
87  0-LYER-Ptoid     6
88  0-LYER-Ptoid     6
89  0-LYER-Ptoid     6
90  0-LYER-Ptoid     6
91  0-LYER-Ptoid     6
92  0-LYER-Ptoid     6
93      0-LYER-0     6
94  0-LYER-Ptoid     5
95  0-LYER-Ptoid     5
96  0-LYER-Ptoid     5
97  0-LYER-Ptoid     5
98  0-LYER-Ptoid     5
99  0-LYER-Ptoid     5
100 0-LYER-Ptoid     5
101     0-LYER-0     5
102 0-LYER-Ptoid     3
103 0-LYER-Ptoid     3
104 0-LYER-Ptoid     3
105 0-LYER-Ptoid     3
106 0-LYER-Ptoid     3
107 0-LYER-Ptoid     3
108 0-LYER-Ptoid     3
109 0-LYER-Ptoid     3
110 0-LYER-Ptoid     3
111 0-LYER-Ptoid     3
112     0-LYER-0     3
113 0-LYER-Ptoid     3
114 0-LYER-Ptoid     3
115 0-LYER-Ptoid     3
116 0-LYER-Ptoid     3
117 0-LYER-Ptoid     3
118     0-LYER-0     3
119 0-LYER-Ptoid     4
120 0-LYER-Ptoid     4
121 0-LYER-Ptoid     4
122     0-LYER-0     4
123 0-LYER-Ptoid     4
124     0-LYER-0     4
125 0-LYER-Ptoid     2
126 0-LYER-Ptoid     2
127 0-LYER-Ptoid     2
128 0-LYER-Ptoid     2
129 0-LYER-Ptoid     2
130 0-LYER-Ptoid     2
131 0-LYER-Ptoid     2
132 0-LYER-Ptoid     2
133 0-LYER-Ptoid     2
134 0-LYER-Ptoid     2
135 0-LYER-Ptoid     2
136    0-0-Ptoid     2
137 0-LYER-Ptoid     4
138 0-LYER-Ptoid     4
139 0-LYER-Ptoid     4
140 0-LYER-Ptoid     4
141 0-LYER-Ptoid     4
142 0-LYER-Ptoid     4
143 0-LYER-Ptoid     4
144 0-LYER-Ptoid     4
145 0-LYER-Ptoid     4
146 0-LYER-Ptoid     4
147 0-LYER-Ptoid     4
148 0-LYER-Ptoid     4
149 0-LYER-Ptoid     2
150 0-LYER-Ptoid     2
151 0-LYER-Ptoid     2
152 0-LYER-Ptoid     2
153 0-LYER-Ptoid     2
154 0-LYER-Ptoid     2
155 0-LYER-Ptoid     2
156 0-LYER-Ptoid     2
157 0-LYER-Ptoid     2
158 0-LYER-Ptoid     2
159     0-LYER-0     2
160 0-LYER-Ptoid     5
161 0-LYER-Ptoid     5
162     0-LYER-0     5
163 0-LYER-Ptoid     5
164 0-LYER-Ptoid     5
165     0-LYER-0     5
166 0-LYER-Ptoid     2
167 0-LYER-Ptoid     2
168 0-LYER-Ptoid     2
169 0-LYER-Ptoid     2
170 0-LYER-Ptoid     2
171 0-LYER-Ptoid     2
172 0-LYER-Ptoid     2
173 0-LYER-Ptoid     2
174 0-LYER-Ptoid     2
175 0-LYER-Ptoid     2
176 0-LYER-Ptoid     2
177 0-LYER-Ptoid     2
178     0-LYER-0     2
179 0-LYER-Ptoid     6
180 0-LYER-Ptoid     6
181     0-LYER-0     6
182 0-LYER-Ptoid     4
183    0-0-Ptoid     4
184 0-LYER-Ptoid     4
185 0-LYER-Ptoid     4
186 0-LYER-Ptoid     4
187 0-LYER-Ptoid     4
188 0-LYER-Ptoid     4
189 0-LYER-Ptoid     4
190     0-LYER-0     4
191 0-LYER-Ptoid     4
192 0-LYER-Ptoid     4
193 0-LYER-Ptoid     4
194 0-LYER-Ptoid     4
195 0-LYER-Ptoid     4
196 0-LYER-Ptoid     4
197 0-LYER-Ptoid     4
198 0-LYER-Ptoid     4
199 0-LYER-Ptoid     4
200 0-LYER-Ptoid     4
201 0-LYER-Ptoid     4
202 0-LYER-Ptoid     4
203 0-LYER-Ptoid     4
204 0-LYER-Ptoid     4
205     0-LYER-0     4
206 0-LYER-Ptoid     2
207 0-LYER-Ptoid     2
208 0-LYER-Ptoid     2
209 0-LYER-Ptoid     2
210 0-LYER-Ptoid     2
211 0-LYER-Ptoid     2
212 0-LYER-Ptoid     2
213 0-LYER-Ptoid     2
214 0-LYER-Ptoid     2
215 0-LYER-Ptoid     2
216 0-LYER-Ptoid     2
217 0-LYER-Ptoid     2
218 0-LYER-Ptoid     2
219 0-LYER-Ptoid     2
220 0-LYER-Ptoid     4
221 0-LYER-Ptoid     4
222 0-LYER-Ptoid     4
223     0-LYER-0     4
224 0-LYER-Ptoid     5
225 0-LYER-Ptoid     5
226 0-LYER-Ptoid     5
227 0-LYER-Ptoid     5
228 0-LYER-Ptoid     5
229 0-LYER-Ptoid     5
230     0-LYER-0     5
231 0-LYER-Ptoid     6
232 0-LYER-Ptoid     6
233 0-LYER-Ptoid     6
234 0-LYER-Ptoid     6
235 0-LYER-Ptoid     6
236 0-LYER-Ptoid     6
237 0-LYER-Ptoid     6
238 0-LYER-Ptoid     6
239     0-LYER-0     6
240 0-LYER-Ptoid     4
241 0-LYER-Ptoid     4
242 0-LYER-Ptoid     4
243 0-LYER-Ptoid     4
244 0-LYER-Ptoid     4
245 0-LYER-Ptoid     4
246 0-LYER-Ptoid     4
247 0-LYER-Ptoid     4
248 0-LYER-Ptoid     4
249 0-LYER-Ptoid     4
250 0-LYER-Ptoid     4
251 0-LYER-Ptoid     4
252 0-LYER-Ptoid     3
253 0-LYER-Ptoid     3
254    0-0-Ptoid     3
255 0-LYER-Ptoid     3
256 0-LYER-Ptoid     3
257 0-LYER-Ptoid     3
258 0-LYER-Ptoid     3
259 0-LYER-Ptoid     3
260 0-LYER-Ptoid     3
261     0-LYER-0     3
262 0-LYER-Ptoid     6
263 0-LYER-Ptoid     6
264 0-LYER-Ptoid     6
265 0-LYER-Ptoid     6
266 0-LYER-Ptoid     6
267 0-LYER-Ptoid     6
268 0-LYER-Ptoid     6
269 0-LYER-Ptoid     6
270 0-LYER-Ptoid     6
271 0-LYER-Ptoid     6
272 0-LYER-Ptoid     2
273 0-LYER-Ptoid     2
274 0-LYER-Ptoid     2
275 0-LYER-Ptoid     2
276 0-LYER-Ptoid     2
277 0-LYER-Ptoid     2
278 0-LYER-Ptoid     2
279 0-LYER-Ptoid     2
280 0-LYER-Ptoid     2
281 0-LYER-Ptoid     2
282 0-LYER-Ptoid     2
283    0-0-Ptoid     2
284 0-LYER-Ptoid     5
285    0-0-Ptoid     5
286 0-LYER-Ptoid     4
287    0-0-Ptoid     4
288 0-LYER-Ptoid     4
289    0-0-Ptoid     4
290 0-LYER-Ptoid     3
291 0-LYER-Ptoid     3
292 0-LYER-Ptoid     3
293 0-LYER-Ptoid     3
294 0-LYER-Ptoid     3
295 0-LYER-Ptoid     3
296 0-LYER-Ptoid     3
297 0-LYER-Ptoid     3
298 0-LYER-Ptoid     3
299 0-LYER-Ptoid     3
300 0-LYER-Ptoid     3
301 0-LYER-Ptoid     3
302 0-LYER-Ptoid     3
303 0-LYER-Ptoid     3
304 0-LYER-Ptoid     3
305 0-LYER-Ptoid     3
306 0-LYER-Ptoid     3
307 0-LYER-Ptoid     3
308 0-LYER-Ptoid     3
309 0-LYER-Ptoid     3
310     0-LYER-0     3
311 0-LYER-Ptoid     5
312 0-LYER-Ptoid     5
313 0-LYER-Ptoid     5
314 0-LYER-Ptoid     5
315 0-LYER-Ptoid     5
316 0-LYER-Ptoid     5
317 0-LYER-Ptoid     5
318 0-LYER-Ptoid     5
319 0-LYER-Ptoid     5
320    0-0-Ptoid     5
321 0-LYER-Ptoid     3
322 0-LYER-Ptoid     3
323    0-0-Ptoid     3
324 0-LYER-Ptoid     5
325     0-LYER-0     5
326 0-LYER-Ptoid     4
327 0-LYER-Ptoid     4
328    0-0-Ptoid     4
329 0-LYER-Ptoid     5
330 0-LYER-Ptoid     5
331 0-LYER-Ptoid     5
332 0-LYER-Ptoid     5
333 0-LYER-Ptoid     5
334 0-LYER-Ptoid     5
335 0-LYER-Ptoid     5
336 0-LYER-Ptoid     5
337     0-LYER-0     5
# convert to Cox data frame for analysis
LP_transit_cox_df <- get_LP_transit_start %>%
  arrange(cage, week_since, state_adj) %>% 
  select(cage, start, week_since, temp:com, state_adj) %>%
  group_by(cage) %>% 
  summarise(across(everything(), last)) %>%
  mutate(#any_event = ifelse(state_adj == "0-LYER-Ptoid", 0, 1),
         fstate = factor(state_adj, levels = c("0-LYER-Ptoid","0-LYER-0","0-0-Ptoid")))

# all looks good, 50 data points
LP_transit_cox_df %>% data.frame()
   cage start week_since temp rich Col gsm1 AOP2 AOP2.gsoh            com
1    12     5         15    0    4   1    1    1         1           Poly
2    13     4         15    0    4   1    1    1         1           Poly
3    14     6          8    0    1   1    0    0         0            Col
4    15     5         13    0    1   0    0    0         1      AOP2.gsoh
5    17     6          7    0    2   0    1    1         0      gsm1_AOP2
6    18     5         14    0    2   1    0    0         1  Col_AOP2.gsoh
7    20     5         11    0    2   0    1    1         0      gsm1_AOP2
8    22     5          6    0    1   0    0    0         1      AOP2.gsoh
9    23     5         14    0    2   0    0    1         1 AOP2_AOP2.gsoh
10   25     4          6    0    1   0    0    1         0           AOP2
11   26     5          6    0    1   1    0    0         0            Col
12   27     5          6    0    2   1    0    1         0       Col_AOP2
13   28     4          6    0    2   1    0    0         1  Col_AOP2.gsoh
14   29     4         13    0    2   0    1    0         1 gsm1_AOP2.gsoh
15   30     6         12    0    2   1    1    0         0       Col_gsm1
16   31     5         12    1    2   0    1    1         0      gsm1_AOP2
17   32     3         13    1    1   1    0    0         0            Col
18   33     3          8    1    1   1    0    0         0            Col
19   34     4          7    1    2   1    0    0         1  Col_AOP2.gsoh
20   35     4          5    1    2   0    0    1         1 AOP2_AOP2.gsoh
21   36     2         13    1    2   0    1    0         1 gsm1_AOP2.gsoh
22   37     4         15    1    2   0    1    0         1 gsm1_AOP2.gsoh
23   38     2         12    1    4   1    1    1         1           Poly
24   39     5          7    1    1   0    1    0         0           gsm1
25    4     5          7    0    1   0    0    1         0           AOP2
26   40     2         14    1    2   0    1    0         1 gsm1_AOP2.gsoh
27   41     6          8    1    2   1    0    1         0       Col_AOP2
28   42     4          5    1    2   1    0    1         0       Col_AOP2
29   43     4         10    1    4   1    1    1         1           Poly
30   45     4         15    1    2   1    1    0         0       Col_gsm1
31   46     4          6    1    4   1    1    1         1           Poly
32   47     2         15    1    2   0    1    1         0      gsm1_AOP2
33   48     4          7    1    2   0    0    1         1 AOP2_AOP2.gsoh
34   49     5         11    1    2   1    1    0         0       Col_gsm1
35    5     6         14    0    1   0    1    0         0           gsm1
36   50     4         15    1    2   1    0    1         0       Col_AOP2
37   51     3          5    1    1   0    1    0         0           gsm1
38   52     3          9    1    1   0    0    1         0           AOP2
39   53     6         15    1    4   1    1    1         1           Poly
40   54     2         13    1    1   0    0    0         1      AOP2.gsoh
41   55     5          6    1    2   1    0    0         1  Col_AOP2.gsoh
42   56     4          5    1    1   0    0    0         1      AOP2.gsoh
43   57     4          5    1    2   0    0    1         1 AOP2_AOP2.gsoh
44   58     3         15    1    2   1    0    0         1  Col_AOP2.gsoh
45   59     3         10    1    2   1    1    0         0       Col_gsm1
46    6     5         14    0    2   1    0    1         0       Col_AOP2
47   60     3          5    1    2   0    1    1         0      gsm1_AOP2
48    7     5          6    0    4   1    1    1         1           Poly
49    8     4          6    0    2   1    0    0         1  Col_AOP2.gsoh
50    9     5         13    0    2   1    1    0         0       Col_gsm1
      state_adj       fstate
1  0-LYER-Ptoid 0-LYER-Ptoid
2  0-LYER-Ptoid 0-LYER-Ptoid
3      0-LYER-0     0-LYER-0
4     0-0-Ptoid    0-0-Ptoid
5      0-LYER-0     0-LYER-0
6     0-0-Ptoid    0-0-Ptoid
7      0-LYER-0     0-LYER-0
8      0-LYER-0     0-LYER-0
9      0-LYER-0     0-LYER-0
10    0-0-Ptoid    0-0-Ptoid
11    0-0-Ptoid    0-0-Ptoid
12    0-0-Ptoid    0-0-Ptoid
13    0-0-Ptoid    0-0-Ptoid
14    0-0-Ptoid    0-0-Ptoid
15     0-LYER-0     0-LYER-0
16     0-LYER-0     0-LYER-0
17     0-LYER-0     0-LYER-0
18     0-LYER-0     0-LYER-0
19     0-LYER-0     0-LYER-0
20     0-LYER-0     0-LYER-0
21    0-0-Ptoid    0-0-Ptoid
22 0-LYER-Ptoid 0-LYER-Ptoid
23     0-LYER-0     0-LYER-0
24     0-LYER-0     0-LYER-0
25     0-LYER-0     0-LYER-0
26     0-LYER-0     0-LYER-0
27     0-LYER-0     0-LYER-0
28    0-0-Ptoid    0-0-Ptoid
29     0-LYER-0     0-LYER-0
30 0-LYER-Ptoid 0-LYER-Ptoid
31     0-LYER-0     0-LYER-0
32 0-LYER-Ptoid 0-LYER-Ptoid
33     0-LYER-0     0-LYER-0
34     0-LYER-0     0-LYER-0
35     0-LYER-0     0-LYER-0
36 0-LYER-Ptoid 0-LYER-Ptoid
37    0-0-Ptoid    0-0-Ptoid
38     0-LYER-0     0-LYER-0
39 0-LYER-Ptoid 0-LYER-Ptoid
40    0-0-Ptoid    0-0-Ptoid
41    0-0-Ptoid    0-0-Ptoid
42    0-0-Ptoid    0-0-Ptoid
43    0-0-Ptoid    0-0-Ptoid
44 0-LYER-Ptoid 0-LYER-Ptoid
45     0-LYER-0     0-LYER-0
46    0-0-Ptoid    0-0-Ptoid
47    0-0-Ptoid    0-0-Ptoid
48     0-LYER-0     0-LYER-0
49    0-0-Ptoid    0-0-Ptoid
50     0-LYER-0     0-LYER-0
# multi-state model
LP_multi_coxph <- coxph(Surv(start, week_since, fstate) ~ I(Col+gsm1) + I(AOP2+AOP2.gsoh), LP_transit_cox_df, id = cage) # clear effect of AOP2-
LP_multi_cox.zph <- cox.zph(LP_multi_coxph) 
LP_multi_cox.zph # AOP2+ appears to violate cox assumption for food-chain to aphid transition
                         chisq df      p
I(Col + gsm1)_1:2       0.3055  1 0.5804
I(AOP2 + AOP2.gsoh)_1:2 6.6453  1 0.0099
I(Col + gsm1)_1:3       0.6182  1 0.4317
I(AOP2 + AOP2.gsoh)_1:3 0.0822  1 0.7744
GLOBAL                  7.3579  4 0.1181
plot(LP_multi_cox.zph[2]) # if anything, it appears we are underestimating the destabilizing effect of AOP2+, as it appears to initially increase the likelihood of a transition to the aphid only food web.

Version Author Date
c802852 mabarbour 2021-06-24
coxph(list(Surv(start, week_since, fstate) ~ 1,
           1:2 ~ I(Col+gsm1),
           1:3 ~ I(Col+gsm1) + I(AOP2+AOP2.gsoh)), LP_transit_cox_df, id = cage)
Call:
coxph(formula = list(Surv(start, week_since, fstate) ~ 1, 1:2 ~ 
    I(Col + gsm1), 1:3 ~ I(Col + gsm1) + I(AOP2 + AOP2.gsoh)), 
    data = LP_transit_cox_df, id = cage)

               
1:2                coef exp(coef) se(coef) robust se      z     p
  I(Col + gsm1) -0.1976    0.8207   0.3064    0.3164 -0.625 0.532

                     
1:3                      coef exp(coef) se(coef) robust se      z        p
  I(Col + gsm1)       -1.0582    0.3471   0.4462    0.2890 -3.661 0.000251
  I(AOP2 + AOP2.gsoh) -0.5175    0.5960   0.4611    0.4027 -1.285 0.198703

 States:  1= (s0), 2= 0-LYER-0, 3= 0-0-Ptoid 

Likelihood ratio test=7.41  on 3 df, p=0.05996
n= 50, number of events= 42 
# even after dropping AOP2+ effect on 1:2 transition, doesn't affect previously identified effect on food-chain to collapse.

coxph(Surv(start, week_since, fstate) ~ strata(temp) + I(Col+gsm1) + I(AOP2+AOP2.gsoh), LP_transit_cox_df, id = cage) # still a clear effect of AOP2- after stratifying by temperature
Call:
coxph(formula = Surv(start, week_since, fstate) ~ strata(temp) + 
    I(Col + gsm1) + I(AOP2 + AOP2.gsoh), data = LP_transit_cox_df, 
    id = cage)

                     
1:2                      coef exp(coef) se(coef) robust se      z     p
  I(Col + gsm1)       -0.2073    0.8127   0.3158    0.3257 -0.637 0.524
  I(AOP2 + AOP2.gsoh) -0.1845    0.8315   0.3151    0.3042 -0.607 0.544

                     
1:3                      coef exp(coef) se(coef) robust se      z       p
  I(Col + gsm1)       -0.8798    0.4149   0.4245    0.2805 -3.136 0.00171
  I(AOP2 + AOP2.gsoh) -0.5574    0.5727   0.4290    0.3847 -1.449 0.14742

 States:  1= (s0), 2= 0-LYER-0, 3= 0-0-Ptoid 

Likelihood ratio test=6.65  on 4 df, p=0.1553
n= 50, number of events= 42 
# note we can reproduce the multi-state model by focusing piecewise on this hazard rate 
coxph(Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ strata(temp) + I(Col+gsm1) + I(AOP2+AOP2.gsoh), LP_transit_cox_df) # id = cage no longer needed, including it gives the same results.
Call:
coxph(formula = Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ 
    strata(temp) + I(Col + gsm1) + I(AOP2 + AOP2.gsoh), data = LP_transit_cox_df)

                       coef exp(coef) se(coef)      z      p
I(Col + gsm1)       -0.8798    0.4149   0.4245 -2.072 0.0382
I(AOP2 + AOP2.gsoh) -0.5574    0.5727   0.4290 -1.299 0.1939

Likelihood ratio test=5.91  on 2 df, p=0.05202
n= 50, number of events= 17 
# this is good because then we can see what happens if we account for other sources of non-independence
coxph(Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ strata(temp) + I(Col+gsm1), LP_transit_cox_df) # effect persists when we have a more favorable event-to-variable ratio, although the coefficient has a slightly different meaning alone, so we retain both in the model.
Call:
coxph(formula = Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ 
    strata(temp) + I(Col + gsm1), data = LP_transit_cox_df)

                 coef exp(coef) se(coef)      z     p
I(Col + gsm1) -0.7242    0.4847   0.3663 -1.977 0.048

Likelihood ratio test=4.15  on 1 df, p=0.0416
n= 50, number of events= 17 
coxph(Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ strata(temp) + I(Col+gsm1) + I(AOP2+AOP2.gsoh) + cluster(com), LP_transit_cox_df) # as before, we observe potentially anti-conservative results when clustering at com level.
Call:
coxph(formula = Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ 
    strata(temp) + I(Col + gsm1) + I(AOP2 + AOP2.gsoh), data = LP_transit_cox_df, 
    cluster = com)

                       coef exp(coef) se(coef) robust se      z       p
I(Col + gsm1)       -0.8798    0.4149   0.4245    0.3372 -2.609 0.00907
I(AOP2 + AOP2.gsoh) -0.5574    0.5727   0.4290    0.2783 -2.003 0.04522

Likelihood ratio test=5.91  on 2 df, p=0.05202
n= 50, number of events= 17 
# results are robust to mixed-effect models
coxme(Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ strata(temp) + I(Col+gsm1) + I(AOP2+AOP2.gsoh) + (1|com), LP_transit_cox_df)
Cox mixed-effects model fit by maximum likelihood
  Data: LP_transit_cox_df
  events, n = 17, 50
  Iterations= 2 14 
                    NULL Integrated    Fitted
Log-likelihood -43.95128  -40.99597 -40.99107

                  Chisq df        p   AIC   BIC
Integrated loglik  5.91  3 0.116040 -0.09 -2.59
 Penalized loglik  5.92  2 0.052038  1.91  0.24

Model:  Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ strata(temp) +      I(Col + gsm1) + I(AOP2 + AOP2.gsoh) + (1 | com) 
Fixed coefficients
                          coef exp(coef)  se(coef)     z     p
I(Col + gsm1)       -0.8798872 0.4148297 0.4246916 -2.07 0.038
I(AOP2 + AOP2.gsoh) -0.5573989 0.5726967 0.4292309 -1.30 0.190

Random effects
 Group Variable  Std Dev      Variance    
 com   Intercept 0.0199914171 0.0003996568
coxme(Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ strata(temp) + I(Col+gsm1) + I(AOP2+AOP2.gsoh) + (1|com/temp), LP_transit_cox_df)
Cox mixed-effects model fit by maximum likelihood
  Data: LP_transit_cox_df
  events, n = 17, 50
  Iterations= 2 14 
                    NULL Integrated    Fitted
Log-likelihood -43.95128  -40.99625 -40.98585

                  Chisq   df        p   AIC   BIC
Integrated loglik  5.91 4.00 0.205970 -2.09 -5.42
 Penalized loglik  5.93 2.01 0.052023  1.91  0.24

Model:  Surv(start, week_since, fstate %in% c("0-0-Ptoid")) ~ strata(temp) +      I(Col + gsm1) + I(AOP2 + AOP2.gsoh) + (1 | com/temp) 
Fixed coefficients
                          coef exp(coef)  se(coef)     z     p
I(Col + gsm1)       -0.8799935 0.4147856 0.4247821 -2.07 0.038
I(AOP2 + AOP2.gsoh) -0.5574958 0.5726412 0.4293484 -1.30 0.190

Random effects
 Group    Variable    Std Dev      Variance    
 com/temp (Intercept) 0.0199972339 0.0003998894
 com      (Intercept) 0.0199914116 0.0003996565

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.7 LTS

Matrix products: default
BLAS:   /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] coxme_2.2-16    bdsmatrix_1.3-4 broom_0.7.11    survival_3.2-13
 [5] msm_1.6.8       cowplot_1.1.1   forcats_0.5.1   stringr_1.4.0  
 [9] dplyr_1.0.7     purrr_0.3.4     readr_2.1.1     tidyr_1.1.4    
[13] tibble_3.1.6    ggplot2_3.3.5   tidyverse_1.3.1 workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] httr_1.4.2        sass_0.4.0        viridisLite_0.4.0 bit64_4.0.5      
 [5] vroom_1.5.7       jsonlite_1.7.2    splines_4.1.2     modelr_0.1.8     
 [9] bslib_0.3.1       assertthat_0.2.1  expm_0.999-6      highr_0.9        
[13] cellranger_1.1.0  yaml_2.2.1        pillar_1.6.4      backports_1.4.1  
[17] lattice_0.20-45   glue_1.6.0        digest_0.6.29     promises_1.2.0.1 
[21] rvest_1.0.2       colorspace_2.0-2  htmltools_0.5.2   httpuv_1.6.5     
[25] Matrix_1.4-0      pkgconfig_2.0.3   haven_2.4.3       mvtnorm_1.1-3    
[29] scales_1.1.1      whisker_0.4       later_1.3.0       tzdb_0.2.0       
[33] git2r_0.28.0      farver_2.1.0      generics_0.1.1    ellipsis_0.3.2   
[37] withr_2.4.3       cli_3.1.0         magrittr_2.0.1    crayon_1.4.2     
[41] readxl_1.3.1      evaluate_0.14     fs_1.5.2          fansi_1.0.0      
[45] nlme_3.1-152      xml2_1.3.3        tools_4.1.2       hms_1.1.1        
[49] lifecycle_1.0.1   munsell_0.5.0     reprex_2.0.1      compiler_4.1.2   
[53] jquerylib_0.1.4   rlang_0.4.12      grid_4.1.2        rstudioapi_0.13  
[57] labeling_0.4.2    rmarkdown_2.11    gtable_0.3.0      DBI_1.1.2        
[61] R6_2.5.1          lubridate_1.8.0   knitr_1.37        bit_4.0.4        
[65] fastmap_1.1.0     utf8_1.2.2        rprojroot_2.0.2   stringi_1.7.3    
[69] parallel_4.1.2    Rcpp_1.0.7        vctrs_0.3.8       dbplyr_2.1.1     
[73] tidyselect_1.1.1  xfun_0.29