Last updated: 2022-03-10

Checks: 7 0

Knit directory: Amphibolis_Posidonia_Comparison/

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(20210414) 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 d4cd865. 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:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/OTT.nb.html
    Ignored:    analysis/plotRgenes.nb.html

Unstaged changes:
    Modified:   data/arabidopsis_gene_level_comparison.xlsx
    Modified:   data/arabidopsis_gene_level_comparison_only_losts.xlsx
    Modified:   data/arabidopsis_gene_level_counts.xlsx
    Modified:   output/GO_results_genes_in_Algae_NOT_Duckweeds_NOT_Seagrasses_NOT_Terrestrials.csv.png
    Modified:   output/GO_results_genes_in_Aquatics_NOT_Seagrasses_NOT_Terrestrials.csv.png
    Modified:   output/GO_results_genes_in_Duckweeds_NOT_Algae_NOT_Seagrasses_NOT_Terrestrials.csv.png
    Modified:   output/GO_results_genes_in_Seagrasses_NOT_Algae_NOT_Duckweeds_NOT_Terrestrials.csv.png
    Modified:   output/GO_results_genes_in_Seagrasses_NOT_Aquatics_NOT_Terrestrials.csv.png
    Modified:   output/GO_results_genes_in_Terrestrials_NOT_Aquatics_NOT_Seagrasses.csv.png
    Modified:   output/GO_results_genes_in_all_seagrasses_vs_backgroundAll_intersect.csv.png
    Modified:   output/GO_results_genes_in_all_seagrasses_vs_backgroundAll_union.csv.png
    Modified:   output/GO_results_genes_in_all_seagrasses_vs_seagrassesBackground_intersect.csv.png
    Modified:   output/GO_results_genes_lost_A_antarctica_not_other_seagrasses.csv.png
    Modified:   output/GO_results_genes_lost_P_australis_not_other_seagrasses.csv.png
    Modified:   output/GO_results_genes_lost_Z_marina_not_other_seagrasses.csv.png
    Modified:   output/GO_results_genes_lost_Z_muelleri_not_other_seagrasses.csv.png
    Modified:   output/GO_results_genes_only_P_australis_not_other_seagrasses.csv.png
    Modified:   output/GO_results_genes_only_Z_marina_not_other_seagrasses.csv.png
    Modified:   output/GO_results_genes_only_Z_muelleri_not_other_seagrasses.csv.png
    Modified:   output/GO_results_genes_union_Aquatics_and_Seagrasses_NOT_Terrestrials.csv.png
    Modified:   output/GO_results_terrestrials_vs_union_aquatics_seagrasses.png
    Modified:   output/Lost_GO_terms_in_five_species.PlantSpecific.xlsx
    Modified:   output/Lost_GO_terms_in_five_species.xlsx
    Modified:   output/Seagrasses_shared_lost_genes.xlsx
    Modified:   output/all_GO_plots.Rdata
    Modified:   output/patched_gene_loss.png
    Modified:   output/patchwork_seagrass_gene_loss.png
    Modified:   output/patchwork_terrestrials_gene_loss.png

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/plotRgenes.Rmd) and HTML (docs/plotRgenes.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 d4cd865 Philipp Bayer 2022-03-10 make the setup blocks nicer
html 46c7d2a Philipp Bayer 2022-03-08 Build site.
Rmd c706dc8 Philipp Bayer 2022-03-08 nicer table
html 2243fa6 Philipp Bayer 2022-02-23 muh files
html 1a19f93 Philipp Bayer 2022-02-23 Build site.
html 9b59467 Philipp Bayer 2022-02-23 Rewrite Orthofinder analysis
html 8bc36e6 Philipp Bayer 2022-02-21 Build site.
Rmd d06c086 Philipp Bayer 2022-02-21 summaryTable
html 48be9b2 Philipp Bayer 2022-02-21 Build site.
Rmd d3cdc00 Philipp Bayer 2022-02-21 better plot
html 292db59 Philipp Bayer 2021-10-18 Build site.
Rmd 95586f9 Philipp Bayer 2021-10-07 Add missing data
html 95586f9 Philipp Bayer 2021-10-07 Add missing data
html c0db4a5 Philipp Bayer 2021-10-07 Build site.
Rmd 08b28ea Philipp Bayer 2021-10-07 wflow_publish(files = c("analysis/*"))

library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.1.1
Warning: package 'ggplot2' was built under R version 4.1.1
Warning: package 'tibble' was built under R version 4.1.1
Warning: package 'tidyr' was built under R version 4.1.1
Warning: package 'readr' was built under R version 4.1.1
Warning: package 'purrr' was built under R version 4.1.1
Warning: package 'dplyr' was built under R version 4.1.1
Warning: package 'stringr' was built under R version 4.1.1
Warning: package 'forcats' was built under R version 4.1.1
library(wesanderson)
Warning: package 'wesanderson' was built under R version 4.1.1
library(ggtree)
library(ggtreeExtra)
Warning: package 'ggtreeExtra' was built under R version 4.1.1
library(kableExtra)
Warning: package 'kableExtra' was built under R version 4.1.2
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())

Visualising R-gene differences here

pal <- wes_palette("Zissou1", 3, type = "continuous")

df <- readxl::read_xlsx('./data/R_genes.xlsx')
df %>% ggplot(aes(fill=Class, x=Genome, y=Count)) + geom_bar(stat='identity') +
    scale_fill_manual(values=pal) +  
 coord_flip() +  cowplot::theme_minimal_vgrid() +
    theme(axis.text.y = element_text(face = "italic")) 

pal <- wes_palette("Zissou1", 4, type = "continuous")

df2 <- df %>% mutate(Class2= case_when(str_detect(Subclass, pattern = 'TN') ~ 'NLR (TNL)',
                                str_detect(Subclass, pattern = '^R') ~ Subclass,
                                TRUE ~ 'NLR (CNL)'))
df2 %>% ggplot(aes(fill=Class2, x=Genome, y=Count)) + geom_bar(stat='identity') +
    scale_fill_manual(values=pal)  + coord_flip() +  cowplot::theme_minimal_vgrid() +
    theme(axis.text.y = element_text(face = "italic")) 

df2 %>% dplyr::filter(Genome %in% c('P. australis', 'Z. marina', 'Z. muelleri', 'O. sativa', 'A. antarctica', 'A. thaliana')) %>% 
  ggplot(aes(fill=Class2, x=factor(Genome, levels=c('Z. marina', 'Z. muelleri', 'P. australis', 'A. antarctica', 'O. sativa', 'A. thaliana' )), y=Count)) + 
  geom_bar(stat='identity') +
    scale_fill_manual(values=pal)  + coord_flip() +  cowplot::theme_minimal_vgrid() +
    theme(axis.text.y = element_text(face = "italic")) +
  xlab('Genome') +
  labs(fill='Class')

Let’s link those to the phylogeny we got from timetree.org

tree <- ape::read.tree('./data/timetree_species.nwk')
tree$tip.label <- c('O. lucimarinus', 'C. reinhardtii', 'P. patens', 'S. moellendorffii', 'O. sativa', 'B. distachyon', 'Z. mays', 'P. australis', 'Z. marina', 'Z. muelleri', 'A. antarctica', 'S. polyrhiza', 'L. gibba', 'V. vinifera', 'A. thaliana', 'S. parvula', 'P. trichocarpa', 'A. trichopada')
p2 <- df2 %>% ggplot(aes(fill=Class2, x=Genome, y=Count)) + geom_bar(stat='identity') +
    scale_fill_manual(values=pal)  + coord_flip() +  cowplot::theme_minimal_vgrid() +
    theme(axis.text.y = element_text(face = "italic")) 
p1 <- ggtree(tree)
p1

df2$label <- df2$Genome
# get species not in tree
subtree <- ape::drop.tip(tree, tree$tip.label[!tree$tip.label %in% df2$label])
p1 <- ggtree(subtree)
p1 

df3 <- as.data.frame(df2)
df3$label <- df3$Genome
df3$id <- df3$label
# code from https://thackl.github.io/ggtree-composite-plots

tree_y <-  function(ggtree, data){
  if(!inherits(ggtree, "ggtree"))
    stop("not a ggtree object")
  left_join(select(data, label), select(ggtree$data, label, y)) %>%
    pull(y)
}
# overwrite the default expand for continuous scales
scale_y_tree <- function(expand=expand_scale(0, 0.6), ...){
    scale_y_continuous(expand=expand, ...)
}

# get the range of the ggtree y-axis data
tree_ylim <- function(ggtree){
  if(!inherits(ggtree, "ggtree"))
    stop("not a ggtree object")
  range(ggtree$data$y)
}

# plot data next to a ggtree aligned by shared labels
ggtreeplot <- function(ggtree, data = NULL, mapping = aes(), flip=FALSE,
     expand_limits=expand_scale(0,.6), ...){
  
  if(!inherits(ggtree, "ggtree"))
    stop("not a ggtree object")

  # match the tree limits
  limits <- tree_ylim(ggtree)
  limits[1] <- limits[1] + (limits[1] * expand_limits[1]) - expand_limits[2]
  limits[2] <- limits[2] + (limits[2] * expand_limits[3]) + expand_limits[4]
  
  if(flip){
    mapping <- modifyList(aes_(x=~x), mapping)
    data <- mutate(data, x=tree_y(ggtree, data))
    gg <- ggplot(data=data, mapping = mapping, ...) +
      scale_x_continuous(limits=limits, expand=c(0,0))
  }else{
    mapping <- modifyList(aes_(y=~y), mapping)
    data <- mutate(data, y=tree_y(ggtree, data))
    gg <- ggplot(data=data, mapping = mapping, ...) +
      scale_y_continuous(limits=limits, expand=c(0,0))
  }
  gg
}

# get rid of superfluous axis - this works after coord_flip, so it also works
# for the rotated histogram
no_y_axis <- function () 
  theme(axis.line.y = element_blank(), 
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank())
p3 <-  ggtree(subtree) + geom_tiplab(align=TRUE, fontface='italic') +
  scale_x_continuous(expand=expand_scale(0.8)) + scale_y_tree()
Warning: `expand_scale()` is deprecated; use `expansion()` instead.

Warning: `expand_scale()` is deprecated; use `expansion()` instead.
Scale for 'y' is already present. Adding another scale for 'y', which will
replace the existing scale.
myhist <- ggtreeplot(p3, df3, aes(y=Count, color=Class2, fill=Class2), flip=TRUE) +
  geom_col(aes(fill=Class2,group=Class2,color=Class2)) + 
  #theme(legend.position="none") +
  coord_flip() + no_y_axis()  + 
  theme(legend.position=c(0.6, 0.87)) + 
  labs(fill='Class', color='Class')
Warning: `expand_scale()` is deprecated; use `expansion()` instead.
Joining, by = "label"
p3 + myhist 

Quick summary stats

df %>% group_by(Genome, Class) %>% summarise(sum=sum(Count)) %>% pivot_wider(names_from = c('Class'), values_from = sum) %>% kbl() %>% kable_styling()
`summarise()` has grouped output by 'Genome'. You can override using the `.groups` argument.
Genome NLR RLK RLP
A. antarctica 739 958 251
A. thaliana 3415 2532 752
A. trichopada 1159 1239 665
B. distachyon 3058 2789 750
C. reinhardtii 2774 6 691
O. lucimarinus 193 5 43
O. sativa 4413 3746 1139
P. australis 588 1147 285
P. patens 1494 1660 649
P. trichocarpa 4524 4217 1606
Z. marina 755 1469 308
Z. muelleri 1256 1814 551

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

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

other attached packages:
 [1] kableExtra_1.3.4  ggtreeExtra_1.2.3 ggtree_3.0.4      wesanderson_0.3.6
 [5] forcats_0.5.1     stringr_1.4.0     dplyr_1.0.7       purrr_0.3.4      
 [9] readr_2.0.2       tidyr_1.1.4       tibble_3.1.5      ggplot2_3.3.5    
[13] tidyverse_1.3.1   workflowr_1.6.2  

loaded via a namespace (and not attached):
 [1] nlme_3.1-152       fs_1.5.0           lubridate_1.8.0    webshot_0.5.2     
 [5] httr_1.4.2         rprojroot_2.0.2    tools_4.1.0        backports_1.2.1   
 [9] bslib_0.3.1        utf8_1.2.2         R6_2.5.1           DBI_1.1.1         
[13] lazyeval_0.2.2     colorspace_2.0-2   withr_2.4.2        tidyselect_1.1.1  
[17] compiler_4.1.0     git2r_0.28.0       cli_3.0.1          rvest_1.0.2       
[21] xml2_1.3.2         labeling_0.4.2     sass_0.4.0         scales_1.1.1      
[25] systemfonts_1.0.4  digest_0.6.28      yulab.utils_0.0.4  rmarkdown_2.11    
[29] svglite_2.1.0      pkgconfig_2.0.3    htmltools_0.5.2    highr_0.9         
[33] dbplyr_2.1.1       fastmap_1.1.0      rlang_0.4.12       readxl_1.3.1      
[37] rstudioapi_0.13    farver_2.1.0       gridGraphics_0.5-1 jquerylib_0.1.4   
[41] generics_0.1.1     jsonlite_1.7.2     magrittr_2.0.1     ggplotify_0.1.0   
[45] patchwork_1.1.1    Rcpp_1.0.7         munsell_0.5.0      fansi_0.5.0       
[49] ape_5.5            ggnewscale_0.4.5   lifecycle_1.0.1    stringi_1.7.5     
[53] whisker_0.4        yaml_2.2.1         grid_4.1.0         parallel_4.1.0    
[57] promises_1.2.0.1   crayon_1.4.1       lattice_0.20-44    cowplot_1.1.1     
[61] haven_2.4.3        hms_1.1.1          knitr_1.36         pillar_1.6.4      
[65] reprex_2.0.1       glue_1.4.2         evaluate_0.14      ggfun_0.0.5       
[69] modelr_0.1.8       vctrs_0.3.8        treeio_1.16.2      tzdb_0.1.2        
[73] httpuv_1.6.3       cellranger_1.1.0   gtable_0.3.0       assertthat_0.2.1  
[77] xfun_0.27          broom_0.7.9        tidytree_0.3.7     later_1.3.0       
[81] viridisLite_0.4.0  aplot_0.1.2        ellipsis_0.3.2