|
| 1 | +# analyze redrawn allele ages |
| 2 | +redraw_frames <- list() |
| 3 | +for(i in 25:34) { |
| 4 | + redraw <- read.table(paste("Mutations/spectral/manuscript/submit/revisions/family_redraw/TGP_10kgacounts.redraw", i, sep = "")) |
| 5 | + names(redraw) <- count_header |
| 6 | + redraw <- cbind(redraw[,mut_classes] + redraw[,complementary_classes], |
| 7 | + CpG = redraw$CpG, bin_age = redraw$bin_age) |
| 8 | + redraw_frames[[i-24]] <- make_plotframes(phasedstrictCT_model, redraw, TGPphased_boot10kga_ests)[[2]] |
| 9 | +} |
| 10 | + |
| 11 | +redraw_sexaves <- lapply(redraw_frames, "[", c("sexave")) |
| 12 | + |
| 13 | +redraw_sexaves <- mapply(cbind, redraw_sexaves, |
| 14 | + data.frame(bin_age = tgp_phased10kgaplots[[2]]$bin_age), |
| 15 | + SIMPLIFY = FALSE) |
| 16 | + |
| 17 | +redraw_ggframe <- do.call(rbind, mapply(cbind, redraw_sexaves, |
| 18 | + lapply(1:10, function(i) { |
| 19 | + data.frame(redraw_idx = rep(i, 100)) }), |
| 20 | + SIMPLIFY = FALSE)) |
| 21 | +names(redraw_ggframe)[2] <- "bin_age" |
| 22 | + |
| 23 | +ggplot(redraw_ggframe, aes(y = sexave, x = bin_age, col = factor(redraw_idx))) + |
| 24 | + geom_smooth(method = "loess", se = FALSE, span = 0.65) + |
| 25 | + geom_smooth(data = tgp_phased10kgaplots[[2]], aes(y = sexave, x = bin_age, col = 'mean'), lwd = 1, lty = 3, |
| 26 | + formula = y ~ x, method = "loess", span = 0.65, se = FALSE, color = 'black') + |
| 27 | + geom_ribbon(data = tgp_phased10kgaplots[[2]], aes(x = bin_age, y = sexave, col = 'mean', |
| 28 | + ymin = sexave_lower, ymax = sexave_upper), |
| 29 | + alpha = 0.15, color = NA) + |
| 30 | + coord_cartesian(ylim = c(13.5,38.5)) + #scale_color_manual(values = rev(pal_aaas("default")(2))) + |
| 31 | + axis_formatting + annotation_logticks(sides = "b") + |
| 32 | + scale_x_log10(minor_breaks = c(1:9 * 100, 1:9 * 1000)) + |
| 33 | + labs(y = "generation interval (years)", x = "allele age (generations ago)") + |
| 34 | + theme(legend.position = "none") |
0 commit comments