Last active
September 11, 2020 02:44
-
-
Save lcolladotor/350ac8843e153d135f64880a1d029b14 to your computer and use it in GitHub Desktop.
For https://docs.google.com/document/d/1iWKnvbn6wGS66rVTRSGkFcJyIKccWTCniN5CWvYuvfw/edit?usp=sharing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## For https://docs.google.com/document/d/1iWKnvbn6wGS66rVTRSGkFcJyIKccWTCniN5CWvYuvfw/edit?usp=sharing | |
## Install R packages if needed | |
# if (!requireNamespace("remotes", quietly = TRUE)) { | |
# install.packages("remotes") | |
# } | |
# remotes::install_cran("ggplot2") | |
# remotes::install_cran("plotly") | |
# remotes::install_cran("sessioninfo") | |
# remotes::install_cran("BiocManager") | |
# BiocManager::install("S4Vectors") | |
# BiocManager::install("BiocFileCache") | |
## Load required R packages | |
library("BiocFileCache") | |
library("S4Vectors") | |
library("ggplot2") | |
library("plotly") | |
library("sessioninfo") | |
## Download the data | |
url <- | |
"https://s3.us-east-2.amazonaws.com/libd-brainseq2/methprop_pd.Rdata" | |
bfc <- BiocFileCache::BiocFileCache() | |
data_path <- BiocFileCache::bfcrpath(bfc, url, exact = TRUE) | |
## Load the data | |
load(data_path, verbose = TRUE) | |
## Explore the data | |
colnames(pd) | |
## Some of the columns are *List objects | |
sapply(pd, class) | |
grepl("List", sapply(pd, class)) | |
## Convert to a regular data.frame (the easy columns) | |
pd_df <- as.data.frame(pd[, !grepl("List", sapply(pd, class))]) | |
## Explore the resulting data | |
dim(pd_df) | |
colnames(pd_df) | |
## We need a "key" variable that is unique | |
length(unique(pd_df$RNum)) | |
nrow(pd_df) | |
## Let's make the key | |
pd_df$key <- pd_df$RNum | |
## Let's make a "highlighted" table | |
pd_key <- highlight_key(pd_df, ~ key) | |
## Make a plot using the highlighted table | |
gg_mean_mito_vs_mean_gene <- | |
ggplot(pd_key, | |
aes(x = mean_mitoRate, y = mean_totalAssignedGene, color = Region)) + geom_point() | |
gg_mean_mito_vs_mean_gene | |
## Make a second plot | |
gg_mean_mito_vs_mean_RIN <- | |
ggplot(pd_key, aes(x = mean_mitoRate, y = mean_RIN, color = Region)) + geom_point() | |
gg_mean_mito_vs_mean_RIN | |
## Convert them to interactive plots | |
p_mean_mito_vs_mean_gene <- ggplotly(gg_mean_mito_vs_mean_gene) | |
p_mean_mito_vs_mean_RIN <- ggplotly(gg_mean_mito_vs_mean_RIN) | |
p_mean_mito_vs_mean_gene | |
p_mean_mito_vs_mean_RIN | |
## Now group them together | |
p_merged <- subplot( | |
p_mean_mito_vs_mean_gene, | |
p_mean_mito_vs_mean_RIN, | |
nrows = 1, | |
shareX = TRUE, | |
shareY = FALSE, | |
which_layout = 2 | |
) | |
p_merged | |
## Explore other highlight() options | |
highlight(p_merged, on = "plotly_click", off = "plotly_doubleclick") | |
highlight(p_merged, on = "plotly_hover", off = "plotly_doubleclick") | |
## Fancy one | |
highlight( | |
p_merged, | |
on = "plotly_click", | |
selectize = TRUE, | |
dynamic = TRUE, | |
persistent = TRUE | |
) | |
## Save the version you liked | |
htmlwidgets::saveWidget(highlight(p_merged, on = "plotly_click", off = "plotly_doubleclick"), | |
file = 'index.html') | |
## Automatically style this file | |
# styler::style_file(rstudioapi::getActiveDocumentContext()$path, | |
# transformers = biocthis::bioc_style()) | |
## Reproducibility information | |
print('Reproducibility information:') | |
Sys.time() | |
proc.time() | |
options(width = 120) | |
session_info() | |
# ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────── | |
# setting value | |
# version R version 4.0.2 (2020-06-22) | |
# os macOS Catalina 10.15.6 | |
# system x86_64, darwin17.0 | |
# ui RStudio | |
# language (EN) | |
# collate en_US.UTF-8 | |
# ctype en_US.UTF-8 | |
# tz America/New_York | |
# date 2020-09-10 | |
# | |
# ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────── | |
# package * version date lib source | |
# assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0) | |
# backports 1.1.9 2020-08-24 [1] CRAN (R 4.0.2) | |
# BiocFileCache * 1.12.1 2020-08-04 [1] Bioconductor | |
# BiocGenerics * 0.34.0 2020-04-27 [1] Bioconductor | |
# biocthis 0.99.0 2020-05-27 [1] Github (lcolladotor/biocthis@3b96da1) | |
# bit 4.0.4 2020-08-04 [1] CRAN (R 4.0.2) | |
# bit64 4.0.5 2020-08-30 [1] CRAN (R 4.0.2) | |
# blob 1.2.1 2020-01-20 [1] CRAN (R 4.0.0) | |
# Cairo 1.5-12.2 2020-07-07 [1] CRAN (R 4.0.2) | |
# callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.0) | |
# cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0) | |
# colorout * 1.2-2 2020-03-16 [1] Github (jalvesaq/colorout@726d681) | |
# colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.0) | |
# crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0) | |
# crosstalk 1.1.0.1 2020-03-13 [1] CRAN (R 4.0.0) | |
# curl 4.3 2019-12-02 [1] CRAN (R 4.0.0) | |
# data.table 1.13.0 2020-07-24 [1] CRAN (R 4.0.2) | |
# DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.0) | |
# dbplyr * 1.4.4 2020-05-27 [1] CRAN (R 4.0.2) | |
# digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0) | |
# dplyr 1.0.2 2020-08-18 [1] CRAN (R 4.0.2) | |
# ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.0) | |
# fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0) | |
# farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.0) | |
# fastmap 1.0.1 2019-10-08 [1] CRAN (R 4.0.0) | |
# fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2) | |
# generics 0.0.2 2018-11-29 [1] CRAN (R 4.0.0) | |
# ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 4.0.2) | |
# glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2) | |
# gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.0) | |
# htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2) | |
# htmlwidgets 1.5.1 2019-10-08 [1] CRAN (R 4.0.0) | |
# httpuv 1.5.4 2020-06-06 [1] CRAN (R 4.0.2) | |
# httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.2) | |
# jsonlite 1.7.0 2020-06-25 [1] CRAN (R 4.0.0) | |
# labeling 0.3 2014-08-23 [1] CRAN (R 4.0.0) | |
# later 1.1.0.1 2020-06-05 [1] CRAN (R 4.0.2) | |
# lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.0.0) | |
# lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0) | |
# magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0) | |
# memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0) | |
# mime 0.9 2020-02-04 [1] CRAN (R 4.0.0) | |
# munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.0) | |
# pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2) | |
# pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0) | |
# plotly * 4.9.2.1 2020-04-04 [1] CRAN (R 4.0.2) | |
# processx 3.4.3 2020-07-05 [1] CRAN (R 4.0.2) | |
# promises 1.1.1 2020-06-09 [1] CRAN (R 4.0.2) | |
# ps 1.3.4 2020-08-11 [1] CRAN (R 4.0.2) | |
# purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.0) | |
# R.cache 0.14.0 2019-12-06 [1] CRAN (R 4.0.0) | |
# R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.0.2) | |
# R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.0.2) | |
# R.utils 2.10.1 2020-08-26 [1] CRAN (R 4.0.2) | |
# R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0) | |
# rappdirs 0.3.1 2016-03-28 [1] CRAN (R 4.0.0) | |
# RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.2) | |
# Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2) | |
# rematch2 2.1.2 2020-05-01 [1] CRAN (R 4.0.0) | |
# rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2) | |
# RSQLite 2.2.0 2020-01-07 [1] CRAN (R 4.0.0) | |
# rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.0) | |
# S4Vectors * 0.26.1 2020-05-16 [1] Bioconductor | |
# scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.0) | |
# sessioninfo * 1.1.1 2018-11-05 [1] CRAN (R 4.0.2) | |
# shiny 1.5.0 2020-06-23 [1] CRAN (R 4.0.2) | |
# styler 1.3.2 2020-02-23 [1] CRAN (R 4.0.0) | |
# tibble 3.0.3 2020-07-10 [1] CRAN (R 4.0.2) | |
# tidyr 1.1.2 2020-08-27 [1] CRAN (R 4.0.2) | |
# tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.2) | |
# usethis 1.6.1 2020-04-29 [1] CRAN (R 4.0.2) | |
# vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2) | |
# viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.0) | |
# webshot 0.5.2 2019-11-22 [1] CRAN (R 4.0.0) | |
# withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.0) | |
# xfun 0.16 2020-07-24 [1] CRAN (R 4.0.2) | |
# xtable 1.8-4 2019-04-21 [1] CRAN (R 4.0.0) | |
# yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0) | |
# | |
# [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment