Last updated: 2020-07-08

Checks: 7 0

Knit directory: Epilepsy19/

This reproducible R Markdown analysis was created with workflowr (version 1.6.1). 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(20200706) 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 856ddcf. 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/fig_go.nb.html
    Ignored:    analysis/fig_neun.nb.html
    Ignored:    analysis/fig_overview.nb.html
    Ignored:    analysis/fig_smart_seq.nb.html
    Ignored:    analysis/fig_summary.nb.html
    Ignored:    analysis/fig_type_distance.nb.html
    Ignored:    analysis/gene_testing.nb.html
    Ignored:    analysis/prep_alignment.nb.html
    Ignored:    cache/con_allen.rds
    Ignored:    cache/con_filt_cells.rds
    Ignored:    cache/con_filt_samples.rds
    Ignored:    cache/con_ss.rds
    Ignored:    cache/count_matrices.rds
    Ignored:    cache/p2s/
    Ignored:    output/

Untracked files:
    Untracked:  DESCRIPTION
    Untracked:  NAMESPACE
    Untracked:  R/
    Untracked:  analysis/prep_alignment.Rmd
    Untracked:  analysis/prep_filtration.Rmd
    Untracked:  code/
    Untracked:  gene_modules/
    Untracked:  man/
    Untracked:  metadata/

Unstaged changes:
    Modified:   Epilepsy19.Rproj
    Modified:   README.md
    Modified:   analysis/index.Rmd

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/fig_summary.Rmd) and HTML (docs/fig_summary.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 5c8e634 viktor_petukhov 2020-07-08 Fixed dates in fig_ notebooks
Rmd a5ba713 viktor_petukhov 2020-07-07 Updated weights for fig_summary.Rmd
Rmd db74ffa viktor_petukhov 2020-07-06 Summary notebook

library(tidyverse)
library(magrittr)
library(cowplot)
devtools::load_all()

annotation <- MetadataPath("annotation.csv") %>% read_csv() %$% setNames(l4, cell)
neuron_type_per_type <- ifelse(grepl("L[2-6].+", unique(annotation)), "Excitatory", "Inhibitory") %>% 
  setNames(unique(annotation))
type_order <- names(neuron_type_per_type)[order(neuron_type_per_type, names(neuron_type_per_type))]
all_stat_df <- read_csv(OutputPath("total_ranking", "go.csv")) %>% 
  rbind(read_csv(OutputPath("total_ranking", "type_distance.csv"))) %>% 
  mutate(AffectionLevel=as.integer(pmax((Rank < 1.1) * 3, HighlyAffected * 2, Affected * 1)))

write_csv(all_stat_df, OutputPath("total_ranking", "total.csv"))

stat_weights = c(Similarity=1.0, CellNumber=0.66, GWAS=0.66, DENumber=0.66, GONumber=0.66, EPEnrichment=0.33)

aggr_type_score <- all_stat_df %>% split(.$Type) %>% 
  sapply(function(x) sum(x$AffectionLevel * stat_weights[x$StatType])) %>% 
  split(neuron_type_per_type[names(.)]) %>% lapply(sort, decreasing=T) %>% 
  Reduce(c, .)

all_stat_df %<>% 
  mutate(Type=factor(Type, levels=names(aggr_type_score)), 
         StatType=factor(StatType, levels=names(sort(stat_weights))),
         AffectionLevel=factor(AffectionLevel, levels=3:0))
stat_aliases <- c(EPEnrichment="Epilepsy\nenrichment", DENumber="Num. of\nDE genes", GONumber="Num. of\nGO pathways",
                  CellNumber="Num. of\ncells", GWAS="GWAS\nenrichment", Similarity="Expression\nsimilarity")

gg_stat_weights <- ggplot(tibble(N=names(stat_weights), V=as.character(stat_weights) %>% factor(levels=unique(.)))) +
  geom_tile(aes(y=factor(N, levels=rev(N)), x=1, fill=V)) +
  scale_fill_brewer("Stat weight", palette="Blues", direction=-1) +
  guides(fill=guide_legend(direction="horizontal", title.position="top", label.position="bottom", reverse=T)) +
  theme(legend.spacing.x=unit(0, "pt"))

gg_score <- ggplot(tibble(N=names(aggr_type_score), V=aggr_type_score)) + 
  geom_tile(aes(x=factor(N, levels=N), y=1, fill=V)) +
  guides(fill=guide_colorbar(direction="horizontal", title.position="top")) +
  scale_fill_distiller("Score", palette="Greens", direction="rev") +
  scale_y_continuous(expand=c(0, 0)) +
  theme(legend.key.width=unit(14, "pt"))

gg_ranks <- ggplot(all_stat_df) + 
  geom_tile(aes(x=Type, y=StatType, fill=AffectionLevel), alpha=stat_weights[as.character(all_stat_df$StatType)]) +
  gNtVline(neuron_type_per_type, color="black", linetype=1) +
  guides(fill=guide_legend(direction="horizontal", title.position="top", label.position="bottom", reverse=T)) +
  scale_fill_manual("Affection level", values=c("#e34a33", "#fdbb84", "#fee8c8", "gray")) +
  scale_y_discrete(expand=c(0, 0), name="Metric", labels=stat_aliases[levels(all_stat_df$StatType)]) +
  theme(axis.text.x=element_text(angle=90, hjust=1, vjust=0.5), panel.grid=element_blank(), 
        legend.spacing.x=unit(0, "pt"), panel.background=element_rect(fill="gray")) # , axis.title.x=element_blank()

plot_grid(
  ggdraw(gg_ranks + theme(legend.position="none", plot.margin=margin(r=10, t=10)) +
         draw_plot(gg_stat_weights + theme_nothing(), 
                   x=length(type_order) + 0.5, y=-5.9, height=6.25, width=1, vjust=-1) +
         draw_plot(gg_score + theme_nothing(), 
                   x=0.25, y=6.25, height=0.3, width=length(type_order) - 0.5, vjust=-1)),
  plot_grid(
    plot_grid(get_legend(gg_score), get_legend(gg_ranks), get_legend(gg_stat_weights), 
              ncol=1, align="v"),
    ggplot() + theme_nothing(), ncol=1, rel_heights=c(1, 0.75)
  ),
  nrow=1, rel_widths=c(1, 0.2), align="vh", axis="tb"
)

ggsave(OutputPath("all_differences.pdf"))

data.frame(value=unlist(sessioninfo::platform_info()))
value
version R version 3.5.1 (2018-07-02)
os Ubuntu 18.04.2 LTS
system x86_64, linux-gnu
ui X11
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2020-07-08
as.data.frame(sessioninfo::package_info())[c('package', 'loadedversion', 'date', 'source')]
package loadedversion date source
AnnotationDbi AnnotationDbi 1.44.0 2018-10-30 Bioconductor
assertthat assertthat 0.2.1 2019-03-21 CRAN (R 3.5.1)
backports backports 1.1.5 2019-10-02 CRAN (R 3.5.1)
base64enc base64enc 0.1-3 2015-07-28 CRAN (R 3.5.1)
beeswarm beeswarm 0.2.3 2016-04-25 CRAN (R 3.5.1)
Biobase Biobase 2.42.0 2018-10-30 Bioconductor
BiocGenerics BiocGenerics 0.28.0 2018-10-30 Bioconductor
bit bit 1.1-15.2 2020-02-10 CRAN (R 3.5.1)
bit64 bit64 0.9-7 2017-05-08 CRAN (R 3.5.1)
blob blob 1.2.1 2020-01-20 CRAN (R 3.5.1)
brew brew 1.0-6 2011-04-13 CRAN (R 3.5.1)
broom broom 0.5.5 2020-02-29 CRAN (R 3.5.1)
callr callr 3.4.2 2020-02-12 CRAN (R 3.5.1)
cellranger cellranger 1.1.0 2016-07-27 CRAN (R 3.5.1)
cli cli 2.0.2 2020-02-28 CRAN (R 3.5.1)
colorspace colorspace 1.4-1 2019-03-18 CRAN (R 3.5.1)
conos conos 1.3.0 2020-05-12 local
cowplot cowplot 1.0.0 2019-07-11 CRAN (R 3.5.1)
crayon crayon 1.3.4 2017-09-16 CRAN (R 3.5.1)
data.table data.table 1.12.8 2019-12-09 CRAN (R 3.5.1)
dataorganizer dataorganizer 0.1.0 2019-11-08 local
DBI DBI 1.1.0 2019-12-15 CRAN (R 3.5.1)
dbplyr dbplyr 1.4.2 2019-06-17 CRAN (R 3.5.1)
dendextend dendextend 1.13.4 2020-02-28 CRAN (R 3.5.1)
desc desc 1.2.0 2018-05-01 CRAN (R 3.5.1)
devtools devtools 2.2.2 2020-02-17 CRAN (R 3.5.1)
digest digest 0.6.25 2020-02-23 CRAN (R 3.5.1)
dplyr dplyr 0.8.5 2020-03-07 CRAN (R 3.5.1)
ellipsis ellipsis 0.3.0 2019-09-20 CRAN (R 3.5.1)
Epilepsy19 Epilepsy19 0.0.0.9000 2019-10-15 local
evaluate evaluate 0.14 2019-05-28 CRAN (R 3.5.1)
fansi fansi 0.4.1 2020-01-08 CRAN (R 3.5.1)
farver farver 2.0.3 2020-01-16 CRAN (R 3.5.1)
fastmap fastmap 1.0.1 2019-10-08 CRAN (R 3.5.1)
forcats forcats 0.5.0 2020-03-01 CRAN (R 3.5.1)
fs fs 1.3.2 2020-03-05 CRAN (R 3.5.1)
generics generics 0.0.2 2018-11-29 CRAN (R 3.5.1)
ggbeeswarm ggbeeswarm 0.6.0 2018-10-16 Github ()
ggplot2 ggplot2 3.3.0 2020-03-05 CRAN (R 3.5.1)
ggrastr ggrastr 0.1.7 2018-12-04 Github ()
git2r git2r 0.26.1 2019-06-29 CRAN (R 3.5.1)
glue glue 1.3.2 2020-03-12 CRAN (R 3.5.1)
gridExtra gridExtra 2.3 2017-09-09 CRAN (R 3.5.1)
gtable gtable 0.3.0 2019-03-25 CRAN (R 3.5.1)
haven haven 2.2.0 2019-11-08 CRAN (R 3.5.1)
highr highr 0.8 2019-03-20 CRAN (R 3.5.1)
hms hms 0.5.3 2020-01-08 CRAN (R 3.5.1)
htmltools htmltools 0.4.0 2019-10-04 CRAN (R 3.5.1)
httpuv httpuv 1.5.2 2019-09-11 CRAN (R 3.5.1)
httr httr 1.4.1 2019-08-05 CRAN (R 3.5.1)
igraph igraph 1.2.4.2 2019-11-27 CRAN (R 3.5.1)
IRanges IRanges 2.16.0 2018-10-30 Bioconductor
irlba irlba 2.3.3 2019-02-05 CRAN (R 3.5.1)
jsonlite jsonlite 1.6.1 2020-02-02 CRAN (R 3.5.1)
knitr knitr 1.28 2020-02-06 CRAN (R 3.5.1)
labeling labeling 0.3 2014-08-23 CRAN (R 3.5.1)
later later 1.0.0 2019-10-04 CRAN (R 3.5.1)
lattice lattice 0.20-40 2020-02-19 CRAN (R 3.5.1)
lifecycle lifecycle 0.2.0 2020-03-06 CRAN (R 3.5.1)
lubridate lubridate 1.7.4 2018-04-11 CRAN (R 3.5.1)
magrittr magrittr 1.5 2014-11-22 CRAN (R 3.5.1)
MASS MASS 7.3-51.5 2019-12-20 CRAN (R 3.5.1)
Matrix Matrix 1.2-18 2019-11-27 CRAN (R 3.5.1)
memoise memoise 1.1.0 2017-04-21 CRAN (R 3.5.1)
mime mime 0.9 2020-02-04 CRAN (R 3.5.1)
modelr modelr 0.1.6 2020-02-22 CRAN (R 3.5.1)
munsell munsell 0.5.0 2018-06-12 CRAN (R 3.5.1)
nlme nlme 3.1-145 2020-03-04 CRAN (R 3.5.1)
org.Hs.eg.db org.Hs.eg.db 3.7.0 2019-10-08 Bioconductor
pagoda2 pagoda2 0.1.1 2019-12-10 local
pbapply pbapply 1.4-2 2019-08-31 CRAN (R 3.5.1)
pillar pillar 1.4.3 2019-12-20 CRAN (R 3.5.1)
pkgbuild pkgbuild 1.0.6 2019-10-09 CRAN (R 3.5.1)
pkgconfig pkgconfig 2.0.3 2019-09-22 CRAN (R 3.5.1)
pkgload pkgload 1.0.2 2018-10-29 CRAN (R 3.5.1)
prettyunits prettyunits 1.1.1 2020-01-24 CRAN (R 3.5.1)
processx processx 3.4.2 2020-02-09 CRAN (R 3.5.1)
promises promises 1.1.0 2019-10-04 CRAN (R 3.5.1)
ps ps 1.3.2 2020-02-13 CRAN (R 3.5.1)
purrr purrr 0.3.3 2019-10-18 CRAN (R 3.5.1)
R6 R6 2.4.1 2019-11-12 CRAN (R 3.5.1)
RColorBrewer RColorBrewer 1.1-2 2014-12-07 CRAN (R 3.5.1)
Rcpp Rcpp 1.0.4 2020-03-17 CRAN (R 3.5.1)
readr readr 1.3.1 2018-12-21 CRAN (R 3.5.1)
readxl readxl 1.3.1 2019-03-13 CRAN (R 3.5.1)
remotes remotes 2.1.1 2020-02-15 CRAN (R 3.5.1)
reprex reprex 0.3.0 2019-05-16 CRAN (R 3.5.1)
rjson rjson 0.2.20 2018-06-08 CRAN (R 3.5.1)
rlang rlang 0.4.5 2020-03-01 CRAN (R 3.5.1)
rmarkdown rmarkdown 2.1 2020-01-20 CRAN (R 3.5.1)
Rook Rook 1.1-1 2014-10-20 CRAN (R 3.5.1)
rprojroot rprojroot 1.3-2 2018-01-03 CRAN (R 3.5.1)
RSQLite RSQLite 2.2.0 2020-01-07 CRAN (R 3.5.1)
rstudioapi rstudioapi 0.11 2020-02-07 CRAN (R 3.5.1)
rvest rvest 0.3.5 2019-11-08 CRAN (R 3.5.1)
S4Vectors S4Vectors 0.20.1 2018-11-09 Bioconductor
scales scales 1.1.0 2019-11-18 CRAN (R 3.5.1)
sccore sccore 0.1 2020-04-24 Github ()
sessioninfo sessioninfo 1.1.1 2018-11-05 CRAN (R 3.5.1)
shiny shiny 1.4.0.2 2020-03-13 CRAN (R 3.5.1)
stringi stringi 1.4.6 2020-02-17 CRAN (R 3.5.1)
stringr stringr 1.4.0 2019-02-10 CRAN (R 3.5.1)
testthat testthat 2.3.2 2020-03-02 CRAN (R 3.5.1)
tibble tibble 2.1.3 2019-06-06 CRAN (R 3.5.1)
tidyr tidyr 1.0.2 2020-01-24 CRAN (R 3.5.1)
tidyselect tidyselect 1.0.0 2020-01-27 CRAN (R 3.5.1)
tidyverse tidyverse 1.3.0 2019-11-21 CRAN (R 3.5.1)
triebeard triebeard 0.3.0 2016-08-04 CRAN (R 3.5.1)
urltools urltools 1.7.3 2019-04-14 CRAN (R 3.5.1)
usethis usethis 1.5.1 2019-07-04 CRAN (R 3.5.1)
vctrs vctrs 0.2.4 2020-03-10 CRAN (R 3.5.1)
vipor vipor 0.4.5 2017-03-22 CRAN (R 3.5.1)
viridis viridis 0.5.1 2018-03-29 CRAN (R 3.5.1)
viridisLite viridisLite 0.3.0 2018-02-01 CRAN (R 3.5.1)
whisker whisker 0.4 2019-08-28 CRAN (R 3.5.1)
withr withr 2.1.2 2018-03-15 CRAN (R 3.5.1)
workflowr workflowr 1.6.1 2020-03-11 CRAN (R 3.5.1)
xfun xfun 0.12 2020-01-13 CRAN (R 3.5.1)
xml2 xml2 1.2.5 2020-03-11 CRAN (R 3.5.1)
xtable xtable 1.8-4 2019-04-21 CRAN (R 3.5.1)
yaml yaml 2.2.1 2020-02-01 CRAN (R 3.5.1)