Skip to content
Snippets Groups Projects
Commit 08921a48 authored by Gervaise Henry's avatar Gervaise Henry :cowboy:
Browse files

Fix output for plotViolinBox

parent 44fb3b36
1 merge request!1Resolve "Fix outputs to GUDMAP/RBK standards"
profiles {
standard {
includeConfig 'conf/biohpc_local.config'
includeConfig 'conf/biohpc.config'
}
}
......@@ -32,15 +32,21 @@ chunk <- read.csv(opt$c,header=FALSE)
exp <- exp[exp$genes %in% chunk$V1,]
#Create output folders
if (!dir.exists(paste0("./",opt$g))){
dir.create(paste0("./",opt$g))
if (!dir.exists("./ViolinBox")){
dir.create("./ViolinBox",opt$g)
}
if (!dir.exists(paste0("./ViolinBox/",opt$g))){
dir.create(paste0("./ViolinBox/",opt$g))
}
if (!dir.exists(paste0("./ViolinBox/",opt$g,"/genes"))){
dir.create(paste0("./ViolinBox/",opt$g,"/genes"))
}
#Plot
for (i in chunk$V1){
id.exp <- id
id.exp$Expression <- as.numeric(exp[which(exp$genes==i),])[-ncol(exp)]
png(paste0("./",opt$g,"/",i,".png"),width=1000,height=500,bg="white")
png(paste0("./ViolinBox/",opt$g,"/genes/",i,"_1.png"),width=1000,height=500,bg="white")
plot(ggplot(id.exp,aes_string(x=opt$g,y="Expression",fill=opt$g))+geom_violin(scale="width",trim=TRUE)+labs(y="Expression")+geom_boxplot(width=0.25,fill="white",outlier.shape=NA)+theme_cowplot())
dev.off()
rm(id.exp)
......
......@@ -203,7 +203,7 @@ process plotFeature {
* plotViolinBox: plot violin/box plots in gene chunks
*/
process plotViolinBox {
publishDir "${outDir}/png/ViolinBox", mode: 'move', overwrite: true
publishDir "${outDir}", mode: 'move', overwrite: true
input:
file matrix_plotViolinBox
......
#!/usr/bin/env nextflow
// Define input variables
params.rda = "${baseDir}/../test_data/sc10x.rda"
params.seurat = "sc10x"
params.tsne = true
params.umap = true
params.assay = "RNA"
params.slot = "scale.data"
params.scale = true
params.sample = 100
params.groups = "${baseDir}/../test_data/groups.txt"
params.convert = "GRCh38p5"
params.studyIID = "studyIID"
params.applicationName = "applicationName"
params.outDir = "${baseDir}/../output"
// Parse input variables
rda = Channel.fromPath(params.rda)
rda.into {
rda_createMatrix
rda_createGroup
}
seurat_createMatrix = params.seurat
seurat_createGroup = params.seurat
tsne_createMatrix = params.tsne
tsne_plotIdentGroup = params.tsne
tsne_plotFeature = params.tsne
umap_createMatrix = params.umap
umap_plotIdentGroup = params.umap
umap_plotFeature = params.umap
assay = params.assay
slot = params.slot
scale = params.scale
sample = params.sample
groups_createGroup = file(params.groups).readLines()
groups_plotIdentGroup = file(params.groups).readLines()
groups_plotViolinPlot = file(params.groups)
convert = params.convert
outDir = "${params.outDir}/deriva/Seq/${params.studyIID}/application_files/${params.applicationName}"
logsDir = "${params.outDir}/Logs"
/*
* createMatrix: extract cell/gene matrix from Seurat object
*/
process createMatrix {
tag "${seurat_createMatrix}"
input:
file rda_createMatrix
val seurat_createMatrix
val tsne_createMatrix
val umap_createMatrix
val assay
val slot
val scale
val sample
output:
file("matrix/*") into matrixRaw
file("cells.csv") into cells
script:
"""
hostname
ulimit -a
module load seurat/3.0.0
seurat-Rscript ${baseDir}/scripts/createMatrix.R --r ${rda_createMatrix} --o ${seurat_createMatrix} --t ${tsne_createMatrix} --u ${umap_createMatrix} --a ${assay} --s ${slot} --l ${scale} --p ${sample}
"""
}
/*
* createGroup: extract ident groups from Seurat object
*/
process createGroup {
tag "${group_createGroup}"
input:
file rda_createGroup
val seurat_createGroup
each group_createGroup from groups_createGroup
file cells
output:
file("*") into id
script:
"""
hostname
ulimit -a
module load seurat/3.0.0
seurat-Rscript ${baseDir}/scripts/createGroup.R --r ${rda_createGroup} --o ${seurat_createGroup} --g ${group_createGroup}
"""
}
//Duplicate group IDs
id.into {
id_plotIdentGroup
id_plotViolinBox
}
/*
* renameGenes: convert gene symbols to NCBI ID's for GUDMAP/RBK
*/
process renameGenes {
tag "NCBI"
input:
file matrixRaw
val convert
output:
file("*") into matrixFinal
file("genes.csv") into genes
script:
if (convert == "NO"){
"""
hostname
ulimit -a
cp -R ./raw/*.mtx .
cp -R ./raw/*.csv .
"""
} else {
"""
hostname
ulimit -a
cp -R ./raw/*.csv .
module load seurat/3.0.0
seurat-Rscript ${baseDir}/scripts/renameGenes.R --g ${convert}
"""
}
}
// Duplicate matrix files
matrixFinal.into {
matrix_plotIdentGroup
matrix_plotFeature
matrix_plotViolinBox
}
/*
* plotIdentGroup: plot identity groups in reduced dimensions
*/
process plotIdentGroup {
tag "${group_plotIdentGroup}"
publishDir "${outDir}", mode: 'move', overwrite: true
input:
file matrix_plotIdentGroup
file("*") from id_plotIdentGroup.collect()
each group_plotIdentGroup from groups_plotIdentGroup
val tsne_plotIdentGroup
val umap_plotIdentGroup
output:
file("**/*.png") into plotsIdentGroup
script:
"""
hostname
ulimit -a
module load seurat/3.0.0
seurat-Rscript ${baseDir}/scripts/plotIdentGroup.R --g ${group_plotIdentGroup} --t ${tsne_plotIdentGroup} --u ${umap_plotIdentGroup}
"""
}
// Split genes into chunks
genes.splitText(by: 1000).into {
genesChunks_plotFeature
genesChunks_plotViolinBox
}
/*
* plotFeature: plot feature plots in gene chunks
*/
process plotFeature {
publishDir "${outDir}", mode: 'move', overwrite: true
input:
file matrix_plotFeature
each file(chunk) from genesChunks_plotFeature
val tsne_plotFeature
val umap_plotFeature
output:
file("**/*.png") into plotsFeature
script:
"""
hostname
ulimit -a
module load seurat/3.0.0
seurat-Rscript ${baseDir}/scripts/plotFeature.R --t ${tsne_plotFeature} --u ${umap_plotFeature} --c ${chunk}
"""
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment