Skip to content

Commit 991aafe

Browse files
author
Panagiotis Papasaikas
committed
fix renku paths
1 parent 5844a9c commit 991aafe

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

DGNs/DGNs_Intro.pdf

193 KB
Binary file not shown.

DGNs/DGNs_exercise.Rmd

+14-21
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ library(reticulate)
3434
#reticulate::py_discover_config(required_module = "keras")
3535
3636
## For setup on a renku environment:
37-
#reticulate::use_virtualenv("/opt/conda")
37+
reticulate::use_virtualenv("/opt/conda")
3838
39-
## Only for xenon6 setup:
40-
#reticulate::use_virtualenv("/tungstenfs/groups/gbioinfo/sharedSoft/virtualenvs/r-reticulate-keras-2.3.0-tensorflow-2.0.0-gpu/") # Use TF2
41-
#reticulate::use_virtualenv("/tungstenfs/groups/gbioinfo/sharedSoft/virtualenvs/r-reticulate-keras-2.2.5-tensorflow-1.14.0-gpu") # Use TF1
42-
#Sys.setenv("CUDA_VISIBLE_DEVICES" = "3" )
4339
4440
reticulate::py_config()
4541
library(keras)
@@ -73,12 +69,13 @@ composition of the dataset:
7369

7470
```{r Download}
7571
## Download the data and set row names to gene symbols whenever possible
76-
sce <- readRDS(gzcon(url("https://github.com/fmicompbio/adv_scrnaseq_2020/blob/master/DGNs/data/SCE_MammaryGland.rds?raw=true")))
72+
#sce <- readRDS(gzcon(url("https://github.com/fmicompbio/adv_scrnaseq_2020/blob/master/DGNs/data/SCE_MammaryGland.rds?raw=true")))
73+
sce <- readRDS("/work/adv_scrnaseq_2020/data/dgn/SCE_MammaryGland.rds")
7774
#Subsample cells to speed up processing and, most importantly, later-on model training:
78-
set.seed(42)
79-
n=4000
75+
#set.seed(42)
76+
#n=4000
8077
#sce <- sce[, sample(1:ncol(sce), n ) ]
81-
## Dataset compostion per cell type and study:
78+
## Dataset composition per cell type and study:
8279
table(colData(sce)$study , colData(sce)$cell.class)
8380
```
8481

@@ -143,7 +140,7 @@ rm(M)
143140

144141
# Define the variational autoencoder model
145142

146-
![](figures/VAE_schematic.png){ width=40% }
143+
![](/work/adv_scrnaseq_2020/adv_scrnaseq_2020/DGNs/figures/VAE_schematic.png){ width=40% }
147144

148145
```{r}
149146
##### Sparse variational autoencoder model
@@ -329,7 +326,6 @@ early_stopping <- callback_early_stopping(monitor = "val_loss", min_delta = 0,
329326

330327
```{r eval=FALSE}
331328
##### Tensorboard callback (do not execute):
332-
#indir <- "/tungstenfs/groups/gbioinfo/papapana/DEEP_LEARNING/Autoencoders/BatchCor_paper/" # When running from xenon
333329
indir <- "/Users/papapana/Desktop/XENON/papapana/DEEP_LEARNING/Autoencoders/BatchCor_paper" # When running locally
334330
log_dir <- paste0(indir,"/logs/run_exercise_DGNs/")
335331
system(paste0 ("rm -rf ", log_dir, "/*") )
@@ -345,7 +341,7 @@ tnsrb <- callback_tensorboard( log_dir )
345341

346342
```{r eval=FALSE}
347343
nepochs=1000 #
348-
###### Fit the model using also our specified callbacks for scheduling and ealry stopping:
344+
###### Fit the model using also our specified callbacks for scheduling and early stopping:
349345
history <- vae %>% fit(
350346
x=sc_train_x,
351347
y=sc_train_x,
@@ -362,7 +358,7 @@ history <- vae %>% fit(
362358
```
363359

364360
```{r}
365-
history <- readRDS("data/MG_complete_VAE_history.rds")
361+
history <- readRDS("/work/adv_scrnaseq_2020/data/dgn/MG_complete_VAE_history.rds")
366362
plot(history)
367363
368364
```
@@ -389,11 +385,9 @@ We now have in our hands a trained VAE for our dataset. What is it good for?
389385

390386
```{r fig.width=7, fig.height=7}
391387
########################################################################################################
392-
vae %>% load_model_weights_hdf5("trained_models/MG_complete_VAE_weights.hdf5")
393-
#vae %>% load_model_weights_hdf5("data/dgn/MG_complete_VAE_weights.hdf5")
388+
vae %>% load_model_weights_hdf5("/work/adv_scrnaseq_2020/data/dgn/MG_complete_VAE_weights.hdf5")
394389
395-
palettes <- readRDS("data/distinct_palettes.rds")
396-
#palettes <- readRDS("data/dgn/distinct_palettes.rds")
390+
palettes <- readRDS("/work/adv_scrnaseq_2020/data/dgn/distinct_palettes.rds")
397391
398392
##### Run on the combined select dataset (train + validation):
399393
study_annot <- sce$study
@@ -498,7 +492,7 @@ legend("topright",legend = c("poisson","loess.fit"),lty=2,lwd=2,bty="n",col=c("d
498492
Here we will show a first example of using our learned latent space for inference. Specifically we will correct for batch-specific
499493
effects by decomposing the variance in the latent space:
500494

501-
![](figures/LatentArithm_BC.png){ width=50% }
495+
![](/work/adv_scrnaseq_2020/adv_scrnaseq_2020/DGNs/figures/LatentArithm_BC.png){ width=50% }
502496

503497
```{r fig.width=10, fig.height=7}
504498
########## Latent arithmetic operations to correct for batch :
@@ -573,12 +567,11 @@ Now we implement a second example of latent arithmetic-based inference. In this
573567
in one of the three studies (wal). Following the same rational of decomposing variance sources in latent space we will then predict the profile of the missing
574568
cell type in the target study:
575569

576-
![](figures/LatentArithm_OoS.png){ width=50% }
570+
![](/work/adv_scrnaseq_2020/adv_scrnaseq_2020/DGNs/figures/LatentArithm_OoS.png){ width=50% }
577571

578572
```{r fig.width=9, fig.height=3}
579573
#We will use a model that was trained on data that never saw wal luminal progenitor cells:
580-
#vae %>% load_model_weights_hdf5("data/dgn/MG_leavout_wallp_VAE_weights.hdf5")
581-
vae %>% load_model_weights_hdf5("trained_models/MG_leavout_wallp_VAE_weights.hdf5")
574+
vae %>% load_model_weights_hdf5("/work/adv_scrnaseq_2020/data/dgn/MG_leavout_wallp_VAE_weights.hdf5")
582575
latent_output <- predict(encoder, list(gene_input=sc_x))
583576
584577

DGNs/Keras_example.Rmd

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ suppressPackageStartupMessages({
7979
#reticulate::py_discover_config(required_module = "keras")
8080
8181
## For setup on a renku environment:
82-
#reticulate::use_virtualenv("/opt/conda")
82+
reticulate::use_virtualenv("/opt/conda")
8383
8484
reticulate::py_config()
8585
library(keras)
@@ -91,7 +91,7 @@ library(keras)
9191

9292

9393
## Preparing the data:
94-
![](figures/MNIST.png)
94+
![](/work/adv_scrnaseq_2020/adv_scrnaseq_2020/DGNs/figures/MNIST.png)
9595
```{r MLP}
9696
#loading the keras inbuilt mnist dataset
9797
data<-dataset_mnist()
@@ -136,7 +136,7 @@ layer_dense(units = 10,activation = 'softmax')
136136
summary(model)
137137
```
138138

139-
![](figures/MLP_model.png)
139+
![](/work/adv_scrnaseq_2020/adv_scrnaseq_2020/DGNs/figures/MLP_model.png)
140140

141141
## Compilation
142142
We are now going to compile the specified model. There are two required arguments that need to be specified

0 commit comments

Comments
 (0)