Last updated: 2021-09-06

Checks: 7 0

Knit directory: DO_Opioid/

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(20200504) 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 95af54d. 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:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/Picture1.png

Untracked files:
    Untracked:  analysis/DDO_morphine1_second_set_69k.stdout
    Untracked:  analysis/DO_Fentanyl.R
    Untracked:  analysis/DO_Fentanyl.err
    Untracked:  analysis/DO_Fentanyl.out
    Untracked:  analysis/DO_Fentanyl.sh
    Untracked:  analysis/DO_morphine1.R
    Untracked:  analysis/DO_morphine1.Rout
    Untracked:  analysis/DO_morphine1.sh
    Untracked:  analysis/DO_morphine1.stderr
    Untracked:  analysis/DO_morphine1.stdout
    Untracked:  analysis/DO_morphine1_SNP.R
    Untracked:  analysis/DO_morphine1_SNP.Rout
    Untracked:  analysis/DO_morphine1_SNP.sh
    Untracked:  analysis/DO_morphine1_SNP.stderr
    Untracked:  analysis/DO_morphine1_SNP.stdout
    Untracked:  analysis/DO_morphine1_combined.R
    Untracked:  analysis/DO_morphine1_combined.Rout
    Untracked:  analysis/DO_morphine1_combined.sh
    Untracked:  analysis/DO_morphine1_combined.stderr
    Untracked:  analysis/DO_morphine1_combined.stdout
    Untracked:  analysis/DO_morphine1_combined_69k.R
    Untracked:  analysis/DO_morphine1_combined_69k.Rout
    Untracked:  analysis/DO_morphine1_combined_69k.sh
    Untracked:  analysis/DO_morphine1_combined_69k.stderr
    Untracked:  analysis/DO_morphine1_combined_69k.stdout
    Untracked:  analysis/DO_morphine1_combined_69k_m2.R
    Untracked:  analysis/DO_morphine1_combined_69k_m2.Rout
    Untracked:  analysis/DO_morphine1_combined_69k_m2.sh
    Untracked:  analysis/DO_morphine1_combined_69k_m2.stderr
    Untracked:  analysis/DO_morphine1_combined_69k_m2.stdout
    Untracked:  analysis/DO_morphine1_combined_weight_DOB.R
    Untracked:  analysis/DO_morphine1_combined_weight_DOB.Rout
    Untracked:  analysis/DO_morphine1_combined_weight_DOB.err
    Untracked:  analysis/DO_morphine1_combined_weight_DOB.out
    Untracked:  analysis/DO_morphine1_combined_weight_DOB.sh
    Untracked:  analysis/DO_morphine1_combined_weight_DOB.stderr
    Untracked:  analysis/DO_morphine1_combined_weight_DOB.stdout
    Untracked:  analysis/DO_morphine1_combined_weight_age.R
    Untracked:  analysis/DO_morphine1_combined_weight_age.err
    Untracked:  analysis/DO_morphine1_combined_weight_age.out
    Untracked:  analysis/DO_morphine1_combined_weight_age.sh
    Untracked:  analysis/DO_morphine1_combined_weight_age_GAMMT.R
    Untracked:  analysis/DO_morphine1_combined_weight_age_GAMMT.err
    Untracked:  analysis/DO_morphine1_combined_weight_age_GAMMT.out
    Untracked:  analysis/DO_morphine1_combined_weight_age_GAMMT.sh
    Untracked:  analysis/DO_morphine1_combined_weight_age_GAMMT_chr19.R
    Untracked:  analysis/DO_morphine1_combined_weight_age_GAMMT_chr19.err
    Untracked:  analysis/DO_morphine1_combined_weight_age_GAMMT_chr19.out
    Untracked:  analysis/DO_morphine1_combined_weight_age_GAMMT_chr19.sh
    Untracked:  analysis/DO_morphine1_cph.R
    Untracked:  analysis/DO_morphine1_cph.Rout
    Untracked:  analysis/DO_morphine1_cph.sh
    Untracked:  analysis/DO_morphine1_second_set.R
    Untracked:  analysis/DO_morphine1_second_set.Rout
    Untracked:  analysis/DO_morphine1_second_set.sh
    Untracked:  analysis/DO_morphine1_second_set.stderr
    Untracked:  analysis/DO_morphine1_second_set.stdout
    Untracked:  analysis/DO_morphine1_second_set_69k.R
    Untracked:  analysis/DO_morphine1_second_set_69k.Rout
    Untracked:  analysis/DO_morphine1_second_set_69k.sh
    Untracked:  analysis/DO_morphine1_second_set_69k.stderr
    Untracked:  analysis/DO_morphine1_second_set_SNP.R
    Untracked:  analysis/DO_morphine1_second_set_SNP.Rout
    Untracked:  analysis/DO_morphine1_second_set_SNP.sh
    Untracked:  analysis/DO_morphine1_second_set_SNP.stderr
    Untracked:  analysis/DO_morphine1_second_set_SNP.stdout
    Untracked:  analysis/DO_morphine1_second_set_weight_DOB.R
    Untracked:  analysis/DO_morphine1_second_set_weight_DOB.Rout
    Untracked:  analysis/DO_morphine1_second_set_weight_DOB.err
    Untracked:  analysis/DO_morphine1_second_set_weight_DOB.out
    Untracked:  analysis/DO_morphine1_second_set_weight_DOB.sh
    Untracked:  analysis/DO_morphine1_second_set_weight_DOB.stderr
    Untracked:  analysis/DO_morphine1_second_set_weight_DOB.stdout
    Untracked:  analysis/DO_morphine1_second_set_weight_age.R
    Untracked:  analysis/DO_morphine1_second_set_weight_age.Rout
    Untracked:  analysis/DO_morphine1_second_set_weight_age.err
    Untracked:  analysis/DO_morphine1_second_set_weight_age.out
    Untracked:  analysis/DO_morphine1_second_set_weight_age.sh
    Untracked:  analysis/DO_morphine1_second_set_weight_age.stderr
    Untracked:  analysis/DO_morphine1_second_set_weight_age.stdout
    Untracked:  analysis/DO_morphine1_weight_DOB.R
    Untracked:  analysis/DO_morphine1_weight_DOB.sh
    Untracked:  analysis/DO_morphine1_weight_age.R
    Untracked:  analysis/DO_morphine1_weight_age.sh
    Untracked:  analysis/DO_morphine_gemma.R
    Untracked:  analysis/DO_morphine_gemma.err
    Untracked:  analysis/DO_morphine_gemma.out
    Untracked:  analysis/DO_morphine_gemma.sh
    Untracked:  analysis/DO_morphine_gemma_firstmin.R
    Untracked:  analysis/DO_morphine_gemma_firstmin.err
    Untracked:  analysis/DO_morphine_gemma_firstmin.out
    Untracked:  analysis/DO_morphine_gemma_firstmin.sh
    Untracked:  analysis/DO_morphine_gemma_withpermu.R
    Untracked:  analysis/DO_morphine_gemma_withpermu.err
    Untracked:  analysis/DO_morphine_gemma_withpermu.out
    Untracked:  analysis/DO_morphine_gemma_withpermu.sh
    Untracked:  analysis/DO_morphine_gemma_withpermu_firstbatch_min.depression.R
    Untracked:  analysis/DO_morphine_gemma_withpermu_firstbatch_min.depression.err
    Untracked:  analysis/DO_morphine_gemma_withpermu_firstbatch_min.depression.out
    Untracked:  analysis/DO_morphine_gemma_withpermu_firstbatch_min.depression.sh
    Untracked:  analysis/Plot_DO_morphine1_SNP.R
    Untracked:  analysis/Plot_DO_morphine1_SNP.Rout
    Untracked:  analysis/Plot_DO_morphine1_SNP.sh
    Untracked:  analysis/Plot_DO_morphine1_SNP.stderr
    Untracked:  analysis/Plot_DO_morphine1_SNP.stdout
    Untracked:  analysis/Plot_DO_morphine1_second_set_SNP.R
    Untracked:  analysis/Plot_DO_morphine1_second_set_SNP.Rout
    Untracked:  analysis/Plot_DO_morphine1_second_set_SNP.sh
    Untracked:  analysis/Plot_DO_morphine1_second_set_SNP.stderr
    Untracked:  analysis/Plot_DO_morphine1_second_set_SNP.stdout
    Untracked:  analysis/scripts/
    Untracked:  analysis/workflow_proc.R
    Untracked:  analysis/workflow_proc.sh
    Untracked:  analysis/workflow_proc.stderr
    Untracked:  analysis/workflow_proc.stdout
    Untracked:  analysis/x.R
    Untracked:  code/cfw/
    Untracked:  code/gemma_plot.R
    Untracked:  code/reconst_utils.R
    Untracked:  data/69k_grid_pgmap.RData
    Untracked:  data/FinalReport/
    Untracked:  data/GM/
    Untracked:  data/GM_covar.csv
    Untracked:  data/GM_covar_07092018_morphine.csv
    Untracked:  data/Jackson_Lab_Bubier_MURGIGV01/
    Untracked:  data/Master Fentanyl DO Study Sheet.xlsx
    Untracked:  data/MasterMorphine Second Set DO w DOB2.xlsx
    Untracked:  data/MasterMorphine Second Set DO.xlsx
    Untracked:  data/cc_variants.sqlite
    Untracked:  data/combined/
    Untracked:  data/first/
    Untracked:  data/founder_geno.csv
    Untracked:  data/genetic_map.csv
    Untracked:  data/gm.json
    Untracked:  data/gwas.sh
    Untracked:  data/marker_grid_0.02cM_plus.txt
    Untracked:  data/mouse_genes_mgi.sqlite
    Untracked:  data/pheno.csv
    Untracked:  data/pheno_qtl2.csv
    Untracked:  data/pheno_qtl2_07092018_morphine.csv
    Untracked:  data/pheno_qtl2_w_dob.csv
    Untracked:  data/physical_map.csv
    Untracked:  data/rnaseq/
    Untracked:  data/sample_geno.csv
    Untracked:  data/second/
    Untracked:  figure/
    Untracked:  glimma-plots/
    Untracked:  output/DO_morphine_Min.depression.png
    Untracked:  output/DO_morphine_Min.depression22222_violin_chr5.pdf
    Untracked:  output/DO_morphine_Min.depression_coefplot.pdf
    Untracked:  output/DO_morphine_Min.depression_coefplot_blup.pdf
    Untracked:  output/DO_morphine_Min.depression_coefplot_blup_chr5.png
    Untracked:  output/DO_morphine_Min.depression_coefplot_blup_chrX.png
    Untracked:  output/DO_morphine_Min.depression_coefplot_chr5.png
    Untracked:  output/DO_morphine_Min.depression_coefplot_chrX.png
    Untracked:  output/DO_morphine_Min.depression_peak_genes_chr5.png
    Untracked:  output/DO_morphine_Min.depression_violin_chr5.png
    Untracked:  output/DO_morphine_Recovery.Time.png
    Untracked:  output/DO_morphine_Recovery.Time_coefplot.pdf
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_blup.pdf
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_blup_chr11.png
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_blup_chr4.png
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_blup_chr7.png
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_blup_chr9.png
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_chr11.png
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_chr4.png
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_chr7.png
    Untracked:  output/DO_morphine_Recovery.Time_coefplot_chr9.png
    Untracked:  output/DO_morphine_Status_bin.png
    Untracked:  output/DO_morphine_Status_bin_coefplot.pdf
    Untracked:  output/DO_morphine_Status_bin_coefplot_blup.pdf
    Untracked:  output/DO_morphine_Survival.Time.png
    Untracked:  output/DO_morphine_Survival.Time_coefplot.pdf
    Untracked:  output/DO_morphine_Survival.Time_coefplot_blup.pdf
    Untracked:  output/DO_morphine_Survival.Time_coefplot_blup_chr17.png
    Untracked:  output/DO_morphine_Survival.Time_coefplot_blup_chr8.png
    Untracked:  output/DO_morphine_Survival.Time_coefplot_chr17.png
    Untracked:  output/DO_morphine_Survival.Time_coefplot_chr8.png
    Untracked:  output/DO_morphine_combine_batch_peak_violin.pdf
    Untracked:  output/DO_morphine_combined_69k_m2_Min.depression.png
    Untracked:  output/DO_morphine_combined_69k_m2_Min.depression_coefplot.pdf
    Untracked:  output/DO_morphine_combined_69k_m2_Min.depression_coefplot_blup.pdf
    Untracked:  output/DO_morphine_combined_69k_m2_Recovery.Time.png
    Untracked:  output/DO_morphine_combined_69k_m2_Recovery.Time_coefplot.pdf
    Untracked:  output/DO_morphine_combined_69k_m2_Recovery.Time_coefplot_blup.pdf
    Untracked:  output/DO_morphine_combined_69k_m2_Status_bin.png
    Untracked:  output/DO_morphine_combined_69k_m2_Status_bin_coefplot.pdf
    Untracked:  output/DO_morphine_combined_69k_m2_Status_bin_coefplot_blup.pdf
    Untracked:  output/DO_morphine_combined_69k_m2_Survival.Time.png
    Untracked:  output/DO_morphine_combined_69k_m2_Survival.Time_coefplot.pdf
    Untracked:  output/DO_morphine_combined_69k_m2_Survival.Time_coefplot_blup.pdf
    Untracked:  output/DO_morphine_coxph_24hrs_kinship_QTL.png
    Untracked:  output/DO_morphine_cphout.RData
    Untracked:  output/DO_morphine_first_batch_peak_in_second_batch_violin.pdf
    Untracked:  output/DO_morphine_first_batch_peak_in_second_batch_violin_sidebyside.pdf
    Untracked:  output/DO_morphine_first_batch_peak_violin.pdf
    Untracked:  output/DO_morphine_operm.cph.RData
    Untracked:  output/DO_morphine_second_batch_on_first_batch_peak_violin.pdf
    Untracked:  output/DO_morphine_second_batch_peak_ch6surv_on_first_batchviolin.pdf
    Untracked:  output/DO_morphine_second_batch_peak_ch6surv_on_first_batchviolin2.pdf
    Untracked:  output/DO_morphine_second_batch_peak_in_first_batch_violin.pdf
    Untracked:  output/DO_morphine_second_batch_peak_in_first_batch_violin_sidebyside.pdf
    Untracked:  output/DO_morphine_second_batch_peak_violin.pdf
    Untracked:  output/DO_morphine_secondbatch_69k_Min.depression.png
    Untracked:  output/DO_morphine_secondbatch_69k_Min.depression_coefplot.pdf
    Untracked:  output/DO_morphine_secondbatch_69k_Min.depression_coefplot_blup.pdf
    Untracked:  output/DO_morphine_secondbatch_69k_Recovery.Time.png
    Untracked:  output/DO_morphine_secondbatch_69k_Recovery.Time_coefplot.pdf
    Untracked:  output/DO_morphine_secondbatch_69k_Recovery.Time_coefplot_blup.pdf
    Untracked:  output/DO_morphine_secondbatch_69k_Status_bin.png
    Untracked:  output/DO_morphine_secondbatch_69k_Status_bin_coefplot.pdf
    Untracked:  output/DO_morphine_secondbatch_69k_Status_bin_coefplot_blup.pdf
    Untracked:  output/DO_morphine_secondbatch_69k_Survival.Time.png
    Untracked:  output/DO_morphine_secondbatch_69k_Survival.Time_coefplot.pdf
    Untracked:  output/DO_morphine_secondbatch_69k_Survival.Time_coefplot_blup.pdf
    Untracked:  output/DO_morphine_secondbatch_Min.depression.png
    Untracked:  output/DO_morphine_secondbatch_Min.depression_coefplot.pdf
    Untracked:  output/DO_morphine_secondbatch_Min.depression_coefplot_blup.pdf
    Untracked:  output/DO_morphine_secondbatch_Recovery.Time.png
    Untracked:  output/DO_morphine_secondbatch_Recovery.Time_coefplot.pdf
    Untracked:  output/DO_morphine_secondbatch_Recovery.Time_coefplot_blup.pdf
    Untracked:  output/DO_morphine_secondbatch_Status_bin.png
    Untracked:  output/DO_morphine_secondbatch_Status_bin_coefplot.pdf
    Untracked:  output/DO_morphine_secondbatch_Status_bin_coefplot_blup.pdf
    Untracked:  output/DO_morphine_secondbatch_Survival.Time.png
    Untracked:  output/DO_morphine_secondbatch_Survival.Time_coefplot.pdf
    Untracked:  output/DO_morphine_secondbatch_Survival.Time_coefplot_blup.pdf
    Untracked:  output/Fentanyl/
    Untracked:  output/apr_69kchr_combined.RData
    Untracked:  output/apr_69kchr_k_loco_combined.rds
    Untracked:  output/apr_69kchr_second_set.RData
    Untracked:  output/combine_batch_variation.RData
    Untracked:  output/combined_gm.RData
    Untracked:  output/combined_gm.k_loco.rds
    Untracked:  output/combined_gm.k_overall.rds
    Untracked:  output/combined_gm.probs_8state.rds
    Untracked:  output/coxph/
    Untracked:  output/do.morphine.RData
    Untracked:  output/do.morphine.k_loco.rds
    Untracked:  output/do.morphine.probs_8state.rds
    Untracked:  output/first_batch_variation.RData
    Untracked:  output/old_temp/
    Untracked:  output/pr_69kchr_combined.RData
    Untracked:  output/pr_69kchr_second_set.RData
    Untracked:  output/qtl.morphine.69k.out.combined.RData
    Untracked:  output/qtl.morphine.69k.out.combined_m2.RData
    Untracked:  output/qtl.morphine.69k.out.second_set.RData
    Untracked:  output/qtl.morphine.operm.RData
    Untracked:  output/qtl.morphine.out.RData
    Untracked:  output/qtl.morphine.out.combined_gm.RData
    Untracked:  output/qtl.morphine.out.combined_weight_DOB.RData
    Untracked:  output/qtl.morphine.out.combined_weight_age.RData
    Untracked:  output/qtl.morphine.out.second_set.RData
    Untracked:  output/qtl.morphine.out.second_set.weight_DOB.RData
    Untracked:  output/qtl.morphine.out.second_set.weight_age.RData
    Untracked:  output/qtl.morphine.out.weight_DOB.RData
    Untracked:  output/qtl.morphine.out.weight_age.RData
    Untracked:  output/qtl.morphine1.snpout.RData
    Untracked:  output/qtl.morphine2.snpout.RData
    Untracked:  output/second_batch_variation.RData
    Untracked:  output/second_set_apr_69kchr_k_loco.rds
    Untracked:  output/second_set_gm.RData
    Untracked:  output/second_set_gm.k_loco.rds
    Untracked:  output/second_set_gm.probs_8state.rds
    Untracked:  output/topSNP_chr5_mindepression.csv
    Untracked:  output/zoompeak_Min.depression_9.pdf
    Untracked:  output/zoompeak_Recovery.Time_16.pdf
    Untracked:  output/zoompeak_Status_bin_11.pdf
    Untracked:  output/zoompeak_Survival.Time_1.pdf

Unstaged changes:
    Modified:   _workflowr.yml

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/batches_3_do_diversity_report.Rmd) and HTML (docs/batches_3_do_diversity_report.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
Rmd 95af54d xhyuo 2021-09-06 fentanyl
html 468ae22 xhyuo 2021-06-24 Build site.
Rmd cd89ecf xhyuo 2021-06-24 3batches diversity

Diversity report for diversity outbred mice

After finishing 06_final_pr_apr_69K.R, 07_do_diversity_report.R, all the output will be used plot DO Diversity Report for 3 batches of DO mice

library

# Load packages
library(qtl2)
library(table1)
library(tidyverse)
library(data.table)
library(foreach)
library(doParallel)
library(parallel)
library(abind)
library(gap)
library(regress)
library(lme4)
library(abind)
library(ggplot2)
library(vcd)
library(MASS)
#library(plotly)
library(colorspace)
library(HardyWeinberg)
options(stringsAsFactors = FALSE)
source("code/reconst_utils.R")

Summary

load("data/Jackson_Lab_Bubier_MURGIGV01/gm_DO395_qc_newid.RData")#gm_after_qc

# make dataset with a few variables to summarize
table1 <- gm_after_qc$covar %>% 
  dplyr::select(Name = name, 
                Sex  = sex, 
                Generation = ngen) %>%
  mutate(Sex = case_when(
    Sex == "F" ~ "Female",
    Sex == "M" ~ "Male"
  ))

# summarize the data 
table1(~ Generation | Sex, data=table1)
Female
(N=201)
Male
(N=194)
Overall
(N=395)
Generation
36 201 (100%) 194 (100%) 395 (100%)

Founder contributions

load("data/Jackson_Lab_Bubier_MURGIGV01/fp_DO395.RData") #fp and fp_summary object

#summarize per generation per chromosome
fp_summary = fp %>% group_by(chr, founder, gen) %>%
  summarize(mean = round(100*mean(prop), 2),
            sd   = round(100*sd(prop), 2))
`summarise()` has grouped output by 'chr', 'founder'. You can override using the `.groups` argument.
#Stackbar plot
#summarize per chromosome across generation
pdf(file = "data/Jackson_Lab_Bubier_MURGIGV01/stackbar_mean_prop_across_all_gen.pdf",width = 16)
p01 <- fp %>% group_by(chr, founder) %>%
  summarise(grand_mean = round(100*mean(prop), 2)) %>%
  ggplot(aes(x = chr, y = grand_mean, fill = founder)) +
    geom_bar(stat="identity",
             width=1) +
    geom_text(aes(label = paste0(grand_mean)), position = position_stack(vjust = 0.5)) +
    scale_fill_manual(values = CCcolors) +
    ylab("Mean percentage across generations") +
    xlab("Chromosome") +
    theme(panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          panel.background = element_blank(),
          axis.line = element_line(colour = "black"),
          plot.title = element_text(hjust = 0.5),
          text = element_text(size=16),
          axis.title=element_text(size=16),
          legend.title=element_blank())
`summarise()` has grouped output by 'chr'. You can override using the `.groups` argument.
p01
dev.off()
png 
  2 
p01

Version Author Date
468ae22 xhyuo 2021-06-24
#Stackbar plot
#summarize per chromosome across generation
pdf(file = "data/Jackson_Lab_Bubier_MURGIGV01/stackbar_mean_prop_across_all_chr.pdf",width = 16)
p02 <- fp %>% group_by(gen, founder) %>%
  summarise(grand_mean = round(100*mean(prop), 2), 
            grand_sd   = round(100*sd(prop), 2)) %>%
  ggplot(aes(x = gen, y = grand_mean, fill = founder)) +
    geom_bar(stat="identity",
             width=0.99) +
    geom_text(aes(label = paste0(grand_mean, " ± ", grand_sd)), position = position_stack(vjust = 0.5)) +
    scale_fill_manual(values = CCcolors) +
    ylab("Mean percentage across all chromosomes") +
    xlab("Generation") +
    theme(panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          panel.background = element_blank(),
          axis.line = element_line(colour = "black"),
          plot.title = element_text(hjust = 0.5),
          text = element_text(size=16),
          axis.title=element_text(size=16),
          legend.title=element_blank())
`summarise()` has grouped output by 'gen'. You can override using the `.groups` argument.
p02
dev.off()
png 
  2 
p02

Version Author Date
468ae22 xhyuo 2021-06-24
#stackbar_prop_across_gen
for(c in c(1:19, "X")){
  #print(c)
  p <- ggplot(data = fp_summary[fp_summary$chr == c,], aes(x = gen, y = mean, fill = founder)) +
    geom_bar(stat="identity",
             width=1) +
    geom_text(aes(label = paste0(mean," ± ", sd)), position = position_stack(vjust = 0.5)) +
    scale_fill_manual(values = CCcolors) +
    labs(title = paste0("Chr ", c)) +
    ylab("Percentage") +
    xlab("Generation") +
    theme(panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          panel.background = element_blank(),
          axis.line = element_line(colour = "black"),
          plot.title = element_text(hjust = 0.5),
          text = element_text(size=16),
          axis.title=element_text(size=16),
          legend.title=element_blank())
  print(p)
}

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24

Version Author Date
468ae22 xhyuo 2021-06-24
pdf(file = "data/Jackson_Lab_Bubier_MURGIGV01/stackbar_prop_across_gen.pdf",width = 16)
for(c in c(1:19, "X")){
  #print(c)
  p <- ggplot(data = fp_summary[fp_summary$chr == c,], aes(x = gen, y = mean, fill = founder)) +
    geom_bar(stat="identity",
             width=1) +
    geom_text(aes(label = paste0(mean," ± ", sd)), position = position_stack(vjust = 0.5)) +
    scale_fill_manual(values = CCcolors) +
    labs(title = paste0("Chr ", c)) +
    ylab("Percentage") +
    xlab("Generation") +
    theme(panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          panel.background = element_blank(),
          axis.line = element_line(colour = "black"),
          plot.title = element_text(hjust = 0.5),
          text = element_text(size=16),
          axis.title=element_text(size=16),
          legend.title=element_blank())
  print(p)
}
dev.off()
png 
  2 
#stackbar_prop_across_chr
for(g in levels(fp_summary$gen)){
  #print(g)
  p <- ggplot(data = fp_summary[fp_summary$gen == g,], aes(x = chr, y = mean, fill = founder)) +
    geom_bar(stat="identity",
             width=1) +
    geom_text(aes(label = paste0(mean)), position = position_stack(vjust = 0.5)) +
    scale_fill_manual(values = CCcolors) +
    labs(title = paste0("Generation ", g)) +
    ylab("Percentage") +
    theme(panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          panel.background = element_blank(),
          axis.title.x = element_blank(),
          axis.line = element_line(colour = "black"),
          plot.title = element_text(hjust = 0.5),
          text = element_text(size=16),
          axis.title=element_text(size=16),
          legend.title=element_blank())
  #print(p)
}

pdf(file = "data/Jackson_Lab_Bubier_MURGIGV01/stackbar_prop_across_chr.pdf", width = 12)
for(g in levels(fp_summary$gen)){
  #print(g)
  p <- ggplot(data = fp_summary[fp_summary$gen == g,], aes(x = chr, y = mean, fill = founder)) +
    geom_bar(stat="identity",
             width=1) +
    geom_text(aes(label = paste0(mean)), position = position_stack(vjust = 0.5)) +
    scale_fill_manual(values = CCcolors) +
    labs(title = paste0("Generation ", g)) +
    ylab("Percentage") +
    theme(panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          panel.background = element_blank(),
          axis.title.x = element_blank(),
          axis.line = element_line(colour = "black"),
          plot.title = element_text(hjust = 0.5),
          text = element_text(size=16),
          axis.title=element_text(size=16),
          legend.title=element_blank())
  print(p)
}
dev.off()
png 
  2 
#line plot
#plt <- htmltools::tagList()
for(c in unique(names(gm_after_qc$geno))){
  print(c)
  fp_subdata <- fp[fp$chr == c,]
  pp <- ggplot(data = fp_subdata,aes(pos, prop, group = gen, color = founder)) +
    geom_line(aes(linetype=gen)) +
    scale_linetype_manual(values=rep("solid",12)) +
    geom_hline(yintercept=0.125, linetype="dashed", color = "black", size = 0.25) +
    scale_color_manual(values = CCcolors) +
    facet_grid(founder~.) + 
    labs(title = paste0("Chr ", c)) + 
    theme(legend.position='none')
  print(pp)
  # Print an interactive plot
  # Add to list
  #plt[[c]] <- as_widget(ggplotly(pp, width = 1000, height = 1000))
}
[1] "1"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "2"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "3"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "4"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "5"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "6"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "7"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "8"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "9"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "10"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "11"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "12"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "13"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "14"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "15"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "16"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "17"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "18"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "19"

Version Author Date
468ae22 xhyuo 2021-06-24
[1] "X"

Version Author Date
468ae22 xhyuo 2021-06-24
#plt

Average haplotype block size

load("data/Jackson_Lab_Bubier_MURGIGV01/recom_block_size.RData")
#Create an appropriately sized vector of names
nameVector <- unlist(mapply(function(x,y){ rep(y, length(x)) }, pos_ind_gen, names(pos_ind_gen)))
#Create the result
recom_block <- cbind.data.frame(unlist(pos_ind_gen), nameVector)
colnames(recom_block) <- c("sizeblock",
                           "ngen")
#remove 0
recom_block <- recom_block[recom_block$sizeblock != 0,]
#mean
means <- aggregate(sizeblock~ngen, data= recom_block,mean)
means$sizeblock <- round(means$sizeblock, 2)

pdf(file = "data/Jackson_Lab_Bubier_MURGIGV01/boxplot_mean_recomb_block_size.pdf", height = 8, width = 10)
p1 <- ggplot(recom_block, aes(x=ngen, y=sizeblock, group = ngen, fill = ngen)) + 
  geom_boxplot(show.legend = F , outlier.size = 0.5, notchwidth = 3) +
  scale_fill_discrete_qualitative(palette = "warm")+
  geom_text(data = means, alpha = 0.85, aes(label = sizeblock, y = sizeblock + 0.15 )) + 
  ylab("Recombination Block Size (Mb)") +
  xlab("Generation") +
  labs(fill = "") +
  #ylim(c(0, 60)) +
  scale_y_continuous(breaks=c(0,5,10, 20, 40, 60), limits=c(0, 60)) +
  theme(panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(), 
        axis.line = element_line(colour = "black"),
        text = element_text(size=16), 
        axis.title=element_text(size=16)) +
  guides(shape = guide_legend(override.aes = list(size = 12)))
p1
dev.off()
png 
  2 
p1

Version Author Date
468ae22 xhyuo 2021-06-24
#block size distribution
for(g in unique(gm_after_qc$covar$ngen)){
  #plot for recom block size
  #png(paste0("data/Jackson_Lab_Bubier_MURGIGV01/DO_recom_block_size_G", g, ".png"))
  x <- pos_ind_gen[[g]][pos_ind_gen[[g]] != 0]
  # estimate the parameters
  fit1 <- fitdistr(x, "exponential") 
  
  # goodness of fit test
  ks.test(x, "pexp", fit1$estimate) # p-value > 0.05 -> distribution not refused
  
  # plot a graph
  hist(x, 
       freq = FALSE, 
       breaks = 200, 
       xlim = c(0, 5+quantile(x, 1)), 
       #ylim = c(0,0.3),
       xlab = "Recombination Block Size (Mb)", 
       main = paste0("Gen ", g))
  curve(dexp(x, rate = fit1$estimate), 
        from = 0, 
        to = 5+quantile(x, 1), 
        col = "red", 
        add = TRUE)
  #dev.off()
}
Warning in ks.test(x, "pexp", fit1$estimate): ties should not be present for the
Kolmogorov-Smirnov test

Version Author Date
468ae22 xhyuo 2021-06-24

Average heterozygosity value

load("data/Jackson_Lab_Bubier_MURGIGV01/dat_het_ind_pr.RData")

pdf(paste("data/Jackson_Lab_Bubier_MURGIGV01/DO_Heterozygosity_value_violin_genoprops.pdf"), width = 10, height =8)
p2 <- ggplot(dat_het_ind_pr, aes(x=ngen, y=het, group=ngen, fill=ngen)) +
  geom_violin(show.legend = FALSE) +
  geom_boxplot(show.legend = FALSE, width=0.35, color="black", alpha=0.6) +
  #scale_fill_discrete_qualitative(palette = "warm")+
  ylab("Heterozygosity from genotype props") +
  xlab("Generation") +
  ylim(c(0.65, 1)) +
  geom_hline(yintercept=0.875, linetype="dashed", color = "red") +
  #scale_y_continuous(breaks=c(0.55, 0.65, 0.75, 0.85, 0.95, 1), limits=c(0.55, 1)) +
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background = element_blank(),
        axis.line = element_line(colour = "black"),
        text = element_text(size=16),
        axis.title=element_text(size=16),
        legend.title=element_blank())
p2
dev.off()
png 
  2 
p2

Version Author Date
468ae22 xhyuo 2021-06-24

marker UNC13316610 allele frequency

#pull marker UNC13316610
gm.UNC13316610 <- pull_markers(gm_after_qc, "UNC13316610")
#genotype freq
gfreq <- calc_raw_geno_freq(gm.UNC13316610, by = c("marker"))
gfreq_tab <- gfreq %>%
  as.data.frame() %>%
  mutate(id = rownames(gfreq)) %>%
  mutate(C_freq = (2*AA + AB)/(2*(AA+AB+BB))) %>%
  mutate(T_freq = 1-C_freq) %>%
dplyr::select(CC = AA,
              CT = AB,
              TT = BB,
              C_freq,
              T_freq) %>%
  mutate(chisq = HWChisq(c(91, 215, 80))$chisq,
         df    = HWChisq(c(91, 215, 80))$df,
         p     = HWChisq(c(91, 215, 80))$p) 
Chi-square test with continuity correction for Hardy-Weinberg equilibrium (autosomal)
Chi2 =  4.756968 DF =  1 p-value =  0.0291799 D =  11.07837 f =  -0.114895 
Chi-square test with continuity correction for Hardy-Weinberg equilibrium (autosomal)
Chi2 =  4.756968 DF =  1 p-value =  0.0291799 D =  11.07837 f =  -0.114895 
Chi-square test with continuity correction for Hardy-Weinberg equilibrium (autosomal)
Chi2 =  4.756968 DF =  1 p-value =  0.0291799 D =  11.07837 f =  -0.114895 
gfreq_tab
                  CC       CT        TT    C_freq    T_freq    chisq         p
UNC13316610 0.235443 0.556962 0.2075949 0.5139241 0.4860759 4.756968 0.4857513
#
#AA  AB  BB 
#91 215  80 

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so

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=C             
 [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] grid      parallel  stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] HardyWeinberg_1.7.1 Rsolnp_1.16         mice_3.13.0        
 [4] colorspace_2.0-0    MASS_7.3-53         vcd_1.4-8          
 [7] lme4_1.1-26         Matrix_1.2-18       regress_1.3-21     
[10] gap_1.2.2           abind_1.4-5         doParallel_1.0.16  
[13] iterators_1.0.13    foreach_1.5.1       data.table_1.13.6  
[16] forcats_0.5.1       stringr_1.4.0       dplyr_1.0.4        
[19] purrr_0.3.4         readr_1.4.0         tidyr_1.1.2        
[22] tibble_3.0.6        ggplot2_3.3.3       tidyverse_1.3.0    
[25] table1_1.2.1        qtl2_0.24           workflowr_1.6.2    

loaded via a namespace (and not attached):
 [1] nlme_3.1-152      fs_1.5.0          lubridate_1.7.9.2 bit64_4.0.5      
 [5] httr_1.4.2        rprojroot_2.0.2   tools_4.0.3       backports_1.2.1  
 [9] R6_2.5.0          DBI_1.1.1         withr_2.4.1       tidyselect_1.1.0 
[13] bit_4.0.4         compiler_4.0.3    git2r_0.28.0      cli_2.3.0        
[17] rvest_0.3.6       xml2_1.3.2        labeling_0.4.2    scales_1.1.1     
[21] lmtest_0.9-38     digest_0.6.27     minqa_1.2.4       rmarkdown_2.6    
[25] pkgconfig_2.0.3   htmltools_0.5.1.1 highr_0.8         dbplyr_2.1.0     
[29] fastmap_1.1.0     rlang_0.4.10      readxl_1.3.1      rstudioapi_0.13  
[33] RSQLite_2.2.3     farver_2.0.3      generics_0.1.0    zoo_1.8-8        
[37] jsonlite_1.7.2    magrittr_2.0.1    Formula_1.2-4     Rcpp_1.0.6       
[41] munsell_0.5.0     lifecycle_1.0.0   stringi_1.5.3     whisker_0.4      
[45] yaml_2.2.1        blob_1.2.1        promises_1.2.0.1  crayon_1.4.1     
[49] lattice_0.20-41   haven_2.3.1       splines_4.0.3     hms_1.0.0        
[53] knitr_1.31        pillar_1.4.7      boot_1.3-27       codetools_0.2-18 
[57] reprex_1.0.0      glue_1.4.2        evaluate_0.14     modelr_0.1.8     
[61] vctrs_0.3.6       nloptr_1.2.2.2    httpuv_1.5.5      cellranger_1.1.0 
[65] gtable_0.3.0      assertthat_0.2.1  cachem_1.0.4      xfun_0.21        
[69] broom_0.7.4       later_1.1.0.1     truncnorm_1.0-8   memoise_2.0.0    
[73] statmod_1.4.35    ellipsis_0.3.1   

This R Markdown site was created with workflowr