Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
keithgmitchell committed Jan 17, 2020
1 parent 8e4c013 commit 8b0589f
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 123 deletions.
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
# scRNA_shiny_app
# scRNA-seq analysis application
---
# Dataset Information:
- Dataset name:
- Owner:
- Sharing with 1 user(s) and 1 group(s)
- Description:
- File size:

---
Shiny App Tutorial
---

### Single Marker View:
Explore a single feature (gene, metadata, etc.) and its relation to variations of clustering or on a per sample basis.

#### Options:
![](./docs/single_marker.png)
- Numeric Analysis Type: [Genes, Numeric Metadata, PCs]
- Genes: Are you interested in looking at genes or interest such as marker genes?
- Numeric Metadata: Are you interested in looking at metadata features such as:
- percent mitochondria expression for each cell’s expression (percent.mito)
- number of total unique genes or ‘features’ expressed (nFeature_RNA)
- Total number of genes expressed or total count of RNA (nCount_RNA)
- PCs: Are you interested in exploring the principal components that contribute to the tSNE plot seen?
- Identity:
- Orig.ident: This will color the graph based on the names of the samples processed.
- RNA_snn_res.0.XX: This will color the graph based on groupings produced by Seurat as various resolutions.
- A higher value of XX means that there is a higher resolution, and therefore more clusters or inferred groups of cell types.
- A lower value of XX means that there is a
- Primary Numeric: This will change to be Genes, Numeric Metadata, or PCs based on the value selected for ‘Numeric Analysis Type’.

#### Graphs:
- The first plot is a tSNE that is colored based on the Primary Numeric selection.
- The second plot is a violin plot that displays the Identity selection on the X-axis and the Primary Numeric on the Y-axis.
- The third plot is the tSNE that is colored based on the Identity selection.

Having trouble understanding what a tSNE plot represents?
- tSNE helpful video: https://www.youtube.com/watch?v=NEaUSP4YerM

---
### Double Marker View:
Explore two features (gene, metadata, etc.) and its relation to variations of clustering or on a per sample basis.

#### Options: All of the options here are the same as the Single Marker View with the following field as an option.
![](./docs/double_marker.png)
- Secondary Numeric: This, in combination with the Primary Numeric field enables a user to explore two Genes, Numeric Metadata, or PCs based on the value selected for ‘Numeric Analysis Type’.

#### Graphs:
- The first plot is a tSNE that is colored based on the Primary Numeric and Secondary Numeric selection.
- The second plot’s first tile is a violin plot that displays the Identity selection on the X-axis and the Primary Numeric on the Y-axis. The second plot’s second tile is the same as the first tile but is based on the selection of the Secondary Numeric field.
- The third plot is the tSNE that is colored based on the Identity selection.

Having trouble understanding what a tSNE plot represents?
- tSNE helpful video: https://www.youtube.com/watch?v=NEaUSP4YerM

---
### Marker Set (Grid)
This plot helps to explore sets of genes and their relation to the identity.

#### Options:
![](./docs/marker_set.png)
- Identity: the same as what is described for the Single Marker View
- Gene Selection: here you choose the set of genes you would like to explore based on the Identity selected.

#### Graph:
- Y-axis represents the Identity, such as the original samples or some groupings at a certain resolution.
- X-axis represents the genes selected. (Primary Numeric)
- The size of each dot on the grid represents the percentage of cells that expressed that gene.
- The color intensity of each dot on the grid represents the average expression of the cells that expressed a given gene.
- So what makes for a good marker gene for some given identity?
- High mean expression
- High percentage of cells expressing the gene
- Low mean expression and percentage of cells expressing the gene for the rest of the identities
42 changes: 23 additions & 19 deletions app.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ library(ggplot2)
library(tidyr)
library(dplyr)

load('experiment_merged.RData')
genes = experiment.merged@assays$RNA
meta_nums <- colnames(dplyr::select_if(experiment.merged@meta.data, is.numeric))
meta_cats <- colnames(dplyr::select_if(experiment.merged@meta.data, is.factor))

aggregate <- readRDS('Zhang_Seurat_UCD_blood.rds')
#aggregate
genes = aggregate@assays$RNA
meta_nums <- colnames(dplyr::select_if(aggregate@meta.data, is.numeric))
meta_cats <- colnames(dplyr::select_if(aggregate@meta.data, is.factor))
pcs <- list('PC_1','PC_2','PC_3','PC_4','PC_5','PC_6','PC_7','PC_8','PC_9')
agg_cats <- colnames(dplyr::select_if(experiment.merged@meta.data, is.factor))
agg_cats <- colnames(dplyr::select_if(aggregate@meta.data, is.factor))


server = function(input, output, session){
Expand Down Expand Up @@ -54,48 +56,48 @@ server = function(input, output, session){
# Marker Plot Double
output$MarkerGenePlot <- renderPlot({
FeaturePlot(
experiment.merged,
aggregate,
c(input$numeric, input$numeric2), blend=TRUE
)
})

# Marker Plot Single
output$MarkerGenePlotSingle <- renderPlot({
FeaturePlot(
experiment.merged,
aggregate,
c(input$numeric_single)
)
})

# Double Feature Categorical Feature Plot
output$CategoricalPlot <- renderPlot({
DimPlot(object = experiment.merged, group.by=input$categorical, pt.size=0.5, do.label = TRUE, reduction = "tsne", label = T)
DimPlot(object = aggregate, group.by=input$categorical, pt.size=0.5, do.label = TRUE, reduction = "tsne", label = T)
})

# Single Feature Categorical Feature Plot
output$CategoricalPlotSingle <- renderPlot({
DimPlot(object = experiment.merged, group.by=input$categorical_single, pt.size=0.5, do.label = TRUE, reduction = "tsne", label = T)
DimPlot(object = aggregate, group.by=input$categorical_single, pt.size=0.5, do.label = TRUE, reduction = "tsne", label = T)
})

# Double Feature Violin Plot
output$ViolinPlot <- renderPlot({
Idents(experiment.merged) <- input$categorical
VlnPlot(object = experiment.merged, features = c(input$numeric, input$numeric2), pt.size = 0.05)
Idents(aggregate) <- input$categorical
VlnPlot(object = aggregate, features = c(input$numeric, input$numeric2), pt.size = 0.05)
})

# Single Feature Violin Plot
output$ViolinPlotSingle <- renderPlot({
Idents(experiment.merged) <- input$categorical
VlnPlot(object = experiment.merged, features = c(input$numeric_single), pt.size = 0.05)
Idents(aggregate) <- input$categorical_single
VlnPlot(object = aggregate, features = c(input$numeric_single), pt.size = 0.05)
})

# Marker Set Plot
output$MarkerSet <- renderPlot({
Idents(experiment.merged) <- input$categorical_b
Idents(aggregate) <- input$categorical_b
markers = input$numeric_b
expr.cutoff = 3
widedat <- FetchData(experiment.merged, markers)
widedat$Cluster <- Idents(experiment.merged)
widedat <- FetchData(aggregate, markers)
widedat$Cluster <- Idents(aggregate)
longdat <- gather(widedat, key = "Gene", value = "Expression", -Cluster)
longdat$Is.Expressed <- ifelse(longdat$Expression > expr.cutoff, 1, 0)
longdat$Cluster <- factor(longdat$Cluster)
Expand Down Expand Up @@ -181,8 +183,8 @@ ui <- fluidPage(
tabPanel("Documentation", value=-999,
mainPanel(width = 12,
br(),
includeMarkdown("docs/testing.md"),
includeMarkdown("docs/todo.md")
#includeMarkdown("docs/testing.md")
includeMarkdown("README.md")
)
),

Expand Down Expand Up @@ -248,4 +250,6 @@ ui <- fluidPage(
)


shinyApp(ui, server)
shinyApp(ui, server)


74 changes: 0 additions & 74 deletions docs/documentation.md

This file was deleted.

Empty file removed docs/testing.md
Empty file.
29 changes: 0 additions & 29 deletions docs/todo.md

This file was deleted.

0 comments on commit 8b0589f

Please sign in to comment.