Skip to content

Commit 19e6c4b

Browse files
committed
polish figures for submission
1 parent 062e484 commit 19e6c4b

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

20160404_overnight_dsd/rebound.R

+83
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ ggplot(stat_rebound_dt, aes(x=quiet_baseline_day3h, y=quiet_rebound_day3h)) + ge
251251
summary(lm(quiet_rebound_day3h ~ quiet_baseline_day3h * sex, stat_rebound_dt[treatment == "Control"]))
252252
summary(lm(sleep_rebound_day3h ~ sleep_baseline_day3h * sex, stat_rebound_dt[treatment == "Control"]))
253253

254+
255+
254256
ggplot(stat_rebound_dt[sdi %in% c(0, 10)], aes(x=quiet_baseline_day3h, y=quiet_rebound_day3h, colour=treatment)) + geom_point(alpha=1) + facet_grid(sex ~ .) +
255257
#geom_smooth(data=stat_rebound_dt[treatment=="Control"])
256258
geom_smooth(method = "lm")
@@ -267,6 +269,87 @@ all_pl_objs$bar_quiet_reb_day3h_diff <- ggplot(stat_rebound_dt, aes(interval, qu
267269
geom_hline(yintercept=0, colour="red", linetype=2) + scale_y_continuous(name="Extra quiescence in 3h (min)")
268270

269271

272+
273+
### sleep/quiescence loss vs rebound
274+
#ggplot(stat_rebound_dt, aes(x=quiet_baseline_day, y=quiet_rebound_day)) + geom_point(alpha=.3) + facet_grid(sex ~ .) + scale_x_sqrt()+ scale_y_sqrt()
275+
summary(lm(quiet_sd_night ~ quiet_baseline_night * sex, stat_rebound_dt[treatment == "Control"]))
276+
summary(lm(sleep_sd_night ~ sleep_baseline_night * sex, stat_rebound_dt[treatment == "Control"]))
277+
278+
279+
280+
ggplot(stat_rebound_dt[sdi %in% c(0, 10)], aes(x=quiet_baseline_night, y=quiet_sd_night, colour=treatment)) + geom_point(alpha=1) + facet_grid(sex ~ .) +
281+
#geom_smooth(data=stat_rebound_dt[treatment=="Control"])
282+
geom_smooth(method = "lm")
283+
284+
285+
mod <- lm(quiet_sd_night ~ quiet_baseline_night * sex, stat_rebound_dt[sdi == 0])
286+
287+
stat_rebound_dt[, quiet_sd_night_pred := predict(mod, stat_rebound_dt)]
288+
stat_rebound_dt[, quiet_sd_night_diff := quiet_sd_night - quiet_sd_night_pred]
289+
290+
291+
ggplot(stat_rebound_dt, aes(interval, - quiet_sd_night_diff * 12 * 60, colour=treatment)) + layer_barpl() +
292+
geom_hline(yintercept=0, colour="red", linetype=2) + scale_y_continuous(name="Loss quiescence in 12h (min)")
293+
294+
ggplot(stat_rebound_dt[treatment =="SD"], aes( - quiet_sd_night_diff * 12 * 60, quiet_rebound_day3h_diff * 3 * 60, colour=sdi)) +
295+
geom_point() +
296+
geom_smooth(method="lm") +
297+
scale_x_continuous(name="Loss quiescence during SD (min)") +
298+
scale_y_continuous(name="Extra quiescence in rebound (min)") +
299+
facet_grid(interval ~ sex)
300+
301+
mod <- lm(quiet_rebound_day3h_diff ~ quiet_sd_night_diff * interval,stat_rebound_dt[sex == "F"& treatment =="SD"])
302+
303+
ggplot(stat_rebound_dt, aes( quiet_sd_night_diff * 12 * 60, interactions, colour=sex)) +
304+
geom_point() +
305+
#geom_smooth(method="lm") +
306+
scale_x_continuous(name="Extra Quiescence during SD (min)") +
307+
scale_y_sqrt(name="N_interations") +
308+
facet_wrap( ~ interval)
309+
310+
ggplot(stat_rebound_dt[treatment =="SD"], aes( - quiet_sd_night_diff * 12 * 60, interactions, colour=sdi)) +
311+
geom_point() +
312+
geom_smooth(method="lm", mapping=aes(fill=interval)) +
313+
geom_smooth(method="lm") +
314+
scale_x_continuous(name="Loss quiescence during SD (min)") +
315+
scale_y_sqrt(name="N_interations") +
316+
facet_wrap( ~ sex)
317+
318+
319+
ggplot(stat_rebound_dt[treatment =="SD"], aes( - quiet_sd_night_diff * 12 * 60, quiet_rebound_day3h_diff * 3 * 60, colour=sleep_sd_night > .20)) +
320+
geom_point() +
321+
geom_smooth(method="lm") +
322+
scale_x_continuous(name="Loss quiescence during SD (min)") +
323+
scale_y_continuous(name="Extra quiescence in rebound (min)") +
324+
facet_grid( interval ~ sex)
325+
326+
327+
ggplot(stat_rebound_dt, aes( quiet_baseline_night * 12 * 60, quiet_sd_night * 12 * 60)) +
328+
geom_point() +
329+
geom_smooth(method="lm") +
330+
scale_x_continuous() +
331+
#scale_y_sqrt(name="N_interations") +
332+
facet_grid( interval ~ sex)
333+
334+
335+
ggplot(stat_rebound_dt[treatment =="SD"], aes( quiet_rebound_day3h_diff* 3 * 60, interactions, colour=sdi)) +
336+
geom_point() +
337+
geom_smooth(method="lm", mapping=aes(fill=interval)) +
338+
geom_smooth(method="lm") +
339+
scale_x_continuous(name="Extra quiescence in rebound (min)")
340+
scale_y_sqrt(name="N_interations") +
341+
facet_wrap( ~ sex)
342+
343+
#~ all_pl_objs$bar_quiet_reb_day3h_min_baseline <- ggplot(stat_rebound_dt, aes(interval, quiet_rebound_day3h - quiet_baseline_day3h, colour=treatment)) + layer_barpl()
344+
#~ all_pl_objs$bar_quiet_reb_day3h_diff <- ggplot(stat_rebound_dt, aes(interval, quiet_rebound_day3h_diff * 3 * 60, colour=treatment)) + layer_barpl() +
345+
#~ geom_hline(yintercept=0, colour="red", linetype=2) + scale_y_continuous(name="Extra quiescence in 3h (min)")
346+
347+
348+
349+
350+
351+
###
352+
270353
summ_stat <- stat_rebound_dt[,{
271354
w = wilcox.test(quiet_rebound_day3h_diff, mu=0, alternative="greater")
272355
list(pval=w$p.value, n=.N)},

0 commit comments

Comments
 (0)