Last updated: 2020-03-16

Checks: 7 0

Knit directory: Blancetal/analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.6.0). 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(20200217) 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 version displayed above was the version of the Git repository at the time these results were generated.

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:    .DS_Store
    Ignored:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/.DS_Store
    Ignored:    output/.DS_Store
    Ignored:    output/Identifying_Selected_Genes/.DS_Store
    Ignored:    output/Selection_on_Expression_of_Cold_Response_Genes/.DS_Store
    Ignored:    output/Selection_on_expression_of_coexpression_clusters/.DS_Store

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 R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd 8848080 jgblanc 2020-03-16 wflow_publish(c(“analysis/index.Rmd”, “analysis/Expression_plots.Rmd”))

Intro

Here we have the code to plot Expression vs PC for any gen/PC combination in any tissue. This is the code used to generate Figure 6 in the main text. It is important to note that it is easy to plot Expression vs. PC with the line of best fit for any gene. However, to plot confidence intervals you need to get \(\text{var}(C_{11:20})\) from the selection test. To plot the correct confidence interval you would need to record the “var_t” value from the selection test and plug that into the code below used to calculate “k_plus”.

Figures

# Read in Population and Expression Info 
pop <- read.csv("../data/FlintGarciaTableS1_fixednew.csv")
exp <- read.table("../data/Mean_centered_expression/Kern.txt")
exp$lines <- row.names(exp)
m <- merge(pop, exp, by.x = "Inbred", by.y = "lines" )
pop_dat <- m[,1:8]

# Read in Kinship Matrix 
myF <- read.table('../data/Kinship_matrices/F_Kern.txt')

## Get Eigen Values and Vectors 
myE <- eigen(myF)
E_vectors <- myE$vectors
E_values <- myE$values

# Get PC and Expression
pop_dat$PC <- E_vectors[,2] # Can change PC
pop_dat$Gene <- exp[,"GRMZM2G093574"] # Can change gene name

# Get CI info
lambda <- E_values[2]
k_plus <-  1.96 * sqrt(4836.755 * lambda) 
k_minus <- -k_plus

# Do linear regression and get slope 
lR <- lm(pop_dat$Gene ~ pop_dat$PC) 
coeff <- lR$coefficients[[2]]

# Plot 
col <- c('#E69F00', '#56B4E9', "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
ggplot(data=pop_dat, aes(x = PC, y= Gene , color=Subpopulation)) + scale_colour_manual(values = col, labels=c("mixed", "non-stiff stalk", "popcorn", "stiff stalk", "sweet", "tropical")) + xlab("PC 2") +  ylab("Expression") + theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.title.y = element_text(size=12), axis.title.x  = element_text(size=12), legend.position = "bottom", legend.title = element_text(size = 12), legend.text = element_text(size = 10)) + geom_point(size = 2.5) + geom_abline(slope = k_plus, linetype = 2) + geom_abline(slope = coeff, size = 1.5)+  geom_abline(slope = k_minus, linetype = 2) + scale_y_continuous(limits = c(-300, 900), breaks = c(-300, 0, 300, 600, 900))


sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] ggplot2_3.2.1   workflowr_1.6.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3       compiler_3.6.2   pillar_1.4.3     later_1.0.0     
 [5] git2r_0.26.1     tools_3.6.2      digest_0.6.25    evaluate_0.14   
 [9] lifecycle_0.1.0  tibble_2.1.3     gtable_0.3.0     pkgconfig_2.0.3 
[13] rlang_0.4.4      yaml_2.2.1       xfun_0.12        withr_2.1.2     
[17] stringr_1.4.0    dplyr_0.8.4      knitr_1.28       fs_1.3.1        
[21] rprojroot_1.3-2  grid_3.6.2       tidyselect_1.0.0 glue_1.3.1      
[25] R6_2.4.1         rmarkdown_2.1    farver_2.0.3     purrr_0.3.3     
[29] magrittr_1.5     whisker_0.4      backports_1.1.5  scales_1.1.0    
[33] promises_1.1.0   htmltools_0.4.0  assertthat_0.2.1 colorspace_1.4-1
[37] httpuv_1.5.2     labeling_0.3     stringi_1.4.6    lazyeval_0.2.2  
[41] munsell_0.5.0    crayon_1.3.4