-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bioinfo core repo with aws setup instructions
- Loading branch information
1 parent
c9e2957
commit b5ac87e
Showing
18 changed files
with
319 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
|
||
# scRNA_shiny_app |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
library(shiny) | ||
library(Seurat) | ||
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)) | ||
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)) | ||
|
||
|
||
server = function(input, output, session){ | ||
outVar = reactive({ | ||
if (input$dataset == 'Genes'){mydata=row.names(genes)} | ||
else if (input$dataset == 'Numeric Metadata') {mydata=meta_nums} | ||
else if (input$dataset == 'PCs') {mydata=pcs} | ||
mydata | ||
}) | ||
|
||
outVar = reactive({ | ||
if (input$dataset_single == 'Genes'){mydata=row.names(genes)} | ||
else if (input$dataset_single == 'Numeric Metadata') {mydata=meta_nums} | ||
else if (input$dataset_single == 'PCs') {mydata=pcs} | ||
mydata | ||
}) | ||
|
||
observe({ | ||
updateSelectInput(session, "numeric", | ||
choices = outVar() | ||
)}) | ||
|
||
observe({ | ||
updateSelectInput(session, "numeric2", | ||
choices = outVar() | ||
)}) | ||
|
||
observe({ | ||
updateSelectInput(session, "numeric_b", | ||
choices = outVar() | ||
)}) | ||
|
||
observe({ | ||
updateSelectInput(session, "numeric_single", | ||
choices = outVar() | ||
)}) | ||
|
||
# formulaText <- reactive({ | ||
# paste("Marker Gene ~", input$numeric) | ||
# }) | ||
|
||
# Marker Plot Double | ||
output$MarkerGenePlot <- renderPlot({ | ||
FeaturePlot( | ||
experiment.merged, | ||
c(input$numeric, input$numeric2), blend=TRUE | ||
) | ||
}) | ||
|
||
# Marker Plot Single | ||
output$MarkerGenePlotSingle <- renderPlot({ | ||
FeaturePlot( | ||
experiment.merged, | ||
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) | ||
}) | ||
|
||
# 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) | ||
}) | ||
|
||
# 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) | ||
}) | ||
|
||
# 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) | ||
}) | ||
|
||
# Marker Set Plot | ||
output$MarkerSet <- renderPlot({ | ||
Idents(experiment.merged) <- input$categorical_b | ||
markers = input$numeric_b | ||
expr.cutoff = 3 | ||
widedat <- FetchData(experiment.merged, markers) | ||
widedat$Cluster <- Idents(experiment.merged) | ||
longdat <- gather(widedat, key = "Gene", value = "Expression", -Cluster) | ||
longdat$Is.Expressed <- ifelse(longdat$Expression > expr.cutoff, 1, 0) | ||
longdat$Cluster <- factor(longdat$Cluster) | ||
longdat$Gene <- factor(longdat$Gene) | ||
|
||
# Need to summarize into average expression, pct expressed (which is also an average) | ||
plotdat <- group_by(longdat, Gene, Cluster) %>% summarize(`Percentage of Expressed Cells` = mean(Is.Expressed), `Mean Expression` = mean(Expression)) | ||
ggplot(plotdat, aes(x = Gene, y = Cluster)) + | ||
geom_point(aes(size = `Percentage of Expressed Cells`, col = `Mean Expression`)) + | ||
labs(size = "Percentage\nof Expressed\nCells", col = "Mean\nExpression", x = NULL) + | ||
scale_color_gradient(low = "grey", high = "slateblue4") + theme_grey(base_size = 15) + | ||
theme(axis.text.x = element_text(angle = 90, hjust = 1)) | ||
# }, height = 1000, width = 900 ) | ||
}, height = 1000) | ||
|
||
} | ||
|
||
# ui <- fluidPage( | ||
# | ||
# # App title ---- | ||
# titlePanel("scRNA Seurat Analysis"), | ||
# | ||
# # Sidebar layout with input and output definitions ---- | ||
# sidebarLayout( | ||
# | ||
# # Sidebar panel for inputs ---- | ||
# sidebarPanel( | ||
# conditionalPanel(condition = "input.tabselected == -999", | ||
# selectInput("dataset", "Numeric Analysis Type:", | ||
# c('Genes', 'Numeric Metadata','PCs')), | ||
# selectInput("categorical", "Identity:", | ||
# c(meta_cats)), | ||
# selectInput("numeric", "Primary Numeric:", ""), | ||
# | ||
# selectInput('numeric2', 'Secondary Numeric', "") | ||
# ), | ||
# | ||
# conditionalPanel(condition = "input.tabselected == 2", | ||
# selectInput("categorical_b", "Identity:", | ||
# c(agg_cats)), | ||
# selectInput("numeric_b", "Primary Numeric:", "", multiple=TRUE) | ||
# ), | ||
# conditionalPanel(condition = "input.tabselected == 3") | ||
# ), | ||
# | ||
# # Main panel for displaying outputs ---- | ||
# mainPanel( | ||
# | ||
# # Output: Tabset w/ plot, summary, and table ---- | ||
# navbarPage("My application", | ||
# tabPanel("Marker Genes (TSNE)", value=-999, | ||
# #h3(textOutput("caption")), | ||
# plotOutput("MarkerGenePlot"), | ||
# plotOutput("ViolinPlot"), | ||
# #h3(textOutput("caption2")), | ||
# plotOutput("CategoricalPlot") | ||
# #h3(textOutput("caption3")), | ||
# ), | ||
# | ||
# tabPanel("Marker Set (Grid)", value=2, | ||
# plotOutput("MarkerSet") | ||
# ), | ||
# | ||
# tabPanel("Documentation", value=3, | ||
# includeMarkdown("docs/testing.md"), | ||
# includeMarkdown("docs/todo.md") | ||
# ), | ||
# | ||
# id = "tabselected" | ||
# ) | ||
# ) | ||
# ) | ||
# ) | ||
|
||
|
||
|
||
ui <- fluidPage( | ||
|
||
titlePanel("scRNA Seurat Analysis"), | ||
sidebarLayout( | ||
sidebarPanel(width = 12, | ||
tabsetPanel( | ||
tabPanel("Documentation", value=-999, | ||
mainPanel(width = 12, | ||
br(), | ||
includeMarkdown("docs/testing.md"), | ||
includeMarkdown("docs/todo.md") | ||
) | ||
), | ||
|
||
tabPanel("Double Marker", value=2, | ||
br(), | ||
div(style="display: inline-block;vertical-align:top; width: 24%;", | ||
selectInput("dataset", "Numeric Analysis Type:", | ||
c('Genes', 'Numeric Metadata','PCs'))), | ||
div(style="display: inline-block;vertical-align:top; width: 24%;", | ||
selectInput("categorical", "Identity:", | ||
c(meta_cats))), | ||
div(style="display: inline-block;vertical-align:top; width: 24%;", | ||
selectInput("numeric", "Primary Numeric:", "")), | ||
|
||
div(style="display: inline-block;vertical-align:top; width: 24%;", | ||
selectInput('numeric2', 'Secondary Numeric', "")), | ||
|
||
mainPanel(width = 12, | ||
br(), | ||
br(), | ||
#h3(textOutput("caption")), | ||
plotOutput("MarkerGenePlot"), | ||
plotOutput("ViolinPlot"), | ||
plotOutput("CategoricalPlot") | ||
) | ||
), | ||
tabPanel("Single Marker", value=3, | ||
br(), | ||
div(style="display: inline-block;vertical-align:top; width: 24%;", | ||
selectInput("dataset_single", "Numeric Analysis Type:", | ||
c('Genes', 'Numeric Metadata','PCs'))), | ||
div(style="display: inline-block;vertical-align:top; width: 24%;", | ||
selectInput("categorical_single", "Identity:", | ||
c(meta_cats))), | ||
div(style="display: inline-block;vertical-align:top; width: 24%;", | ||
selectInput("numeric_single", "Primary Numeric:", "")), | ||
|
||
mainPanel(width = 12, | ||
br(), | ||
br(), | ||
#h3(textOutput("caption")), | ||
plotOutput("MarkerGenePlotSingle"), | ||
plotOutput("ViolinPlotSingle"), | ||
plotOutput("CategoricalPlotSingle") | ||
) | ||
), | ||
tabPanel("Marker Set (Grid)", value=4, | ||
br(), | ||
selectInput("categorical_b", "Identity:", | ||
c(agg_cats)), | ||
selectInput("numeric_b", "Primary Numeric:", "", multiple=TRUE), | ||
mainPanel(width = 12, | ||
br(), | ||
br(), | ||
plotOutput("MarkerSet") | ||
) | ||
), | ||
id = "tabselected" | ||
) | ||
), | ||
mainPanel(width = 12) | ||
) | ||
) | ||
|
||
|
||
shinyApp(ui, server) |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Starting a Shiny Server Instance from the Preconfigured Image | ||
|
||
### Keith Mitchell (kgmitchell@ucdavis.edu) | ||
*** | ||
#### A few general notes: | ||
- be sure Adam has granted you an IAM account on the UC Davis Bioinformatics AWS account. | ||
- Do not nuke the Zulip instances! | ||
*** | ||
#### How to prepare the instance for a client: | ||
1. Go to the AWS AMI's (Amazon Machine Images). Select the Rshiny Server Image. Go to Actions>Launch | ||
 | ||
2. Next Choose and Instance Type. This will vary in general based on the size of the data you are attempting to analyze. | ||
In general it is advised to start with a smaller instance and then move up from there if necessary. | ||
 | ||
3. Next Configure the Instance Details. The main step here is to set the "Auto-assign Public IP" to enable. | ||
 | ||
4. Keep clicking the bottom right button, "Next: Configure Security Group" until you get to "Step 6: Configure Security Group" | ||
5. At step 6, select the Rshiny App security group. | ||
 | ||
6. Finally launch the instance. (Bottom right hand quarter) | ||
 | ||
7. Select an existing key pair or create a new key pair is the final step for starting the instance. | ||
Choose "Create a new key pair" and give the key a useful name, here we will use "tutorial". | ||
 | ||
8. Move the downloaded key to `~/.ssh/` via `mv ~/Downloads/tutorial.pem ~/.ssh/` | ||
9. `chmod 700 ~/.ssh/tutorial.pem ` | ||
10. Get the connection to the instance seen highlighted below "ec2-…….amazonaws.com" | ||
 | ||
11. Run the following command to upload the "experiment_merged.Rdata" object to the app: | ||
- `scp -i ~/.ssh/tutorial.pem ec2-54-219-166-77.us-west-1.compute.amazonaws.com:/srv/shiny-server/scRNA_shiny_app/ ~/Desktop/experiment_merged.Rdata` | ||
13. Replace the green section with your Public IV4 DNS address from the instance that was created and used in the previous step. | ||
- http://**ec2-54-219-166-77.us-west-1.compute.amazonaws.com**:3838/scRNA_shiny_app/ | ||
14. If there are problems with this link do the following: | ||
- SSH into the server. | ||
- `ssh -i ~/.ssh/tutorial.key ec2-54-219-166-77.us-west-1.compute.amazonaws.com` | ||
- Restart the shiny service. | ||
- `sudo systemctl restart shiny-server.service` | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Todo: | ||
- readme documentation tab with the primers/library used | ||
- change the colors from (green and red) hack the Feature plot function seurat:::function | ||
- dont hard code the PCs only grab the first 10 | ||
|
||
# Done or not needed | ||
## newer | ||
- stretch out the 2nd plot | ||
- make the docs the first tab | ||
- layout all the way across the top | ||
- make NA an option for the second gene (binary button)(kinda done? just did a variation of this) | ||
|
||
|
||
|
||
## older | ||
- ensembl gene id's symbol if available | ||
- add an option for the PC graphs | ||
- marker set tab with the figure Blythe/Matt had seen | ||
- readme tab (MD) | ||
- make the side by side (secondary gene) optional | ||
- going along with this Matt wanted to change the layout.. I did put the violin plot in the middle | ||
- not sure i can group them around the side bar layout as wanted. | ||
|
||
|
||
# Not sure how to do it | ||
- make the default NA | ||
|
||
# Questions | ||
- is it ok to use experiment merged for everything (has more groupings) OK |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.