Skip to content

Commit

Permalink
Cleaned up workflow bits
Browse files Browse the repository at this point in the history
  • Loading branch information
msauria committed Jun 10, 2024
1 parent 9db37fa commit 6a9908b
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 211 deletions.
5 changes: 3 additions & 2 deletions bin/pipeline.plotting.mod.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ for.plot <- combined.mappings %>%
if(!("MtDNA" %in% mito_check$CHROM)) dplyr::filter(., CHROM != "MtDNA") else .
}

BF <- combined.mappings %>%
BF <- for.plot %>%
dplyr::group_by(trait) %>%
dplyr::filter(log10p != 0) %>%
dplyr::distinct(marker, log10p) %>%
Expand Down Expand Up @@ -160,7 +160,8 @@ man.plot <- ggplot() +
facet_grid(. ~ CHROM, scales = "free_x", space = facet_scales) +
ggtitle(BF.frame$trait)

ggsave(man.plot, filename = paste0(BF.frame$trait,"_manhattan_", args[3], ".plot.png"), width = 8, height = 4)

ggsave(man.plot, filename = paste0(BF.frame$trait,"_manhattan_", args[3], ".plot.png"), width = 8, height = 4)


## SWEPTNESS & EFFECTS SUMMARY ##
Expand Down
1 change: 1 addition & 0 deletions conf/rockfish.config
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ singularity {
autoMounts = true
cacheDir = "${params.baseDir}/singularity"
pullTimeout = '20 min'
envWhitelist = "SLURMD_HOSTNAME,SLURM_JOB_NODELIST,SLURM_NODELIST,SLURM_STEP_NODELIST,SLURM_TOPOLOGY_ADDR"
}
3 changes: 1 addition & 2 deletions env/conda.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: nemascan
name: base
channels:
- defaults
- bioconda
- r
- biobuilds
- conda-forge
dependencies:
- bcftools=1.9
- pandoc=2.12
- plink=1.90b6.12
- bedtools=2.29.2
Expand Down
14 changes: 7 additions & 7 deletions input_data/all_species/rename_chromosomes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
I 1
II 2
III 3
IV 4
V 5
X 6
MtDNA 7
I 1
II 2
III 3
IV 4
V 5
X 6
MtDNA 7
32 changes: 16 additions & 16 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ if (params.matrix || params.mapping){

if (params.help) {
log.info '''
O~~~ O~~ O~~ ~~
O~~~ O~~ O~ O~~
O~ O~~ O~~ O~~ O~~
O~~ O~~ O~~ O~~ O~~~ O~~ O~~ O~~ O~~ O~~~ O~~ O~~ O~~
O~~ O~~ O~~ O~ O~~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~ O~~ O~~~~~ O~~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~ ~~ O~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~~ O~~~~ O~~~ O~ O~~ O~~ O~~~ O~~ ~~ O~~~ O~~ O~~~ O~~~ O~~
O~~ O~~ O~~ O~~ O~~~ O~~ O~~ O~~ O~~ O~~~ O~~ O~~ O~~
O~~ O~~ O~~ O~ O~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~ O~~ O~~~~~ O~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~O~~ O~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~~ O~~~~ O~~~ O~ O~~ O~~ O~~~ O~ O~~ O~~~ O~~ O~~~ O~~~ O~~
'''
log.info "----------------------------------------------------------------"
log.info " USAGE "
Expand Down Expand Up @@ -246,13 +246,13 @@ O~~ O~~ O~~~~ O~~~ O~ O~~ O~~ O~~~ O~~ ~~ O~~~ O~~ O~~~ O
exit 1
} else {
log.info '''
O~~~ O~~ O~~ ~~
O~~~ O~~ O~ O~~
O~ O~~ O~~ O~~ O~~
O~~ O~~ O~~ O~~ O~~~ O~~ O~~ O~~ O~~ O~~~ O~~ O~~ O~~
O~~ O~~ O~~ O~ O~~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~ O~~ O~~~~~ O~~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~ ~~ O~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~~ O~~~~ O~~~ O~ O~~ O~~ O~~~ O~~ ~~ O~~~ O~~ O~~~ O~~~ O~~
O~~ O~~ O~~ O~~ O~~~ O~~ O~~ O~~ O~~ O~~~ O~~ O~~ O~~
O~~ O~~ O~~ O~ O~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~ O~~ O~~~~~ O~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~O~~ O~ O~~ O~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~ O~~ O~~~~ O~~~ O~ O~~ O~~ O~~~ O~ O~~ O~~~ O~~ O~~~ O~~~ O~~
'''
log.info ""
log.info "Trait File = ${params.traitfile}"
Expand Down Expand Up @@ -500,7 +500,7 @@ workflow {
.join(gcta_fine_maps.out.finemap_html_inbred, remainder: true) // fine mapping data
.join(gcta_fine_maps.out.finemap_html_loco, remainder: true)
.join(prep_ld_files.out.finemap_LD_inbred, remainder: true)
.join(prep_ld_files.out.finemap_LD_loco, remainder: true) | html_report_main
.join(prep_ld_files.out.finemap_LD_loco, remainder: true).view { "$it" } | html_report_main
}
} else {
// generate main html report
Expand Down Expand Up @@ -548,14 +548,15 @@ workflow {
if(simulation) {

// for simulations
Channel.fromPath("${params.data_dir}/${params.simulate_strains}").collect { it.tokenize( ' ' ) }
Channel.fromPath("${params.data_dir}/${params.simulate_strains}")
.splitCsv(sep:" ")
.map { SM, STRAINS -> [SM, STRAINS] }
.combine(vcf_file.combine(vcf_index))
.combine(Channel.fromPath("${params.data_dir}/all_species/rename_chromosomes"))
.combine(Channel.fromPath("${params.data_dir}/${params.simulate_maf}").splitCsv()) | prepare_simulation_files

// eigen
contigs = Channel.from(["1", "2", "3", "4", "5", "6"])
contigs = Channel.from([1, 2, 3, 4, 5, 6])
contigs.combine(prepare_simulation_files.out.sim_geno)
.combine(Channel.fromPath("${params.bin_dir}/Get_GenoMatrix_Eigen.R")) | chrom_eigen_variants_sims

Expand Down Expand Up @@ -645,7 +646,6 @@ workflow.onComplete {
Mapping = ${params.mapping}
Simulation = ${params.simulate}
Simulate QTL effects = ${params.simulate_qtlloc}
Annotation = ${params.annotate}
Result Directory = ${params.out}
"""

Expand Down
160 changes: 62 additions & 98 deletions modules/mapping.nf
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,31 @@ process gcta_grm {
label "lg"

input:
tuple val(TRAIT), file(traits), file(bed), file(bim), file(fam), file(map), file(nosex), file(ped), file(log)
tuple val(TRAIT), file(traits), file(bed), file(bim), file(fam), file(map), file(nosex), \
file(ped), file(log), val(algorithm)

output:
tuple val(TRAIT), file(traits), file(bed), file(bim), file(fam), file(map), file(nosex), \
file(ped), file(log), file("${TRAIT}_gcta_grm.grm.bin"), file("${TRAIT}_gcta_grm.grm.id"), \
file("${TRAIT}_gcta_grm.grm.N.bin"), file("${TRAIT}_gcta_grm_inbred.grm.bin"), file("${TRAIT}_gcta_grm_inbred.grm.id")
file(ped), file(log), file("${TRAIT}_gcta_grm_${algorithm}.grm.bin"), \
file("${TRAIT}_gcta_grm_${algorithm}.grm.id"), \
file("${TRAIT}_gcta_grm_${algorithm}.grm.N.bin"), val(algorithm)

when:
params.maps
params.mapping

"""
if [[ ${algorithm} == "inbred" ]];
then
option="--make-grm-inbred"
else
options="--make-grm"
fi
gcta64 --bfile ${TRAIT} \\
--autosome \\
--maf ${params.maf} \\
--make-grm \\
--out ${TRAIT}_gcta_grm \\
--thread-num 5
gcta64 --bfile ${TRAIT} \\
--autosome \\
--maf ${params.maf} \\
--make-grm-inbred \\
--out ${TRAIT}_gcta_grm_inbred \\
\${option} \\
--out ${TRAIT}_gcta_grm_${algorithm} \\
--thread-num 5
"""
}
Expand All @@ -89,63 +92,44 @@ process gcta_lmm_exact_mapping {

label "lg"

publishDir "${params.out}/INBRED/Mapping/Raw", pattern: "*pca.fastGWA", overwrite: true
publishDir "${params.out}/LOCO/Mapping/Raw", pattern: "*pca.loco.mlma", overwrite: true
publishDir "${params.out}/INBRED/Mapping/Raw", pattern: "*inbred_pca.fastGWA", overwrite: true
publishDir "${params.out}/LOCO/Mapping/Raw", pattern: "*loco_pca.mlma", overwrite: true

input:
tuple val(TRAIT), file(traits), file(bed), file(bim), file(fam), file(map), \
file(nosex), file(ped), file(log), file(grm_bin), file(grm_id), file(grm_nbin), \
file(grm_bin_inbred), file(grm_id_inbred)
file(nosex), file(ped), file(log), file(grm_bin), file(grm_id), file(grm_nbin),
val(algorithm)

output:
tuple val(TRAIT), file("${TRAIT}_lmm-exact_inbred_pca.fastGWA"), file("${TRAIT}_lmm-exact_pca.loco.mlma")
tuple val(TRAIT), file("${TRAIT}_lmm-exact_${algorithm}_pca.*", arity=1)


"""
gcta64 --grm ${TRAIT}_gcta_grm \\
--make-bK-sparse ${params.sparse_cut} \\
--out ${TRAIT}_sparse_grm \\
--thread-num ${task.cpus}
gcta64 --grm ${TRAIT}_gcta_grm \\
--pca 1 \\
--out ${TRAIT}_sparse_grm \\
--thread-num ${task.cpus}
gcta64 --mlma-loco \\
--grm ${TRAIT}_sparse_grm \\
--bfile ${TRAIT} \\
--out ${TRAIT}_lmm-exact \\
--pheno ${traits} \\
--maf ${params.maf} \\
--thread-num ${task.cpus}
gcta64 --mlma-loco \\
--grm ${TRAIT}_sparse_grm \\
--bfile ${TRAIT} \\
--qcovar ${TRAIT}_sparse_grm.eigenvec \\
--out ${TRAIT}_lmm-exact_pca \\
--pheno ${traits} \\
--maf ${params.maf} \\
--thread-num ${task.cpus}
gcta64 --grm ${TRAIT}_gcta_grm_inbred \\
if [[ ${algorithm} == "inbred" ]];
then
options="--fastqGWA-lmm-exact --grm-sparse"
else
options="--mlma-loco --grm"
fi
gcta64 --grm ${TRAIT}_gcta_grm_${algorithm} \\
--make-bK-sparse ${params.sparse_cut} \\
--out ${TRAIT}_sparse_grm_inbred \\
--out ${TRAIT}_sparse_grm_${algorithm} \\
--thread-num ${task.cpus}
gcta64 --grm ${TRAIT}_gcta_grm_inbred \\
gcta64 --grm ${TRAIT}_gcta_grm_${algorithm} \\
--pca 1 \\
--out ${TRAIT}_sparse_grm_inbred \\
--out ${TRAIT}_sparse_grm_${algorithm} \\
--thread-num ${task.cpus}
gcta64 --fastGWA-lmm-exact \\
--grm-sparse ${TRAIT}_sparse_grm \\
gcta64 \${options} ${TRAIT}_sparse_grm \\
--bfile ${TRAIT} \\
--out ${TRAIT}_lmm-exact_inbred \\
--out ${TRAIT}_lmm-exact_${algorithm} \\
--pheno ${traits} \\
--maf ${params.maf} \\
--thread-num ${task.cpus}
gcta64 --fastGWA-lmm-exact \\
--grm-sparse ${TRAIT}_sparse_grm \\
gcta64 \${options} ${TRAIT}_sparse_grm \\
--bfile ${TRAIT} \\
--qcovar ${TRAIT}_sparse_grm_inbred.eigenvec \\
--out ${TRAIT}_lmm-exact_inbred_pca \\
--qcovar ${TRAIT}_sparse_grm_${algorithm}.eigenvec \\
--out ${TRAIT}_lmm-exact_${algorithm}_pca \\
--pheno ${traits} \\
--maf ${params.maf} \\
--thread-num ${task.cpus}
Expand All @@ -163,57 +147,38 @@ process gcta_lmm_exact_mapping_nopca {
input:
tuple val(TRAIT), file(traits), file(bed), file(bim), file(fam), file(map), \
file(nosex), file(ped), file(log), file(grm_bin), file(grm_id), file(grm_nbin), \
file(grm_bin_inbred), file(grm_id_inbred)
val(algorithm)

output:
tuple val(TRAIT), file("${TRAIT}_lmm-exact_inbred.fastGWA"), file("${TRAIT}_lmm-exact.loco.mlma")
tuple val(TRAIT), file("${TRAIT}_lmm-exact_${algorithm}.*", arity=1)


"""
gcta64 --grm ${TRAIT}_gcta_grm \\
if [[ ${algorithm} == "inbred" ]];
then
options="--fastqGWA-lmm-exact --grm-sparse"
else
options="--mlma-loco --grm"
fi
gcta64 --grm ${TRAIT}_gcta_grm_${algorithm} \\
--make-bK-sparse ${params.sparse_cut} \\
--out ${TRAIT}_sparse_grm \\
--out ${TRAIT}_sparse_grm_${algorithm} \\
--thread-num ${task.cpus}
gcta64 --grm ${TRAIT}_gcta_grm \\
gcta64 --grm ${TRAIT}_gcta_grm_${algorithm} \\
--pca 1 \\
--out ${TRAIT}_sparse_grm \\
--out ${TRAIT}_sparse_grm_${algorithm} \\
--thread-num ${task.cpus}
gcta64 --mlma-loco \\
--grm ${TRAIT}_sparse_grm \\
gcta64 \${options} ${TRAIT}_sparse_grm \\
--bfile ${TRAIT} \\
--out ${TRAIT}_lmm-exact \\
--out ${TRAIT}_lmm-exact_${algorithm} \\
--pheno ${traits} \\
--maf ${params.maf} \\
--thread-num ${task.cpus}
gcta64 --mlma-loco \\
--grm ${TRAIT}_sparse_grm \\
gcta64 \${options} ${TRAIT}_sparse_grm \\
--bfile ${TRAIT} \\
--qcovar ${TRAIT}_sparse_grm.eigenvec \\
--out ${TRAIT}_lmm-exact_pca \\
--pheno ${traits} \\
--maf ${params.maf} \\
--thread-num ${task.cpus}
gcta64 --grm ${TRAIT}_gcta_grm_inbred \\
--make-bK-sparse ${params.sparse_cut} \\
--out ${TRAIT}_sparse_grm_inbred \\
--thread-num ${task.cpus}
gcta64 --grm ${TRAIT}_gcta_grm_inbred \\
--pca 1 \\
--out ${TRAIT}_sparse_grm_inbred \\
--thread-num ${task.cpus}
gcta64 --fastGWA-lmm-exact \\
--grm-sparse ${TRAIT}_sparse_grm \\
--bfile ${TRAIT} \\
--out ${TRAIT}_lmm-exact_inbred \\
--pheno ${traits} \\
--maf ${params.maf} \\
--thread-num ${task.cpus}
gcta64 --fastGWA-lmm-exact \\
--grm-sparse ${TRAIT}_sparse_grm \\
--bfile ${TRAIT} \\
--qcovar ${TRAIT}_sparse_grm_inbred.eigenvec \\
--out ${TRAIT}_lmm-exact_inbred_pca \\
--qcovar ${TRAIT}_sparse_grm_${algorithm}.eigenvec \\
--out ${TRAIT}_lmm-exact_${algorithm}_pca \\
--pheno ${traits} \\
--maf ${params.maf} \\
--thread-num ${task.cpus}
Expand All @@ -230,19 +195,18 @@ process gcta_intervals_maps {

input:
tuple val(TRAIT), file(pheno), file(tests), file(geno), val(P3D), val(sig_thresh), \
val(qtl_grouping_size), val(qtl_ci_size), file(lmmexact_inbred), file(lmmexact_loco), file(find_aggregate_intervals_maps)
val(qtl_grouping_size), val(qtl_ci_size), file(lmmexact), \
file(find_aggregate_intervals_maps), val(algorithm)

output:
tuple file(geno), file(pheno), val(TRAIT), file(tests), file("*AGGREGATE_mapping_inbred.tsv"), file("*AGGREGATE_mapping_loco.tsv"), emit: maps_to_plot
path "*AGGREGATE_qtl_region_inbred.tsv", emit: qtl_peaks_inbred
tuple file("*AGGREGATE_mapping_inbred.tsv"), file("*AGGREGATE_mapping_loco.tsv"), val(TRAIT), emit: for_html

path "*AGGREGATE_qtl_region_loco.tsv", emit: qtl_peaks_loco
// tuple val('loco'), file("*AGGREGATE_mapping_loco.tsv"), val(TRAIT), emit: for_html_loco
tuple file(geno), file(pheno), val(TRAIT), file(tests), file("*AGGREGATE_mapping_${algorithm}.tsv"), emit: maps_to_plot
path "*AGGREGATE_qtl_region${algorithm}.tsv", emit: qtl_peaks
tuple file("*AGGREGATE_mapping_${algorithm}.tsv"), val(TRAIT), val(algorithm), emit: for_html

"""
Rscript --vanilla ${find_aggregate_intervals_maps} ${geno} ${pheno} ${lmmexact_inbred} ${tests} ${qtl_grouping_size} ${qtl_ci_size} ${sig_thresh} ${TRAIT}_AGGREGATE inbred
Rscript --vanilla ${find_aggregate_intervals_maps} ${geno} ${pheno} ${lmmexact_loco} ${tests} ${qtl_grouping_size} ${qtl_ci_size} ${sig_thresh} ${TRAIT}_AGGREGATE loco
Rscript --vanilla ${find_aggregate_intervals_maps} ${geno} ${pheno} ${lmmexact} \\
${tests} ${qtl_grouping_size} ${qtl_ci_size} ${sig_thresh} \\
${TRAIT}_AGGREGATE ${algorithm}
"""
}

Loading

0 comments on commit 6a9908b

Please sign in to comment.