﻿_id	LARVAE
1	#use the raw data:
2	"larv <- read.csv(file=""C:/Users/rjolma/OneDrive - NIOZ/Databases and forms/Larvae07092023.csv"""
3	library(lubridate)
4	seasons = function(x){
5	"  if(x %in% 2:5) return(""Spring"")"
6	"  if(x %in% 6:7) return(""Summer"")"
7	"  if(x %in% 8:10) return(""Fall"")"
8	  if(x %in% c(11
9	  
10	}
11	larv$Season = sapply(month(larv$date)
12	
13	larv$red10 <- as.Date(larv$red10
14	larv$red14 <- as.Date(larv$red14
15	larv$red18 <- as.Date(larv$red18
16	larv$red22 <- as.Date(larv$red22
17	larv$red26 <- as.Date(larv$red26
18	
19	larv$fh10 <- as.Date(larv$fh10
20	larv$fh14 <- as.Date(larv$fh14
21	larv$fh18 <- as.Date(larv$fh18
22	larv$fh22 <- as.Date(larv$fh22
23	larv$fh26 <- as.Date(larv$fh26
24	
25	larv$fc10 <- as.Date(larv$fc10
26	larv$fc14 <- as.Date(larv$fc14
27	larv$fc18 <- as.Date(larv$fc18
28	larv$fc22 <- as.Date(larv$fc22
29	larv$fc26 <- as.Date(larv$fc26
30	
31	larv$ad10 <- as.Date(larv$ad10
32	larv$ad14 <- as.Date(larv$ad14
33	larv$ad18 <- as.Date(larv$ad18
34	larv$ad22 <- as.Date(larv$ad22
35	larv$ad26 <- as.Date(larv$ad26
36	
37	larv$fh10d<-as.numeric(difftime(larv$fh10
38	larv$fh14d<-as.numeric(difftime(larv$fh14
39	larv$fh18d<-as.numeric(difftime(larv$fh18
40	larv$fh22d<-as.numeric(difftime(larv$fh22
41	larv$fh26d<-as.numeric(difftime(larv$fh26
42	
43	larv$fc10d<-as.numeric(difftime(larv$fc10
44	larv$fc14d<-as.numeric(difftime(larv$fc14
45	larv$fc18d<-as.numeric(difftime(larv$fc18
46	larv$fc22d<-as.numeric(difftime(larv$fc22
47	larv$fc26d<-as.numeric(difftime(larv$fc26
48	
49	larv$ad10d<-as.numeric(difftime(larv$ad10
50	larv$ad14d<-as.numeric(difftime(larv$ad14
51	larv$ad18d<-as.numeric(difftime(larv$ad18
52	larv$ad22d<-as.numeric(difftime(larv$ad22
53	larv$ad26d<-as.numeric(difftime(larv$ad26
54	
55	#one came out as seconds and was then specified
56	larv$fh18d<-as.numeric(difftime(larv$fh18
57	
58	larv$X50d10 <- as.Date(larv$X50d10
59	larv$X50d14 <- as.Date(larv$X50d14
60	larv$X50d18 <- as.Date(larv$X50d18
61	larv$X50d22 <- as.Date(larv$X50d22
62	larv$X50d26 <- as.Date(larv$X50d26
63	
64	larv$X50d10d<-as.numeric(difftime(larv$X50d10
65	larv$X50d14d<-as.numeric(difftime(larv$X50d14
66	larv$X50d18d<-as.numeric(difftime(larv$X50d18
67	larv$X50d22d<-as.numeric(difftime(larv$X50d22
68	larv$X50d26d<-as.numeric(difftime(larv$X50d26
69	
70	#time from first copepodite to 50% dead:
71	larv$life10<-as.numeric(difftime(larv$X50d10
72	larv$life14<-as.numeric(difftime(larv$X50d14
73	larv$life18<-as.numeric(difftime(larv$X50d18
74	larv$life22<-as.numeric(difftime(larv$X50d22
75	larv$life26<-as.numeric(difftime(larv$X50d26
76	
77	
78	#Go from each egg sac (number) on a separate row to each observation on a separate row. Thus 5 rows per egg sac in the new format. We also want to keep information about the parasite species and season onboard:
79	library(reshape2)
80	dat.c<- melt(larv
81	"             value.name = ""time"")"
82	dat.h <- melt(larv
83	
84	
85	dat.d <- melt(larv
86	"              value.name = ""time"")"
87	dat.50d <- melt(larv
88	"                value.name = ""time"")"
89	
90	dat.a <- melt(larv
91	
92	
93	#make a success column in which all observations that have a number (a infectious stage appeared at some point) are 1 and all with NA are 0 (no infectious stage seen)
94	dat.c$time<-as.numeric(dat.c$value)
95	dat.c$success<-dat.c$time
96	library(dplyr)
97	dat.c <- dat.c %>% mutate(success = ifelse(is.na(success)
98	dat.c$success[dat.c$success>0]<-1
99	#species separated:
100	
101	#success models:
102	#first looking at the effect of season separately:
103	fisher.test(ori$success
104	fisher.test(int$success
105	
106	library(lme4)
107	sucmodel3<-glmer(success ~ ori * temperature+ (1|number)
108	summary(sucmodel3)
109	
110	sucmodel4<-glmer(success ~ ori + temperature+ (1|number)
111	summary(sucmodel4)
112	
113	anova(sucmodel3
114	
115	ori<-subset(dat.c
116	int<-subset(dat.c
117	
118	sucmodeli<-glmer(success ~  temperature+ (1|number)
119	summary(sucmodeli)
120	
121	sucmodelo<-glmer(success ~  temperature+ (1|number)
122	summary(sucmodelo)
123	
124	#Poisson models:
125	#first hatch
126	
127	
128	dat.h$ori<-as.factor(dat.h$ori)
129	summary(h1 <- glmer(time ~ temperature + ori + (1 | number)
130	summary(h2 <- glmer(time ~ temperature * ori + (1 | number)
131	anova(h1
132	
133	
134	#First copepodite
135	dat.c$ori<-as.factor(dat.c$ori)
136	summary(c1 <- glmer(time ~ temperature + ori + (1 | number)
137	summary(c2 <- glmer(time ~ temperature * ori + (1 | number)
138	anova(c1
139	
140	#50% dead:
141	dat.50d$ori<-as.factor(dat.50d$ori)
142	summary(d1 <- glmer(time ~ temperature + ori + (1 | number)
143	summary(d2 <- glmer(time ~ temperature * ori + (1 | number)
144	anova (d1
145	
146	# copepodite lifespan
147	dat.a$ori<-as.factor(dat.a$ori)
148	summary(cl1 <- glmer(time ~ temperature + ori + (1 | number)
149	summary(cl2 <- glmer(time ~ temperature * ori + (1 | number)
150	anova(cl1
151	
152	dat.c$temperature<- as.character(dat.c$temperature)
153	"dat.c[""temperature""][dat.c[""temperature""] == ""f10d""] <- ""10"""
154	"dat.c[""temperature""][dat.c[""temperature""] == ""f14d""] <- ""14"""
155	"dat.c[""temperature""][dat.c[""temperature""] == ""f18d""] <- ""18"""
156	"dat.c[""temperature""][dat.c[""temperature""] == ""f22d""] <- ""22"""
157	"dat.c[""temperature""][dat.c[""temperature""] == ""f26d""] <- ""26"""
158	
159	#separate poissons by species
160	
161	dat.hi<- subset(dat.h
162	dat.ho<- subset(dat.h
163	
164	dat.ci<- subset(dat.c
165	dat.co<- subset(dat.c
166	
167	dat.50di<- subset(dat.50d
168	dat.50do<- subset(dat.50d
169	
170	dat.ai<- subset(dat.a
171	dat.ao<- subset(dat.a
172	
173	summary(hi1 <- glmer(time ~ temperature + (1 | number)
174	summary(ho1 <- glmer(time ~ temperature + (1 | number)
175	
176	summary(ci1 <- glmer(time ~ temperature + (1 | number)
177	summary(co1 <- glmer(time ~ temperature + (1 | number)
178	
179	summary(d50i1 <- glmer(time ~ temperature + (1 | number)
180	summary(d50o1 <- glmer(time ~ temperature + (1 | number)
181	
182	summary(ai1 <- glmer(time ~ temperature + (1 | number)
183	summary(ao1 <- glmer(time ~ temperature + (1 | number)
184	
185	#Figure 2 (response times)
186	dat.h <- melt(larv
187	dat.d <- melt(larv
188	dat.50d <- melt(larv
189	
190	"names(dat.h)[names(dat.h) == ""ori""] <- ""Species"""
191	dat.h$Species<-as.character(dat.h$Species)
192	"dat.h[""Species""][dat.h[""Species""] == 0] <- ""M. intestinalis"""
193	"dat.h[""Species""][dat.h[""Species""] == 1] <- ""M. orientalis"""
194	
195	"names(dat.50d)[names(dat.50d) == ""ori""] <- ""Species"""
196	dat.50d$Species<-as.character(dat.50d$Species)
197	"dat.50d[""Species""][dat.50d[""Species""] == 0] <- ""M. intestinalis"""
198	"dat.50d[""Species""][dat.50d[""Species""] == 1] <- ""M. orientalis"""
199	
200	"names(dat.d)[names(dat.d) == ""ori""] <- ""Species"""
201	dat.d$Species<-as.character(dat.d$Species)
202	"dat.d[""Species""][dat.d[""Species""] == 0] <- ""M. intestinalis"""
203	"dat.d[""Species""][dat.d[""Species""] == 1] <- ""M. orientalis"""
204	
205	dat.50d$temperature<- as.character(dat.50d$temperature)
206	"dat.50d[""temperature""][dat.50d[""temperature""] == ""X50d10d""] <- ""10"""
207	"dat.50d[""temperature""][dat.50d[""temperature""] == ""X50d14d""] <- ""14"""
208	"dat.50d[""temperature""][dat.50d[""temperature""] == ""X50d18d""] <- ""18"""
209	"dat.50d[""temperature""][dat.50d[""temperature""] == ""X50d22d""] <- ""22"""
210	"dat.50d[""temperature""][dat.50d[""temperature""] == ""X50d26d""] <- ""26"""
211	dat.50d$temperature<- as.factor(dat.50d$temperature)
212	dat.50d$Species<-as.factor(dat.50d$Species)
213	
214	dat.h$temperature<- as.character(dat.h$temperature)
215	"dat.h[""temperature""][dat.h[""temperature""] == ""fh10d""] <- ""10"""
216	"dat.h[""temperature""][dat.h[""temperature""] == ""fh14d""] <- ""14"""
217	"dat.h[""temperature""][dat.h[""temperature""] == ""fh18d""] <- ""18"""
218	"dat.h[""temperature""][dat.h[""temperature""] == ""fh22d""] <- ""22"""
219	"dat.h[""temperature""][dat.h[""temperature""] == ""fh26d""] <- ""26"""
220	dat.h$temperature<- as.factor(dat.h$temperature)
221	dat.h$Species<-as.factor(dat.h$Species)
222	
223	dat.d$temperature<- as.character(dat.d$temperature)
224	"dat.d[""temperature""][dat.d[""temperature""] == ""ad10d""] <- ""10"""
225	"dat.d[""temperature""][dat.d[""temperature""] == ""ad14d""] <- ""14"""
226	"dat.d[""temperature""][dat.d[""temperature""] == ""ad18d""] <- ""18"""
227	"dat.d[""temperature""][dat.d[""temperature""] == ""ad22d""] <- ""22"""
228	"dat.d[""temperature""][dat.d[""temperature""] == ""ad26d""] <- ""26"""
229	dat.d$temperature<- as.factor(dat.d$temperature)
230	dat.d$Species<-as.factor(dat.d$Species)
231	
232	
233	ph<-ggplot(dat.h
234	"  labs(x = ""Temperature (C)"""
235	  theme(text = element_text(size = 15))   +
236	"  scale_color_manual(values=c(""blue3"""
237	  geom_boxplot()+ 
238	"  ggtitle(""First hatching"") +"
239	  ylim(0
240	ph
241	pc<-ggplot(dat.c
242	"  labs(x = ""Temperature (C)"""
243	  theme(text = element_text(size = 15))   +
244	"  scale_color_manual(values=c(""blue3"""
245	  geom_boxplot()+ 
246	"  ggtitle(""Infectious stage"") +"
247	  ylim(0
248	pc
249	pd<-ggplot(dat.d
250	"  labs(x = ""Temperature (C)"""
251	  theme(text = element_text(size = 15))   +
252	"  scale_color_manual(values=c(""blue3"""
253	  geom_boxplot()+ 
254	"  ggtitle(""All dead"") +"
255	  ylim(0
256	pd
257	p50d<-ggplot(dat.50d
258	"  labs(x = ""Temperature (C)"""
259	  theme(text = element_text(size = 15))   +
260	"  scale_color_manual(values=c(""blue3"""
261	  geom_boxplot()+ 
262	"  ggtitle(""50% dead"") +"
263	  ylim(0
264	p50d
265	ggarrange(ph
266	          ncol = 2
267	
268	#lifespan:
269	#time from first copepodite to 50% dead:
270	larv$life10<-as.numeric(difftime(larv$X50d10
271	larv$life14<-as.numeric(difftime(larv$X50d14
272	larv$life18<-as.numeric(difftime(larv$X50d18
273	larv$life22<-as.numeric(difftime(larv$X50d22
274	larv$life26<-as.numeric(difftime(larv$X50d26
275	
276	library(reshape2)
277	dat.a <- melt(larv
278	
279	dat.a <- melt(larv
280	"dat.a$temperature <- sub(""life"""
281	str(dat.a)
282	dat.a$temperature<- as.factor(dat.a$temperature)
283	dat.a$Season<- as.factor(dat.a$Season)
284	dat.a$ori<- as.factor(dat.a$ori)
285	pa<-ggplot(dat.a
286	"  labs(x = ""Temperature (C)"""
287	  theme(text = element_text(size = 15))   +
288	"  scale_color_manual(values=c(""blue3"""
289	  geom_boxplot()+ 
290	"  ggtitle(""Copepodite lifespan"") +"
291	  ylim(0
292	pa
293	
294	
295	
296	
297	
298	
299	
300	
301	
302	
303	
304	
305	
306	
307	
308	
309	
310	
311	
312	
313	
314	#STAGES INSIDE HOSTS:  
315	
316	"par <- read.csv(file=""C:/Users/rjolma/OneDrive - NIOZ/Documenten/Project planning/R digging/adults.csv"""
317	par$end_date <- as.Date(par$end_date
318	par$days<-difftime(par$end_date
319	par$days<-as.numeric(par$days)
320	par$tempi <- par$temp
321	par$tempi <- as.factor(par$tempi)
322	par$plength <- as.numeric(par$plength)
323	parin<- subset(par
324	parinalive<- subset(parin
325	pars<-subset(parinalive
326	pars$g<-as.factor(pars$g)
327	
328	aso<-subset(pars
329	asi<-subset(pars
330	
331	aso10<- subset(aso
332	aso14<- subset(aso
333	aso18<- subset(aso
334	aso22<- subset(aso
335	aso26<- subset(aso
336	
337	asi10<- subset(asi
338	asi14<- subset(asi
339	asi18<- subset(asi
340	asi22<- subset(asi
341	asi26<- subset(asi
342	#host entry success
343	
344	#with linear temperature:
345	sucf242<-glmer(in24h ~ ori * temp + (1|number)
346	sucf243<-glmer(in24h ~ ori + temp + (1|number)
347	anova(sucf242
348	summary(sucf242)
349	summary(sucf243)
350	
351	#with categorical temperature:
352	sucfl<-glmer(in24h ~ ori * tempi + (1|number)
353	sucfl2<-glmer(in24h ~ ori + tempi + (1|number)
354	anova(sucfl
355	summary(sucfl)
356	summary(sucfl2)
357	
358	#by species:
359	orip<-subset(par
360	intp<-subset(par
361	
362	suci<-glmer(in24h ~  tempi + (1|number)
363	suco<-glmer(in24h ~  tempi + (1|number)
364	summary(suci)
365	summary(suco)
366	
367	#confidence intervals:
368	cc24 <-confint(sucfl2
369	ctab24 <- cbind(est=fixef(sucfl2)
370	rtab24 <- exp(ctab24)
371	print(rtab24
372	
373	cc24i <-confint(suci
374	ctab24i <- cbind(est=fixef(suci)
375	rtab24i <- exp(ctab24i)
376	print(rtab24i
377	
378	cc24o <-confint(suco
379	ctab24o <- cbind(est=fixef(suco)
380	rtab24o <- exp(ctab24o)
381	print(rtab24o
382	
383	#infection success:
384	#removed parasites that were clearly of second generation:
385	
386	parinalive1 <- parinalive[(parinalive$X1stgen == 1 | is.na(parinalive$X1stgen) | parinalive$X1stgen != 0)
387	str(parinalive1)
388	
389	#with linear temperature:
390	sucin1<-glmer(inend ~ ori * temp + (1|number)
391	sucin2<-glmer(inend ~ ori + temp + (1|number)
392	anova(sucin1
393	summary(sucin1)
394	summary(sucin2)
395	
396	#with categorical temperature:
397	sucin3<-glmer(inend ~ ori * tempi + (1|number)
398	sucin4<-glmer(inend ~ ori + tempi + (1|number)
399	anova(sucin3
400	summary(sucin3)
401	summary(sucin4)
402	
403	#by species:
404	oripin<-subset(parinalive1
405	intpin<-subset(parinalive1
406	
407	suciin<-glmer(inend ~  tempi + (1|number)
408	sucoin<-glmer(inend ~  tempi + (1|number)
409	summary(suciin)
410	summary(sucoin)
411	
412	#confidence intervals:
413	ccin <-confint(sucin4
414	ctabin<- cbind(est=fixef(sucin4)
415	rtabin <- exp(ctabin)
416	print(rtabin
417	
418	cci <-confint(suciin
419	ctabi <- cbind(est=fixef(suciin)
420	rtabi <- exp(ctabi)
421	print(rtabi
422	
423	cco <-confint(sucoin
424	ctabo <- cbind(est=fixef(sucoin)
425	rtabo <- exp(ctabo)
426	print(rtabo
427	
428	
429	#Figure 3:
430	
431	p1<- ggplot(aso10
432	  geom_point(aes(shape=g
433	"  ggtitle(expression(italic(""Mytilicola orientalis"") ~ ""10C"")) +"
434	"  scale_color_manual(values=c(""#00BFC4"""
435	"  labs(x = ""Days"""
436	  ylim(0
437	  xlim(50
438	  geom_hline(yintercept = 3.55
439	p1
440	p2<- ggplot(aso14
441	  geom_point(aes(shape=g
442	"  ggtitle(""14C"") +"
443	"  scale_color_manual(values=c(""#00BFC4"""
444	"  labs(x = ""Days"""
445	  ylim(0
446	  xlim(50
447	  geom_hline(yintercept = 3.55
448	
449	p3<- ggplot(aso18
450	  geom_point(aes(shape=g
451	"  ggtitle(""18C"") +"
452	"  scale_color_manual(values=c(""#00BFC4"""
453	"  labs(x = ""Days"""
454	  ylim(0
455	  xlim(50
456	  geom_hline(yintercept = 3.55
457	
458	p4<- ggplot(aso22
459	  geom_point(aes(shape=g
460	"  ggtitle(""22C"") +"
461	"  scale_color_manual(values=c(""#00BFC4"""
462	"  labs(x = ""Days"""
463	  ylim(0
464	  xlim(50
465	  geom_hline(yintercept = 3.55
466	
467	p5<- ggplot(aso26
468	  geom_point(aes(shape=g
469	"  ggtitle(""26C"") +"
470	"  scale_color_manual(values=c(""#00BFC4"""
471	"  labs(x = ""Days"""
472	  ylim(0
473	  xlim(50
474	  geom_hline(yintercept = 3.55
475	
476	
477	
478	p6 <- ggplot(asi10
479	  geom_point(aes(shape=g
480	"  ggtitle(expression(italic(""Mytilicola intestinalis"") ~ ""10C"")) +"
481	"  scale_color_manual(values=c(""#F8766D"""
482	"  labs(x = ""Days"""
483	  ylim(0
484	  xlim(50
485	  geom_hline(yintercept = 4.23
486	
487	p6
488	
489	p6
490	p7<- ggplot(asi14
491	  geom_point(aes(shape=g
492	"  ggtitle(""14C"") +"
493	"  scale_color_manual(values=c(""#F8766D"""
494	"  labs(x = ""Days"""
495	  ylim(0
496	  xlim(50
497	  geom_hline(yintercept = 4.23
498	p7
499	p8<- ggplot(asi18
500	  geom_point(aes(shape=g
501	"  ggtitle(""18C"") +"
502	"  scale_color_manual(values=c(""#F8766D"""
503	"  labs(x = ""Days"""
504	  ylim(0
505	  xlim(50
506	  geom_hline(yintercept = 4.23
507	p8
508	p9<- ggplot(asi22
509	  geom_point(aes(shape=g
510	"  ggtitle(""22C"") +"
511	"  scale_color_manual(values=c(""#F8766D"""
512	"  labs(x = ""Days"""
513	  ylim(0
514	  xlim(50
515	  geom_hline(yintercept = 4.23
516	
517	p10<- ggplot(asi26
518	  geom_point(aes(shape=g
519	"  ggtitle(""26C"") +"
520	"  scale_color_manual(values=c(""#F8766D"""
521	"  labs(x = ""Days"""
522	  ylim(0
523	  xlim(50
524	  geom_hline(yintercept = 4.23
525	
526	ggarrange(p6
527	          ncol = 2
528	# exported as a tiff with dimensions of 700x1100
529	
530	#LENGTH REGRESSION:
531	
532	#subsets for until reproductive size
533	#theoretical as does not get there: aso10r = aso10
534	aso14r<- subset(aso14
535	aso18r<- subset(aso18
536	aso22r<- subset(aso22
537	aso26r<- subset(aso26
538	
539	asi10r<- subset(asi10
540	asi14r<- subset(asi14
541	asi18r<- subset(asi18
542	asi22r<- subset(asi22
543	asi26r<- subset(asi26
544	
545	#subsets for until maximum size 
546	aso10m<-subset(aso10
547	aso14m<- subset(aso14
548	aso18m<- subset(aso18
549	aso22m<- subset(aso22
550	aso26m<- subset(aso26
551	
552	asi10m<- subset(asi10
553	asi14m<- subset(asi14
554	asi18m<- subset(asi18
555	asi22m<- subset(asi22
556	asi26m<- subset(asi26
557	
558	#with also the non-relevant:
559	#until the reproductive size:
560	p1<- ggplot(aso10
561	  geom_point(aes(shape=g
562	"  ggtitle(""M. orientalis 10C"") +"
563	"  scale_color_manual(values=c(""steelblue"""
564	"  labs(x = ""Days"""
565	  ylim(0
566	  xlim(0
567	  geom_hline(yintercept = 3.55)
568	
569	p2<- ggplot(aso14r
570	  geom_point(aes(shape=g
571	"  ggtitle(""M. orientalis 14C"") +"
572	"  scale_color_manual(values=c(""steelblue"""
573	"  labs(x = ""Days"""
574	  ylim(0
575	  xlim(0
576	  geom_hline(yintercept = 3.55)
577	
578	p3<- ggplot(aso18r
579	  geom_point(aes(shape=g
580	"  ggtitle(""M. orientalis 18C"") +"
581	"  scale_color_manual(values=c(""steelblue"""
582	"  labs(x = ""Days"""
583	  ylim(0
584	  xlim(0
585	  geom_hline(yintercept = 3.55)
586	
587	p4<- ggplot(aso22r
588	  geom_point(aes(shape=g
589	"  ggtitle(""M. orientalis 22C"") +"
590	"  scale_color_manual(values=c(""steelblue"""
591	"  labs(x = ""Days"""
592	  ylim(0
593	  xlim(0
594	  geom_hline(yintercept = 3.55)
595	
596	p5<- ggplot(aso26r
597	  geom_point(aes(shape=g
598	"  ggtitle(""M. orientalis 26C"") +"
599	"  scale_color_manual(values=c(""steelblue"""
600	"  labs(x = ""Days"""
601	  ylim(0
602	  xlim(0
603	  geom_hline(yintercept = 3.55)
604	
605	p6<- ggplot(asi10r
606	  geom_point(aes(shape=g
607	"  ggtitle(""M. intestinalis 10C"") +"
608	"  scale_color_manual(values=c(""steelblue"""
609	"  labs(x = ""Days"""
610	  ylim(0
611	  xlim(0
612	  geom_hline(yintercept = 4.23)
613	
614	p7<- ggplot(asi14r
615	  geom_point(aes(shape=g
616	"  ggtitle(""M. intestinalis 14C"") +"
617	"  scale_color_manual(values=c(""steelblue"""
618	"  labs(x = ""Days"""
619	  ylim(0
620	  xlim(0
621	  geom_hline(yintercept = 4.23)
622	
623	p8<- ggplot(asi18r
624	  geom_point(aes(shape=g
625	"  ggtitle(""M. intestinalis 18C"") +"
626	"  scale_color_manual(values=c(""steelblue"""
627	"  labs(x = ""Days"""
628	  ylim(0
629	  xlim(0
630	  geom_hline(yintercept = 4.23)
631	
632	p9<- ggplot(asi22r
633	  geom_point(aes(shape=g
634	"  ggtitle(""M. intestinalis 22C"") +"
635	"  scale_color_manual(values=c(""steelblue"""
636	"  labs(x = ""Days"""
637	  ylim(0
638	  xlim(0
639	  geom_hline(yintercept = 4.23)
640	
641	p10<- ggplot(asi26r
642	  geom_point(aes(shape=g
643	"  ggtitle(""M. intestinalis 26C"") +"
644	"  scale_color_manual(values=c(""steelblue"""
645	"  labs(x = ""Days"""
646	  ylim(0
647	  xlim(0
648	  geom_hline(yintercept = 4.23)
649	p1
650	p2
651	p3
652	p4
653	p5
654	p6
655	p7
656	p8
657	p9
658	p10
659	
660	ggarrange(p1
661	          ncol = 2
662	
663	#until maximal size:
664	p1<- ggplot(aso10m
665	  geom_point(aes(shape=g
666	"  ggtitle(""M. orientalis 10C"") +"
667	"  scale_color_manual(values=c(""steelblue"""
668	"  labs(x = ""Days"""
669	  ylim(0
670	  xlim(0
671	  geom_hline(yintercept = 3.55)
672	
673	p2<- ggplot(aso14m
674	  geom_point(aes(shape=g
675	"  ggtitle(""M. orientalis 14C"") +"
676	"  scale_color_manual(values=c(""steelblue"""
677	"  labs(x = ""Days"""
678	  ylim(0
679	  xlim(0
680	  geom_hline(yintercept = 3.55)
681	
682	p3<- ggplot(aso18m
683	  geom_point(aes(shape=g
684	"  ggtitle(""M. orientalis 18C"") +"
685	"  scale_color_manual(values=c(""steelblue"""
686	"  labs(x = ""Days"""
687	  ylim(0
688	  xlim(0
689	  geom_hline(yintercept = 3.55)
690	
691	p4<- ggplot(aso22m
692	  geom_point(aes(shape=g
693	"  ggtitle(""M. orientalis 22C"") +"
694	"  scale_color_manual(values=c(""steelblue"""
695	"  labs(x = ""Days"""
696	  ylim(0
697	  xlim(0
698	  geom_hline(yintercept = 3.55)
699	
700	p5<- ggplot(aso26m
701	  geom_point(aes(shape=g
702	"  ggtitle(""M. orientalis 26C"") +"
703	"  scale_color_manual(values=c(""steelblue"""
704	"  labs(x = ""Days"""
705	  ylim(0
706	  xlim(0
707	  geom_hline(yintercept = 3.55)
708	
709	p6<- ggplot(asi10m
710	  geom_point(aes(shape=g
711	"  ggtitle(""M. intestinalis 10C"") +"
712	"  scale_color_manual(values=c(""steelblue"""
713	"  labs(x = ""Days"""
714	  ylim(0
715	  xlim(0
716	  geom_hline(yintercept = 4.23)
717	
718	p7<- ggplot(asi14m
719	  geom_point(aes(shape=g
720	"  ggtitle(""M. intestinalis 14C"") +"
721	"  scale_color_manual(values=c(""steelblue"""
722	"  labs(x = ""Days"""
723	  ylim(0
724	  xlim(0
725	  geom_hline(yintercept = 4.23)
726	
727	p8<- ggplot(asi18m
728	  geom_point(aes(shape=g
729	"  ggtitle(""M. intestinalis 18C"") +"
730	"  scale_color_manual(values=c(""steelblue"""
731	"  labs(x = ""Days"""
732	  ylim(0
733	  xlim(0
734	  geom_hline(yintercept = 4.23)
735	
736	p9<- ggplot(asi22m
737	  geom_point(aes(shape=g
738	"  ggtitle(""M. intestinalis 22C"") +"
739	"  scale_color_manual(values=c(""steelblue"""
740	"  labs(x = ""Days"""
741	  ylim(0
742	  xlim(0
743	  geom_hline(yintercept = 4.23)
744	
745	p10<- ggplot(asi26m
746	  geom_point(aes(shape=g
747	"  ggtitle(""M. intestinalis 26C"") +"
748	"  scale_color_manual(values=c(""steelblue"""
749	"  labs(x = ""Days"""
750	  ylim(0
751	  xlim(0
752	  geom_hline(yintercept = 4.23)
753	p1
754	p2
755	p3
756	p4
757	p5
758	p6
759	p7
760	p8
761	p9
762	p10
763	
764	ggarrange(p1
765	          ncol = 2
766	
767	#linear regression with and without log transformation:
768	
769	intercept <- 0.27
770	lmo10 <- lm(I(plength - intercept) ~ 0 + days
771	summary(lmo10)
772	lmo14r <- lm(I(plength - intercept) ~ 0 + days
773	summary(lmo14r)
774	lmo18r <- lm(I(plength - intercept) ~ 0 + days
775	summary(lmo18r)
776	lmo22r <- lm(I(plength - intercept) ~ 0 + days
777	summary(lmo22r)
778	lmo26r <- lm(I(plength - intercept) ~ 0 + days
779	summary(lmo26r)
780	
781	
782	
783	
784	p1<- ggplot(aso10
785	  geom_point(aes(shape=g
786	"  ggtitle(""M. orientalis 10C"") +"
787	"  scale_color_manual(values=c(""steelblue"""
788	"  labs(x = ""Days"""
789	  ylim(0
790	  xlim(0
791	  geom_abline(intercept = intercept
792	  geom_hline(yintercept = 3.55)
793	p1
794	
795	p2<- ggplot(aso14r
796	  geom_point(aes(shape=g
797	"  ggtitle(""M. orientalis 14C"") +"
798	"  scale_color_manual(values=c(""steelblue"""
799	"  labs(x = ""Days"""
800	  ylim(0
801	  xlim(0
802	  geom_abline(intercept = intercept
803	  geom_hline(yintercept = 3.55)
804	p2
805	
806	
807	p3<- ggplot(aso18r
808	  geom_point(aes(shape=g
809	"  ggtitle(""M. orientalis 18C"") +"
810	"  scale_color_manual(values=c(""steelblue"""
811	"  labs(x = ""Days"""
812	  ylim(0
813	  xlim(0
814	  geom_abline(intercept = intercept
815	  geom_hline(yintercept = 3.55)
816	p3
817	
818	
819	p4<- ggplot(aso22r
820	  geom_point(aes(shape=g
821	"  ggtitle(""M. orientalis 22C"") +"
822	"  scale_color_manual(values=c(""steelblue"""
823	"  labs(x = ""Days"""
824	  ylim(0
825	  xlim(0
826	  geom_abline(intercept = intercept
827	  geom_hline(yintercept = 3.55)
828	p4
829	
830	p5<- ggplot(aso26r
831	  geom_point(aes(shape=g
832	"  ggtitle(""M. orientalis 26C"") +"
833	"  scale_color_manual(values=c(""steelblue"""
834	"  labs(x = ""Days"""
835	  ylim(0
836	  xlim(0
837	  geom_abline(intercept = intercept
838	  geom_hline(yintercept = 3.55)
839	p5
840	
841	
842	
843	intercept <- 0.47
844	lmi10r <- lm(I(plength - intercept) ~ 0 + days
845	summary(lmi10r)
846	lmi14r <- lm(I(plength - intercept) ~ 0 + days
847	summary(lmi14r)
848	lmi18r <- lm(I(plength - intercept) ~ 0 + days
849	summary(lmi18r)
850	lmi22r <- lm(I(plength - intercept) ~ 0 + days
851	summary(lmi22r)
852	lmi26r <- lm(I(plength - intercept) ~ 0 + days
853	summary(lmi26r)
854	
855	
856	p6<- ggplot(asi10r
857	  geom_point(aes(shape=g
858	"  ggtitle(""M. intestinalis 10C"") +"
859	"  scale_color_manual(values=c(""steelblue"""
860	"  labs(x = ""Days"""
861	  ylim(0
862	  xlim(0
863	  geom_abline(intercept = intercept
864	  geom_hline(yintercept = 4.23)
865	p6
866	
867	p7<- ggplot(asi14r
868	  geom_point(aes(shape=g
869	"  ggtitle(""M. intestinalis 14C"") +"
870	"  scale_color_manual(values=c(""steelblue"""
871	"  labs(x = ""Days"""
872	  ylim(0
873	  xlim(0
874	  geom_abline(intercept = intercept
875	  geom_hline(yintercept = 4.23)
876	p7
877	
878	
879	p8<- ggplot(asi18r
880	  geom_point(aes(shape=g
881	"  ggtitle(""M. intestinalis 18C"") +"
882	"  scale_color_manual(values=c(""steelblue"""
883	"  labs(x = ""Days"""
884	  ylim(0
885	  xlim(0
886	  geom_abline(intercept = intercept
887	  geom_hline(yintercept = 4.23)
888	p8
889	
890	
891	p9<- ggplot(asi22r
892	  geom_point(aes(shape=g
893	"  ggtitle(""M. intestinalis 22C"") +"
894	"  scale_color_manual(values=c(""steelblue"""
895	"  labs(x = ""Days"""
896	  ylim(0
897	  xlim(0
898	  geom_abline(intercept = intercept
899	  geom_hline(yintercept = 4.23)
900	p9
901	
902	p10<- ggplot(asi26r
903	  geom_point(aes(shape=g
904	"  ggtitle(""M. intestinalis 26C"") +"
905	"  scale_color_manual(values=c(""steelblue"""
906	"  labs(x = ""Days"""
907	  ylim(0
908	  xlim(0
909	  geom_abline(intercept = intercept
910	  geom_hline(yintercept = 4.23)
911	p10
912	
913	ggarrange(p1
914	          ncol = 2
915	
916	#The same with log transformation:
917	  
918	  # Specify the desired intercept
919	  intercept <- log(0.27)  # Log-transformed intercept value
920	  intercept
921	
922	# Log-transform the length measurements
923	aso10$log_plength <- log(aso10$plength)
924	aso14r$log_plength <- log(aso14r$plength)
925	aso18r$log_plength <- log(aso18r$plength)
926	aso22r$log_plength <- log(aso22r$plength)
927	aso26r$log_plength <- log(aso26r$plength)
928	
929	lmo10 <- lm(I(log_plength - intercept) ~ 0 + days
930	summary(lmo10)
931	lmo14r <- lm(I(log_plength - intercept) ~ 0 + days
932	summary(lmo14r)
933	lmo18r <- lm(I(log_plength - intercept) ~ 0 + days
934	summary(lmo18r)
935	lmo22r <- lm(I(log_plength - intercept) ~ 0 + days
936	summary(lmo22r)
937	lmo26r <- lm(I(log_plength - intercept) ~ 0 + days
938	summary(lmo26r)
939	
940	p1<- ggplot(aso10
941	  geom_point(aes(shape=g
942	"    ggtitle(expression(italic(""Mytilicola orientalis"") ~ ""10C"")) +"
943	"  scale_color_manual(values=c(""#00BFC4"""
944	"  labs(x = ""Days"""
945	  ylim(-2
946	  xlim(0
947	  geom_abline(intercept = intercept
948	  geom_hline(yintercept = 1.266948)
949	p1
950	
951	p2<- ggplot(aso14r
952	  geom_point(aes(shape=g
953	"  ggtitle(""14C "") +"
954	"  scale_color_manual(values=c(""#00BFC4"""
955	"  labs(x = ""Days"""
956	  ylim(-2
957	  xlim(0
958	  geom_abline(intercept = intercept
959	  geom_hline(yintercept = 1.266948)
960	p2
961	
962	
963	p3<- ggplot(aso18r
964	  geom_point(aes(shape=g
965	"  ggtitle(""18C "") +"
966	"  scale_color_manual(values=c(""#00BFC4"""
967	"  labs(x = ""Days"""
968	  ylim(-2
969	  xlim(0
970	  geom_abline(intercept = intercept
971	  geom_hline(yintercept = 1.266948)
972	p3
973	
974	
975	p4<- ggplot(aso22r
976	  geom_point(aes(shape=g
977	"  ggtitle(""22C "") +"
978	"  scale_color_manual(values=c(""#00BFC4"""
979	"  labs(x = ""Days"""
980	  ylim(-2
981	  xlim(0
982	  geom_abline(intercept = intercept
983	  geom_hline(yintercept = 1.266948)
984	p4
985	
986	p5<- ggplot(aso26r
987	  geom_point(aes(shape=g
988	"  ggtitle(""26C"") +"
989	"  scale_color_manual(values=c(""#00BFC4"""
990	"  labs(x = ""Days"""
991	  ylim(-2
992	  xlim(0
993	  geom_abline(intercept = intercept
994	  geom_hline(yintercept = 1.266948)
995	p5
996	
997	# Specify the desired intercept
998	intercept <- log(0.47)  # Log-transformed intercept value
999	intercept
1000	
1001	# Log-transform the length measurements
1002	asi10r$log_plength <- log(asi10r$plength)
1003	asi14r$log_plength <- log(asi14r$plength)
1004	asi18r$log_plength <- log(asi18r$plength)
1005	asi22r$log_plength <- log(asi22r$plength)
1006	asi26r$log_plength <- log(asi26r$plength)
1007	# Fit a linear regression model with the log-transformed intercept
1008	fit <- lm(log_plength ~ 0 + days
1009	
1010	
1011	lmi10r <- lm(I(log_plength - intercept) ~ 0 + days
1012	summary(lmi10r)
1013	lmi14r <- lm(I(log_plength - intercept) ~ 0 + days
1014	summary(lmi14r)
1015	lmi18r <- lm(I(log_plength - intercept) ~ 0 + days
1016	summary(lmi18r)
1017	lmi22r <- lm(I(log_plength - intercept) ~ 0 + days
1018	summary(lmi22r)
1019	lmi26r <- lm(I(log_plength - intercept) ~ 0 + days
1020	summary(lmi26r)
1021	
1022	
1023	log(4.23)
1024	
1025	p6<- ggplot(asi10r
1026	  geom_point(aes(shape=g
1027	"ggtitle(expression(italic(""Mytilicola intestinalis"") ~ ""10C"")) +  scale_color_manual(values=c(""#F8766D"""
1028	"  labs(x = ""Days"""
1029	  ylim(-2
1030	  xlim(0
1031	  geom_abline(intercept = intercept
1032	  geom_hline(yintercept = 1.442202)
1033	p6
1034	
1035	p7<- ggplot(asi14r
1036	  geom_point(aes(shape=g
1037	"  ggtitle(""14C "") +"
1038	"  scale_color_manual(values=c(""#F8766D"""
1039	"  labs(x = ""Days"""
1040	  ylim(-2
1041	  xlim(0
1042	  geom_abline(intercept = intercept
1043	  geom_hline(yintercept = 1.442202)
1044	p7
1045	
1046	
1047	p8<- ggplot(asi18r
1048	  geom_point(aes(shape=g
1049	"  ggtitle(""18C "") +"
1050	"  scale_color_manual(values=c(""#F8766D"""
1051	"  labs(x = ""Days"""
1052	  ylim(-2
1053	  xlim(0
1054	  geom_abline(intercept = intercept
1055	  geom_hline(yintercept = 1.442202)
1056	p8
1057	
1058	
1059	p9<- ggplot(asi22r
1060	  geom_point(aes(shape=g
1061	"  ggtitle(""22C "") +"
1062	"  scale_color_manual(values=c(""#F8766D"""
1063	"  labs(x = ""Days"""
1064	  ylim(-2
1065	  xlim(0
1066	  geom_abline(intercept = intercept
1067	  geom_hline(yintercept = 1.442202)
1068	p9
1069	
1070	p10<- ggplot(asi26r
1071	  geom_point(aes(shape=g
1072	"  ggtitle(""26C "") +"
1073	"  scale_color_manual(values=c(""#F8766D"""
1074	"  labs(x = ""Days"""
1075	  ylim(-2
1076	  xlim(0
1077	  geom_abline(intercept = intercept
1078	  geom_hline(yintercept = 1.442202)
1079	p10
1080	
1081	
1082	ggarrange(p6
1083	          ncol = 2
1084	# exported as a tiff with dimensions of 700x1100
1085	
1086	
1087	#analysing the impact of temperature using linear temperature on the data in each temperature until the first detection of a reproductive size parasite:
1088	# Using rbind to combine data frames
1089	combr <- rbind(aso10
1090	
1091	#including only rows that contained data for the parasite length:
1092	combr2 <- combr[complete.cases(combr$log_plength)
1093	
1094	model1 <- lmer(plength ~  days *temp *ori + (1 | tank/number)
1095	summary(model1)
1096	step1<-step(model1)
1097	step1
1098	model2 <- lmer(plength ~  days *temp *ori + (1 | number)
1099	summary(model2)
1100	step2<-step(model2)
1101	step2
1102	
1103	model3<-lmer(plength ~ days + temp + ori + (1 | number) + days:ori
1104	summary(model3)
