-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docs: add dev_w_docker.md and include dev_w_docker.md in the d…
…ocuments
- Loading branch information
Showing
2 changed files
with
58 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
To develop R scripts for single cell sequencing data, docker container can be used. In the docker container, development can be finished using jupyter-lab. | ||
|
||
If the goal is to develop an R script named `sc_singleR.prod.R`, we create two files: | ||
``` | ||
sc_seurat_opt.R | ||
sc_singleR.ipynb | ||
``` | ||
|
||
1. Record the script path: | ||
|
||
``` | ||
script_path = getwd() # %exclude_jupyterlab% | ||
script_path # %exclude_jupyterlab% | ||
``` | ||
|
||
2. Invoke `sc_singleR_opt.R` for command line options | ||
|
||
Inside the notebook, we use the cell below to utilize `sc_seurat_opt.R` to read the command line options and save the information in an RDS file named `opt.rds`. | ||
|
||
``` | ||
system(paste0('Rscript ', script_path, # %exclude_jupyterlab% | ||
'/sc_singleR_opt.R --genome="hg38" --markerList="/Volumes/ccrsf-ifx/Software/scripts/bin/currentsnake/single_cell/gene_lists/human_gene_list.csv" --outdir="/Volumes/ccrsf-static/Analysis/xies4/github_repos/pipeline_dev_test/singleR" --rds="/Volumes/ccrsf-static/Analysis/xies4/github_repos/pipeline_dev_test/test_dir/seur_10x_cluster_object.rds"'), # %exclude_jupyterlab% | ||
intern = T) # %exclude_jupyterlab% | ||
``` | ||
|
||
3. Write the main code | ||
|
||
First, read the options using readRDS: | ||
|
||
``` | ||
opt = readRDS("/Volumes/ccrsf-static/Analysis/xies4/github_repos/pipeline_dev_test/singleR/opt.rds") # %exclude_jupyterlab% | ||
``` | ||
|
||
Then include the code to accomplish the task. | ||
|
||
4. Generate production script: `sc_singleR.prod.R` | ||
|
||
The code below will first convert the `ipynb` file to a script file and combine the script for option `sc_singleR_opt.R` and `sc_singleR.r` (output file of `jupyter nbconvert -`) with exclusion of the lines with "exclude_jupyterlab". | ||
|
||
``` | ||
notebook_prefix = "sc_singleR" # %exclude_jupyterlab% | ||
notebook_name = paste0(notebook_prefix, ".ipynb") # %exclude_jupyterlab% | ||
notebook_r = paste0(script_path, "/", paste0(notebook_prefix, ".r")) # %exclude_jupyterlab% | ||
notebook_path = paste0(script_path, "/", notebook_name) # %exclude_jupyterlab% | ||
opt_name = paste0(script_path, "/", sub(".ipynb", "_opt.R", notebook_name)) # %exclude_jupyterlab% | ||
output = paste0(script_path, "/", sub(".ipynb", ".prod.R", notebook_name)) # %exclude_jupyterlab% | ||
cmd1 = paste0("jupyter nbconvert --to script --output ", # %exclude_jupyterlab% | ||
notebook_prefix, ' ', notebook_path, "> /dev/null 2>&1 ") # %exclude_jupyterlab% | ||
cmd1 # %exclude_jupyterlab% | ||
system(cmd1, intern = TRUE) # %exclude_jupyterlab% | ||
cmd2 = paste0('cat ', opt_name, ' ', notebook_r, # %exclude_jupyterlab% | ||
' |grep -v exclude_jupyterlab > ', output, ' 2>&1') # %exclude_jupyterlab% | ||
cmd2 # %exclude_jupyterlab% | ||
system(cmd2, intern = T) # %exclude_jupyterlab% | ||
system(paste0("rm ", notebook_r)) # %exclude_jupyterlab% | ||
``` | ||
|
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