Skip to content

Commit

Permalink
version 1 - plotting test
Browse files Browse the repository at this point in the history
  • Loading branch information
Riley-Grindle committed Jul 17, 2024
1 parent 72f2a1e commit 3a3739c
Show file tree
Hide file tree
Showing 13 changed files with 385 additions and 107 deletions.
5 changes: 3 additions & 2 deletions Samples.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
id,data_directory,genes_2_rm,mito_genes
test,
id,data_directory,features_2_rm,mito_genes
samp_1,/Users/rgrindle/Desktop/mdibl/wd/scRNA-seq/test_pipe/Samp1,,test_mito.csv
samp_2,/Users/rgrindle/Desktop/mdibl/wd/scRNA-seq/test_pipe/Samp2,,test_mito.csv
67 changes: 59 additions & 8 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,65 @@

process {

publishDir = [
path: { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
withName: 'DISPLAY_REDUCTION' {
publishDir = [
path: { "${params.outdir}/Group_Analysis/${meta}/Dimensional_Reduction" },
mode: params.publish_dir_mode
]
ext.args = params.integration_method
}

withName: 'FIND_NN_CLUSTER' {
publishDir = [
path: { "${params.outdir}/Group_Analysis/${meta.group}/Nearest_Neighbor-Clusters" },
mode: params.publish_dir_mode
]
}

withName: 'INTEGRATION' {
publishDir = [
path: { "${params.outdir}/Group_Analysis/${meta}/Integration" },
mode: params.publish_dir_mode
]
}

withName: 'RUN_PCA' {
publishDir = [
path: { "${params.outdir}/Group_Analysis/${meta}/PCA" },
mode: params.publish_dir_mode
]
ext.args = params.pcMax
}

withName: 'MERGE_SO' {
publishDir = [
path: { "${params.outdir}/Group_Analysis/${meta}/Merge" },
mode: params.publish_dir_mode
]
ext.args2 = params.n_features_2_scale
ext.args3 = params.scale_method
}

withName: 'FIND_DOUBLETS' {
publishDir = [
path: { "${params.outdir}/Sample_Processing/${meta.id}/Doublet_Detection" },
mode: params.publish_dir_mode
]
}

withName: 'NORMALIZE_QC' {
publishDir = [
path: { "${params.outdir}/Sample_Processing/${meta.id}/Normalize_QC" },
mode: params.publish_dir_mode
]
}

withName: 'MAKE_SEURAT' {
publishDir = [
path: { "${params.outdir}/Sample_Processing/${meta.id}/Inital_SO" },
mode: params.publish_dir_mode
]
}

withName: SAMPLESHEET_CHECK {
publishDir = [
Expand All @@ -26,9 +80,6 @@ process {
]
}

withName: FASTQC {
ext.args = '--quiet'
}

withName: CUSTOM_DUMPSOFTWAREVERSIONS {
publishDir = [
Expand Down
17 changes: 7 additions & 10 deletions modules/local/doubletfinder.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process FIND_DOUBLETS {

tag "${meta.id}"
label 'process_medium'
label 'process_small'

conda "conda-forge::python=3.9.5"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
Expand All @@ -12,11 +12,12 @@ process FIND_DOUBLETS {
tuple val(meta), path (rds)
tuple val(meta), path (data_directory)
val vars_2_regress


output:
tuple val(meta), path ("*_DoubletsRemoved.rds"), emit: rds
path("*.validation.log"), emit: log
tuple val(meta), path ("*_DoubletsRemoved.rds"), emit: rds
tuple val(meta), path("*.validation.log"), emit: log
path("*.pdf")
//path ("versions.yml"), emit: versions

when:
Expand All @@ -30,12 +31,8 @@ process FIND_DOUBLETS {
$vars_2_regress \\
$data_directory \\
${meta.id} \\
${args}
${args}
//cat <<-END_VERSIONS > versions.yml
//"${task.process}":
//Seurat: \$(echo \$( version) | sed "s/, version //g" )
//END_VERSIONS
"""

stub:
Expand All @@ -46,4 +43,4 @@ process FIND_DOUBLETS {
END_VERSIONS
"""

}
}
32 changes: 17 additions & 15 deletions modules/local/find_NN_clusters.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process FIND_NN_CLUSTER {

tag "${meta.id}"
label 'process_medium'
tag "${meta.group}"
label 'process_small'

conda "conda-forge::python=3.9.5"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
Expand All @@ -10,35 +10,37 @@ process FIND_NN_CLUSTER {

input:
tuple val(meta), path (rds)
path validation_log
tuple val(meta), path (validation_log)
val resolutions
val integration_method
val integration_tool

output:
tuple val(meta), path ("*_Clustered.rds"), emit: rds
path("*validation.log"), emit: log
tuple val(meta), path("*validation.log"), emit: log
path("markers")
path("*.pdf")
//path ("versions.yml"), emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
if (meta.integrated) {
integration_method = integration_tool
} else {
integration_method = "NULL"
}
def args = task.ext.args ?: ''
"""
pcMax=\$(paste -s <(grep PC $validation_log| grep -E -o "[0-9]") | sed 's|\t||')
pcMax=\$(paste -s <(grep PC $validation_log| grep -E -o "[0-9]") | sed 's|\\t||')
FindNeighborsClustersMarkers.R \\
$rds\\
$resolutions \\
\$pcMax \\
$integration \\
${integration_method} \\
${meta.group} \\
${args}
//cat <<-END_VERSIONS > versions.yml
//"${task.process}":
//Seurat: \$(echo \$( version) | sed "s/, version //g" )
//END_VERSIONS
${args}
"""

stub:
Expand All @@ -49,4 +51,4 @@ process FIND_NN_CLUSTER {
END_VERSIONS
"""

}
}
18 changes: 7 additions & 11 deletions modules/local/integration.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process INTEGRATION {

tag "${meta.group}"
label 'process_medium'
tag "${meta}"
label 'process_small'

conda "conda-forge::python=3.9.5"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
Expand All @@ -11,10 +11,10 @@ process INTEGRATION {
input:
tuple val(meta), path (rds)
val integration_method

output:
tuple val(meta), path ("*_Integrated.rds"), emit: rds
path("*validation.log"), emit: log
tuple val(meta), path("*validation.log"), emit: log
//path ("versions.yml"), emit: versions

when:
Expand All @@ -26,13 +26,9 @@ process INTEGRATION {
Integration.R \\
$rds \\
$integration_method \\
${meta.group} \\
${args}
${meta} \\
${args}
//cat <<-END_VERSIONS > versions.yml
//"${task.process}":
//Seurat: \$(echo \$( version) | sed "s/, version //g" )
//END_VERSIONS
"""

stub:
Expand All @@ -43,4 +39,4 @@ process INTEGRATION {
END_VERSIONS
"""

}
}
10 changes: 6 additions & 4 deletions modules/local/makeseurat.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ process MAKE_SEURAT {
val gene_identifier

output:
tuple val(meta), path ("*_SO.rds"), emit: rds
path("*.validation.log"), emit: log
path ("versions.yml"), emit: versions
tuple val(meta), path ("*_SO.rds"), emit: rds
tuple val(meta), path("*_Validation.log"), emit: log
path ("versions.yml"), emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -34,11 +34,13 @@ process MAKE_SEURAT {
$gene_identifier \\
$genes_2_rm \\
${meta.id} \\
${meta.group} \\
"${meta.groups}" \\
$min_cells \\
$min_features \\
${args}
perl -i -pe 's/"//g;s/\\[\\d\\d?\\d?\\] //g' fileName.log *_Validation.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Seurat: \$(echo \$( version) | sed "s/, version //g" )
Expand Down
19 changes: 10 additions & 9 deletions modules/local/merge.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process MERGE_SO {

tag "${meta.group}"
label 'process_medium'
tag "${meta}"
label 'process_small'

conda "conda-forge::python=3.9.5"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
Expand All @@ -15,23 +15,24 @@ process MERGE_SO {
output:
tuple val(meta), path ("*Merged_SO.rds"), emit: rds
path("*validation.log"), emit: log
path("*.pdf")
//path ("versions.yml"), emit: versions

when:
task.ext.when == null || task.ext.when

script:
def n_features = task.ext.args2 ?: 'ALL'
def scale_method = task.ext.args3 ?: 'SCT'
def args = task.ext.args ?: ''
"""
Merge.R \\
${Meta.group} \\
${meta} \\
$vars_2_regress \\
${args}
$n_features \\
$scale_method \\
${args}
//cat <<-END_VERSIONS > versions.yml
//"${task.process}":
//Seurat: \$(echo \$( version) | sed "s/, version //g" )
//END_VERSIONS
"""

stub:
Expand All @@ -42,4 +43,4 @@ process MERGE_SO {
END_VERSIONS
"""

}
}
23 changes: 13 additions & 10 deletions modules/local/normalize_qc.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process NORMALIZE_QC {

tag "${meta.id}"
label 'process_medium'
label 'process_small'

conda "conda-forge::python=3.9.5"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
Expand All @@ -16,18 +16,21 @@ process NORMALIZE_QC {
val ncount_lower
val ncount_upper
val max_mito_pct


output:
tuple val(meta), path ("*_QC.rds"), emit: rds
path("*.validation.log"), emit: log
tuple val(meta), path ("*_QC.rds"), emit: rds
tuple val(meta), path("*.validation.log"), emit: log
//path ("versions.yml"), emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
if (mito_genes.getClass().name == "nextflow.util.BlankSeparatedList") {
mito_genes = 'NULL'
}
"""
Normalize_QC.R \\
$mito_genes \\
Expand All @@ -38,12 +41,12 @@ process NORMALIZE_QC {
$max_mito_pct \\
$rds \\
${meta.id} \\
${args}
${args}
//cat <<-END_VERSIONS > versions.yml
//"${task.process}":
//Seurat: \$(echo \$( version) | sed "s/, version //g" )
//END_VERSIONS
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Seurat: \$(echo \$( version) | sed "s/, version //g" )
END_VERSIONS
"""

stub:
Expand All @@ -54,4 +57,4 @@ process NORMALIZE_QC {
END_VERSIONS
"""

}
}
Loading

0 comments on commit 3a3739c

Please sign in to comment.