Last updated: 2019-12-06
Checks: 6 1
Knit directory: bentsen-rausch-2019/
This reproducible R Markdown analysis was created with workflowr (version 1.4.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.
The global environment had objects present when the code in the R Markdown file was run. These objects 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. Use wflow_publish
or wflow_build
to ensure that the code is always run in an empty environment.
The following objects were defined in the global environment when these results were created:
Name | Class | Size |
---|---|---|
data | environment | 56 bytes |
env | environment | 56 bytes |
The command set.seed(20191021)
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: .Rproj.user/
Ignored: analysis/figure/
Ignored: test_files/
Untracked files:
Untracked: analysis/figure_6.Rmd
Untracked: analysis/figure_7.Rmd
Untracked: analysis/olig_ttest_padj.csv
Untracked: analysis/supp1.Rmd
Untracked: code/sc_functions.R
Untracked: data/bulk/
Untracked: data/fgf_filtered_nuclei.RDS
Untracked: data/figures/
Untracked: data/filtglia.RDS
Untracked: data/glia/
Untracked: data/lps1.txt
Untracked: data/mcao1.txt
Untracked: data/mcao_d3.txt
Untracked: data/mcaod7.txt
Untracked: data/mouse_data/
Untracked: data/neur_astro_induce.xlsx
Untracked: data/neuron/
Untracked: data/synaptic_activity_induced.xlsx
Untracked: olig_ttest_padj.csv
Untracked: output/agrp_pcgenes.csv
Untracked: output/all_wc_markers.csv
Untracked: output/allglia_wgcna_genemodules.csv
Untracked: output/bulk/
Untracked: output/fig.RData
Untracked: output/fig4_part2.RData
Untracked: output/glia/
Untracked: output/glial_markergenes.csv
Untracked: output/integrated_all_markergenes.csv
Untracked: output/integrated_neuronmarkers.csv
Untracked: output/neuron/
Untracked: wc_de.pdf
Unstaged changes:
Modified: analysis/9_wc_processing.Rmd
Modified: analysis/figure_1.Rmd
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 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 | e326368 | Full Name | 2019-12-06 | wflow_publish(“analysis/13_olig_pseudotime.Rmd”) |
html | f4dd96b | Full Name | 2019-10-29 | Build site. |
html | 3b5cbe7 | Full Name | 2019-10-28 | Build site. |
library(here)
here() starts at /nfsdata/projects/dylan/bentsen-rausch-2019
library(Seurat)
library(monocle)
Loading required package: Matrix
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:Matrix':
colMeans, colSums, rowMeans, rowSums, which
The following objects are masked from 'package:stats':
IQR, mad, sd, var, xtabs
The following objects are masked from 'package:base':
anyDuplicated, append, as.data.frame, basename, cbind,
colMeans, colnames, colSums, dirname, do.call, duplicated,
eval, evalq, Filter, Find, get, grep, grepl, intersect,
is.unsorted, lapply, lengths, Map, mapply, match, mget, order,
paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind,
Reduce, rowMeans, rownames, rowSums, sapply, setdiff, sort,
table, tapply, union, unique, unsplit, which, which.max,
which.min
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Loading required package: ggplot2
Loading required package: VGAM
Loading required package: stats4
Loading required package: splines
Loading required package: DDRTree
Loading required package: irlba
library(ggplot2)
library(tidyverse)
── Attaching packages ────────────────────────────────── tidyverse 1.2.1 ──
✔ tibble 2.1.3 ✔ purrr 0.3.2
✔ tidyr 0.8.3 ✔ dplyr 0.8.3
✔ readr 1.3.1.9000 ✔ stringr 1.4.0
✔ tibble 2.1.3 ✔ forcats 0.4.0
── Conflicts ───────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::combine() masks Biobase::combine(), BiocGenerics::combine()
✖ tidyr::expand() masks Matrix::expand()
✖ tidyr::fill() masks VGAM::fill()
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
✖ ggplot2::Position() masks BiocGenerics::Position(), base::Position()
library(rstatix)
Attaching package: 'rstatix'
The following object is masked from 'package:stats':
filter
library(ggpubr)
Loading required package: magrittr
Attaching package: 'magrittr'
The following object is masked from 'package:purrr':
set_names
The following object is masked from 'package:tidyr':
extract
library(ggsci)
library(ggrepel)
library(reshape2)
Attaching package: 'reshape2'
The following object is masked from 'package:tidyr':
smiths
library(cowplot)
********************************************************
Note: As of version 1.0.0, cowplot does not change the
default ggplot2 theme anymore. To recover the previous
behavior, execute:
theme_set(theme_cowplot())
********************************************************
Attaching package: 'cowplot'
The following object is masked from 'package:ggpubr':
get_legend
library(ggpubr)
olig <- readRDS(here("data/glia/olig_labeled.RDS"))
olig_plot <- as.data.frame(Embeddings(olig, reduction = "umap"))
olig_plot$trt <- olig$trt
olig_plot$type <- Idents(olig)
label.df <- data.frame(cluster=levels(olig_plot$type),label=levels(olig_plot$type))
label.df_2 <- olig_plot %>%
dplyr::group_by(type) %>%
dplyr::summarize(x = median(UMAP_1), y = median(UMAP_2))
a <- ggplot(olig_plot, aes(UMAP_1, UMAP_2, colour = trt)) +
geom_point(alpha = 0.5, size=.5) + scale_color_manual(values=c("#000000","#999999"), name="") +
guides(colour = guide_legend(override.aes = list(size=2))) + theme_pubr() + theme(legend.position = c(0.3, 0.25), legend.background=element_blank())
b <- ggplot(olig_plot, aes(UMAP_1, UMAP_2, colour = type)) +
geom_point(alpha = 0.5, size=.5) + scale_colour_discrete(name="Treatment") +
geom_label_repel(data = label.df_2, aes(label = type, x=x, y=y), size=3, fontface="bold", inherit.aes = F) +
guides(colour = guide_legend(override.aes = list(size=5))) + theme_pubr() + theme(legend.position = "none")
plot_grid(a,b)
cell<-as.data.frame.matrix(table(olig$orig.ident, olig@active.ident))
cell$trt<-as.factor(sapply(strsplit(rownames(cell),"_"),"[",2))
cell<-melt(cell)
stat.test <- cell %>%
group_by(variable) %>%
t_test(value ~ trt) %>%
adjust_pvalue() %>%
add_significance("p.adj")
Warning: `set_attrs()` is deprecated as of rlang 0.3.0
This warning is displayed once per session.
cell %>% dplyr::group_by(trt, variable) %>%
dplyr::summarise(mean=mean(value), sd = sd(value), se = sd/sqrt(length(value))) %>%
mutate(signif = stat.test$p.adj.signif) %>%
mutate(signif = ifelse(trt == "FGF1", yes = NA, no = signif)) %>% ungroup() -> plotval
write.csv(plotval, file="olig_ttest_padj.csv")
plotval %>% mutate(variable = fct_relevel(variable, c("OPC","COP", "NFOL","MFOL","MOL1"))) %>%
mutate(trt = fct_relevel(trt, c("Vehicle","FGF1")))-> plotval
Warning: Unknown levels in `f`: Vehicle
ggplot(plotval, aes(x = variable, y = mean, fill = trt)) +
geom_bar(position=position_dodge(), stat="identity") +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se),size=.3,width=.2,position=position_dodge(.9)) +
xlab(NULL) + scale_fill_manual(values=c("gray80","gray30")) +
ylab("Number of cells") +
ggpubr::theme_pubr(legend = "none") +
theme(axis.text.x = element_text(angle=45, hjust=1)) +
geom_signif(y_position=c(plotval %>% dplyr::group_by(variable) %>% dplyr::summarise(max = max(mean)) %>% pull(max) + 50),
xmin = c(seq(0.9,4.9, by = 1)), xmax=c(seq(1.1,5.1, by = 1)),
annotation=c(plotval %>% slice(6:10) %>% pull(signif) %>% as.character() %>% toupper())[c(1,4,5,3,2)],
tip_length=0, size = 0.5, textsize = 3, color="black", vjust = -1) + coord_cartesian(clip="off") -> oligttest
oligttest
cds <- as.CellDataSet(olig)
cds <- estimateSizeFactors(cds)
cds <- estimateDispersions(cds)
cds <- detectGenes(cds, min_expr = 0.1)
fData(cds)$use_for_ordering <-
fData(cds)$num_cells_expressed > 0.1 * ncol(cds)
cds <- reduceDimension(cds,
max_components = 2,
norm_method = 'log',
num_dim = 2,
reduction_method = 'tSNE',
verbose = T)
cds <- clusterCells(cds, verbose = T)
Distance cutoff calculated to 7.253532
cds <- clusterCells(cds,
rho_threshold = 150,
delta_threshold = 15,
skip_rho_sigma = T,
verbose = F)
plot_cell_clusters(cds, label_groups_by_cluster=FALSE, color_cells_by = "Cluster")
Version | Author | Date |
---|---|---|
f4dd96b | Full Name | 2019-10-29 |
olig_expressed_genes <- row.names(subset(fData(cds), num_cells_expressed >= 10))
clustering_DEG_genes <-
differentialGeneTest(cds[olig_expressed_genes,],
fullModelFormulaStr = '~predicted.id',
cores = 10)
olig_ordering_genes <-
row.names(clustering_DEG_genes)[order(clustering_DEG_genes$qval)][1:500]
cds <-
setOrderingFilter(cds,
ordering_genes = olig_ordering_genes)
cds <-
reduceDimension(cds, method = 'DDRTree')
cds <-
orderCells(cds)
cds <-
orderCells(cds, root_state = 2)
olig$pseudo <- cds$Pseudotime
plot_cell_trajectory(cds,color_by = "predicted.id")
ggsave(here("data/figures/supp/monocle_by_celltype.pdf"))
plot_cell_trajectory(cds, markers = "Gpr17")
ggsave(here("data/figures/supp/monocle_by_gpr17.pdf"))
plot_cell_trajectory(cds, color_by = "Pseudotime")
ggsave(here("data/figures/supp/monocle_by_pseudo.pdf"))
plot_cell_trajectory(cds, color_by = "trt", alpha=0.5)
ggsave(here("data/figures/supp/monocle_by_trt.pdf"))
olig_plot$pseudo <- olig$pseudo
olig_plot$gpr17 <- as.numeric(olig@assays[["SCT"]]@data["Gpr17",])
ggplot(olig_plot, aes(UMAP_1, UMAP_2, colour = pseudo)) +
geom_point(alpha = 0.5, size=.5) + ggsci::scale_color_material(name="Pseudotime", guide = guide_colorbar(title.position = "top"), palette = "blue-grey") +
ggpubr::theme_pubr() + xlab(NULL) + ylab(NULL) +
theme(legend.position = c(0.3,0.25), legend.direction = "horizontal",legend.title = element_text(hjust=0.5), legend.background = element_blank()) -> olig_pseudo
ggplot(olig_plot, aes(UMAP_1, UMAP_2, color = gpr17)) +
geom_point(alpha = 0.75, size=.5) + ggsci::scale_color_material(name="Gpr17 Expression", palette = "deep-orange",
guide = guide_colorbar(title.position = "top")) +
ggpubr::theme_pubr() + xlab(NULL) + ylab(NULL) +
theme(legend.position = c(0.3,0.25), legend.direction = "horizontal",legend.title = element_text(hjust=0.5), legend.background = element_blank()) -> olig_gpr17
sc_olig <- cowplot::plot_grid(b, addSmallLegend(olig_pseudo), oligttest, addSmallLegend(olig_gpr17), ncol=2, labels="auto", scale=0.9, align="hv")
sc_olig
Version | Author | Date |
---|---|---|
f4dd96b | Full Name | 2019-10-29 |
readxl::read_xlsx(path = here("data/mouse_data/fig6/191118_Gpr17.xlsx"), range="A4:B10") %>%
reshape2::melt() %>% na.omit() -> gpr17
gpr17 %>% dplyr::group_by(variable) %>% dplyr::summarise(mean=mean(value), sd = sd(value), se = sd/sqrt(length(value))) %>%
ggplot(aes(x=variable, y=mean, fill=variable, color=variable)) +
geom_col(width=1, alpha=0.75, colour="black", position="dodge") +
geom_errorbar(aes(x=variable, ymin = mean-se, ymax=mean+se), width=0.2, position=position_dodge(.9), size=1) +
geom_jitter(data = gpr17, inherit.aes = F, aes(x=variable, y=value, fill=variable),
alpha=0.5, shape=21, position = position_jitterdodge(.5)) + xlab(NULL) +
#geom_text(position = position_dodge2(width=.9, preserve="single"), aes(y=value+se+1), face = "bold", size=8) +
ylab("GPR17+ Cells Per mm²") + scale_fill_manual("Treatment", values=c("gray80","gray30")) +
scale_color_manual("Treatment", values=c("gray80","gray30"))+ theme_classic() +
theme(legend.position = "none", legend.background = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank()) +
geom_signif(y_position=max(gpr17$value), xmin=1.2, xmax=1.8,
annotation=c("*"), tip_length=0, size = 0.5, textsize = 6, color="black") + coord_cartesian(clip="off") -> gpr17_bp
olig_val <- cowplot::plot_grid(ggplot() + theme_void(), gpr17_bp, nrow=1, scale=0.9, labels=c("e","f"), rel_widths = c(2,1))
cowplot::plot_grid(sc_olig, olig_val, ncol=1, align="hv", rel_heights = c(1.75,1))
Version | Author | Date |
---|---|---|
3b5cbe7 | Full Name | 2019-10-28 |
#ggsave("figure_6.tiff", width=12, h=8, dpi=600, compression = "lzw")
sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Storage
Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.3.so
locale:
[1] LC_CTYPE=en_DK.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_DK.UTF-8 LC_COLLATE=en_DK.UTF-8
[5] LC_MONETARY=en_DK.UTF-8 LC_MESSAGES=en_DK.UTF-8
[7] LC_PAPER=en_DK.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_DK.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] splines stats4 parallel stats graphics grDevices utils
[8] datasets methods base
other attached packages:
[1] here_0.1 cowplot_1.0.0 reshape2_1.4.3
[4] ggrepel_0.8.0.9000 ggsci_2.9 ggpubr_0.2.1
[7] magrittr_1.5 rstatix_0.1.1 forcats_0.4.0
[10] stringr_1.4.0 dplyr_0.8.3 purrr_0.3.2
[13] readr_1.3.1.9000 tidyr_0.8.3 tibble_2.1.3
[16] tidyverse_1.2.1 monocle_2.10.1 DDRTree_0.1.5
[19] irlba_2.3.3 VGAM_1.1-1 ggplot2_3.2.1
[22] Biobase_2.42.0 BiocGenerics_0.28.0 Matrix_1.2-17
[25] Seurat_3.0.3.9036
loaded via a namespace (and not attached):
[1] readxl_1.3.1 backports_1.1.4 workflowr_1.4.0
[4] plyr_1.8.4 igraph_1.2.4.1 lazyeval_0.2.2
[7] densityClust_0.3 listenv_0.7.0 fastICA_1.2-1
[10] digest_0.6.20 htmltools_0.3.6 viridis_0.5.1
[13] gdata_2.18.0 cluster_2.1.0 ROCR_1.0-7
[16] openxlsx_4.1.0.1 limma_3.38.3 globals_0.12.4
[19] modelr_0.1.4 RcppParallel_4.4.3 matrixStats_0.54.0
[22] R.utils_2.9.0 docopt_0.6.1 colorspace_1.4-1
[25] rvest_0.3.4 haven_2.1.0 xfun_0.8
[28] sparsesvd_0.1-4 crayon_1.3.4 jsonlite_1.6
[31] zeallot_0.1.0 survival_2.44-1.1 zoo_1.8-6
[34] ape_5.3 glue_1.3.1 gtable_0.3.0
[37] leiden_0.3.1 car_3.0-3 future.apply_1.3.0
[40] abind_1.4-5 scales_1.0.0 pheatmap_1.0.12
[43] bibtex_0.4.2 Rcpp_1.0.2 metap_1.1
[46] viridisLite_0.3.0 reticulate_1.13 proxy_0.4-23
[49] foreign_0.8-71 rsvd_1.0.2 SDMTools_1.1-221.1
[52] tsne_0.1-3 htmlwidgets_1.3 httr_1.4.1
[55] FNN_1.1.3 gplots_3.0.1.1 RColorBrewer_1.1-2
[58] ica_1.0-2 pkgconfig_2.0.2 R.methodsS3_1.7.1
[61] uwot_0.1.3 labeling_0.3 tidyselect_0.2.5
[64] rlang_0.4.0 munsell_0.5.0 cellranger_1.1.0
[67] tools_3.5.3 cli_1.1.0 generics_0.0.2
[70] broom_0.5.2 ggridges_0.5.1 evaluate_0.14
[73] yaml_2.2.0 npsurv_0.4-0 knitr_1.23
[76] fs_1.3.1 fitdistrplus_1.0-14 zip_2.0.3
[79] caTools_1.17.1.2 RANN_2.6.1 pbapply_1.4-1
[82] future_1.14.0 nlme_3.1-140 whisker_0.3-2
[85] slam_0.1-45 R.oo_1.22.0 xml2_1.2.0
[88] compiler_3.5.3 rstudioapi_0.10 curl_4.0
[91] plotly_4.9.0 png_0.1-7 ggsignif_0.5.0
[94] lsei_1.2-0 stringi_1.4.3 highr_0.8
[97] lattice_0.20-38 HSMMSingleCell_1.2.0 vctrs_0.2.0
[100] pillar_1.4.2 combinat_0.0-8 Rdpack_0.11-0
[103] lmtest_0.9-37 RcppAnnoy_0.0.12 data.table_1.12.2
[106] bitops_1.0-6 gbRd_0.4-11 R6_2.4.0
[109] rio_0.5.16 KernSmooth_2.23-15 gridExtra_2.3
[112] codetools_0.2-16 MASS_7.3-51.4 gtools_3.8.1
[115] assertthat_0.2.1 rprojroot_1.3-2 withr_2.1.2
[118] qlcMatrix_0.9.7 sctransform_0.2.0 hms_0.5.0
[121] grid_3.5.3 rmarkdown_1.13 carData_3.0-2
[124] Rtsne_0.15 git2r_0.25.2 lubridate_1.7.4
[127] rematch_1.0.1