Skip to content

Commit 8b895f5

Browse files
committed
Minor fixes/cleanup
1 parent 8f4b003 commit 8b895f5

10 files changed

+94
-213
lines changed

code/2-umap.py

-8
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@
100100
print(f"\n Number of markers used: {len(all_together_vs_marks.columns)}")
101101

102102

103-
#~~~~~~~~~~~~~~~~~~~Optional: z-score transformation~~~~~~~~~~~~~~~~~~~~~~~~~~#
104-
# Z-SCORE: Not used now, interactive inplementation on later stages of the pipeline
105-
# z-score transformation (for the Organoid Methods Paper, only applied to supplementary figure 1)
106-
# all_together_vs_marks.head()
107-
# all_together_vs_marks = all_together_vs_marks.apply(zscore)
108-
# all_together_vs_marks.head()
109-
110-
111103
#~~~~~~~~~~~~~~~~~~~~~~~~~~Perform and save UMAP~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
112104
#Define UMAP parameters
113105

code/5v2-pca.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#~Heatmaps~#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
2+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#~PCA~#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
33
###############################################################################
44
#Calculate and plot PCAs on EMD and DREMI scores
55
import os
@@ -8,11 +8,9 @@
88

99
from aux.aux_functions import yes_or_NO
1010

11-
#2 options for the PCA plots:
12-
#Either run basic PCA on R and plot in shiny app (less graphical customisation, simpler plots)
13-
#Leverage PCA shiny apps.
14-
#PCAshiny from Factoshiny -> Very basic
15-
#Interactive PCA Explorer
11+
#Import yes or no question to choose the different plotings
12+
#Run the separate R shiny apps accordingly
13+
#Simultaneous emd and DREMI should both be possible since the ports are random
1614

1715
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I/O~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
1816
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

code/aux/aux4_dremi.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import scprep
99

1010

11+
# EXPERIMENTAL #
1112
# find outliers for both marker_x and marker_y based on cufoffs of standard deviations
1213
# return the number of outliers and a dataframe after outlier removal
1314
# update the df_info_dict with the number of outliers

code/aux/aux5v1_dremi.R

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ if(length(new.packages)) install.packages(new.packages, repos = "http://cran.us.
1313
#Load packages
1414
lapply(list.of.packages, require, character.only = TRUE)
1515

16+
#FUTURE WORK: Look into ComplexHeatmap (group similar DREMI patterns)
1617

1718
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~DATA SETUP~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
18-
#Make sure no_norm is like this and marker_marker, not marker-marker -> check dremi script for populatiog the column itself, although i don't think that will pose a problem here in R
19+
#Make sure no_norm is like this and marker_marker, not marker-marker ->
20+
#check dremi script for populatiog the column itself, although i don't think that will pose a problem here in R
1921
dremi_info <- read_tsv(args)
2022
minx <- min(dremi_info$with_outliers_arcsinh_DREMI_score)
2123
maxx <- max(dremi_info$with_outliers_arcsinh_DREMI_score)
@@ -33,7 +35,7 @@ initial_dremi <- dremi_info %>% ggplot(aes(
3335
###############################################################################
3436
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#~UI~#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
3537
###############################################################################
36-
# Define UI for application that draws a histogram
38+
3739
ui <- fluidPage(
3840

3941
# Application title
@@ -59,12 +61,12 @@ ui <- fluidPage(
5961
###############################################################################
6062
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#~Server~#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
6163
###############################################################################
62-
# Define server logic required to draw a histogram
64+
6365
server <- function(input, output, session) {
6466

6567
output$out6 <- renderPrint(input$in6)
6668

67-
output$trendPlot <- renderPlotly({
69+
output$trendPlot <- renderPlotly({ #Process input data and make plotly heatmap
6870
if (!is.null(input$in6) & !is.null(input$in12)) {
6971
data_to_plot <- dremi_info %>% filter(str_detect(marker_x_marker_y, input$in6)) %>% filter(file_origin %in% input$in12)
7072
data_to_plot$file_origin <- as.factor(data_to_plot$file_origin) %>% fct_relevel(input$in12)
@@ -95,7 +97,7 @@ server <- function(input, output, session) {
9597
) %>% layout(height = 800) # %>% layout(height = 1400, width = 1200)
9698
)
9799
})
98-
output$foo <- downloadHandler(
100+
output$foo <- downloadHandler( #Download plotly heatmap
99101
filename = "dremi_heatmap.pdf",
100102
content = function(file_origin) {
101103
if (!is.null(input$in6) & !is.null(input$in12)) {

code/aux/aux5v1_emd.R

+7-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ print(minx, maxx)
2727
###############################################################################
2828
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#~UI~#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
2929
###############################################################################
30-
# Define UI for application that draws a histogram
30+
3131
ui <- fluidPage(
3232

3333
# Application title
@@ -61,12 +61,12 @@ ui <- fluidPage(
6161
###############################################################################
6262
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#~Server~#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
6363
###############################################################################
64-
# Define server logic required to draw a histogram
64+
6565
server <- function(input, output, session) {
6666

6767
output$out6 <- renderPrint(input$in6)
6868

69-
output$trendPlot <- renderPlotly({
69+
output$trendPlot <- renderPlotly({ #Process input data and make plotly heatmap
7070
if (!is.null(input$in6) & !is.null(input$in12)) {
7171
data_to_plot <- emd_info %>% filter(marker %in% input$in6) %>% filter(file_origin %in% input$in12)
7272
data_to_plot$file_origin <- as.factor(data_to_plot$file_origin) %>% fct_relevel(input$in12)
@@ -79,7 +79,6 @@ server <- function(input, output, session) {
7979
data_to_plot$file_origin <- as.factor(data_to_plot$file_origin) %>% fct_relevel(input$in12)
8080
}
8181
else{data_to_plot <- emd_info}
82-
# saveRDS(data_to_plot, "testdata.RDS")
8382
initial_emd <- data_to_plot %>% ggplot(aes(x=file_origin, y=fct_rev(marker))) + geom_tile(aes(fill=EMD_no_norm_arc))
8483
print(
8584
ggplotly(initial_emd + scale_fill_distiller(
@@ -94,7 +93,7 @@ server <- function(input, output, session) {
9493
ggtitle("EMD scores heatmap")
9594
) %>% layout(height = 700, width = 700))
9695
})
97-
output$complexheatmap <- renderPlot({ ###TESTING ADDITION OF COMPLEXHEATMAP###
96+
output$complexheatmap <- renderPlot({ #Process input data and make ComplexHeatmap
9897
if (!is.null(input$in6) & !is.null(input$in12)) {
9998
data_to_plot <- emd_info %>% filter(marker %in% input$in6) %>% filter(file_origin %in% input$in12)
10099
data_to_plot$file_origin <- as.factor(data_to_plot$file_origin) %>% fct_relevel(input$in12)
@@ -114,7 +113,7 @@ server <- function(input, output, session) {
114113
Heatmap(t(df_mat), name="EMD scores", column_title="Conditions",row_title="Markers",column_names_rot=60)
115114
}, width=600, height=800)
116115

117-
output$foo <- downloadHandler(
116+
output$foo <- downloadHandler( #Download plotly heatmap
118117
filename = "emd_heatmap.pdf",
119118
content = function(file) {
120119
if (!is.null(input$in6) & !is.null(input$in12)) {
@@ -145,7 +144,7 @@ server <- function(input, output, session) {
145144
, device = "pdf")
146145
}
147146
)
148-
output$complex <- downloadHandler(
147+
output$complex <- downloadHandler( #Download ComplexHeatmap
149148
filename = "emd_complexheatmap.pdf",
150149
content = function(file) {
151150
if (!is.null(input$in6) & !is.null(input$in12)) {
@@ -179,6 +178,6 @@ if (getOption("browser") == "") {
179178
options(browser="xdg-open")
180179
print("R encountered an error when identifying your default browser.")
181180
print("Please manually open in your browser the addres indicated below.")
182-
} #The block below solves the utils::browseURL(appUrl) ERROR present in certain conda/WSL installs
181+
} #The block above solves the utils::browseURL(appUrl) ERROR present in certain conda/WSL installs
183182

184183
shinyApp(ui = ui, server = server) #, options = list(launch.browser=TRUE))

0 commit comments

Comments
 (0)