Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrue committed Feb 23, 2019
0 parents commit 2d47454
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
12 changes: 12 additions & 0 deletions 00-install.R
@@ -0,0 +1,12 @@

# Essentials ----

install.packages("BiocManager")
BiocManager::install("iSEE")
install.packages("rsconnect")

# GitHub ----

# For some reason rsconnect::deployApp() doesn't seem to like GitHub
# install.packages("devtools")
# devtools::install_github("csoneson/iSEE")
46 changes: 46 additions & 0 deletions 01-subset-allen.R
@@ -0,0 +1,46 @@
# Due to the memory limit on RStudio Cloud sessions, the full "allen" dataset could not be used for the demo.
# This script was run on a local machine to load and subset the "allen" dataset.
# The RDS file containing the subset was then uploaded to a Dropbox account from which it was downloaded from the RStudio Cloud session.
# Please refer to "02-subset-download.R" for that last step.

library(scRNAseq)
data("allen")

# Subset assays ----
assayNames(allen)
assay(allen, "counts") <- assay(allen, "tophat_counts")
for (x in setdiff(assayNames(allen), "counts")) {
assay(allen, x) <- NULL
}
allen

# Subset colData ----
colnames(colData(allen))
colData(allen) <- colData(allen)[, c("NREADS", "driver_1_s", "dissection_s", "Core.Type", "passes_qc_checks_s")]

# There is no colData ----
rowData(allen)

# Drop metadata ----
metadata(allen) <- list()

# Normalize ----
library(scater)
sce <- as(allen, "SingleCellExperiment")
sce <- normalize(sce)

# Add reduced dimensions ----
sce <- runPCA(sce, ncomponents=4)
sce <- runTSNE(sce)

# Subset features ----
keep <- which(order(rowVars(assay(sce, "logcounts"))) <= 500) # keep 500 most variable
sce <- sce[keep, ]

# Add rowData ----
rowData(sce)$ave_count <- rowMeans(counts(sce))
rowData(sce)$n_cells <- rowSums(counts(sce)>0)
sce

# save to RDS ----
saveRDS(sce, "allen.subset.rds")
17 changes: 17 additions & 0 deletions 02-subset-download.R
@@ -0,0 +1,17 @@
# Due to the memory limit on RStudio Cloud sessions, the full "allen" dataset could not be used for the demo.
# This script was run from the RStudio Cloud session to download a subset of the data, preprocessed on a local machine.
# Please refer to "01-subset-allen.R" for the preprocessing.


BiocManager::install("BiocFileCache")

library(BiocFileCache)
bfc <- BiocFileCache()

url <- "https://www.dropbox.com/s/yps03y6ws8rtc1h/allen.subset.rds?dl=1"
if (identical(nrow(bfcquery(bfc, "AllenSubset")), 0L)) {
add5 <- bfcadd(bfc, "AllenSubset", fpath=url)
}
rid5 <- names(add5)

file.copy(add5, "allen.subset.rds")
5 changes: 5 additions & 0 deletions 99-deploy.R
@@ -0,0 +1,5 @@

library(rsconnect)
# rsconnect::setAccountInfo(name='kevinrue', token='xxxx', secret='xxx')
options(repos = BiocManager::repositories())
rsconnect::deployApp()
Binary file added allen.subset.rds
Binary file not shown.
11 changes: 11 additions & 0 deletions app.R
@@ -0,0 +1,11 @@

library(SingleCellExperiment)
sce <- readRDS("allen.subset.rds")

library(iSEE)
library(shiny)

# Preload the tour, so that it opens on startup
tour <- read.delim(system.file(package = "iSEE", "extdata", "intro_firststeps.txt"), header = TRUE, sep = ";")
packageVersion("iSEE")
iSEE(sce, tour = tour)
16 changes: 16 additions & 0 deletions isee-shiny-contest.Rproj
@@ -0,0 +1,16 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
10 changes: 10 additions & 0 deletions rsconnect/shinyapps.io/kevinrue/isee-shiny-contest.dcf
@@ -0,0 +1,10 @@
name: isee-shiny-contest
title: iSEE app using a subset of the allen dataset
username: kevinrue
account: kevinrue
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 735398
bundleId: 1894024
url: https://kevinrue.shinyapps.io/isee-shiny-contest/
when: 1550950950.2006

0 comments on commit 2d47454

Please sign in to comment.