* first commit with imputeme as a module. Extensive re-write of imputeme-code, resulting in release v1.0.7 that is runnable in the next-flow framework.


Co-authored-by: EC2 Default User <ec2-user@ip-172-31-21-198.us-west-2.compute.internal>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
Co-authored-by: Pontus Freyhult <pontus_github@soua.net>
This commit is contained in:
Lasse Folkersen 2021-11-05 10:25:54 +01:00 committed by GitHub
parent 02892ef654
commit e560fbbc3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 208 additions and 0 deletions

BIN
modules/gunzip/test.txt.gz Normal file

Binary file not shown.

View file

@ -0,0 +1,78 @@
//
// Utility functions used in nf-core DSL2 module files
//
//
// Extract name of software tool from process name using $task.process
//
def getSoftwareName(task_process) {
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
}
//
// Extract name of module from process name using $task.process
//
def getProcessName(task_process) {
return task_process.tokenize(':')[-1]
}
//
// Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
//
def initOptions(Map args) {
def Map options = [:]
options.args = args.args ?: ''
options.args2 = args.args2 ?: ''
options.args3 = args.args3 ?: ''
options.publish_by_meta = args.publish_by_meta ?: []
options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files
options.suffix = args.suffix ?: ''
return options
}
//
// Tidy up and join elements of a list to return a path string
//
def getPathFromList(path_list) {
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
return paths.join('/')
}
//
// Function to save/publish module results
//
def saveFiles(Map args) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
// Do not publish versions.yml unless running from pytest workflow
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
return null
}
if (ioptions.publish_by_meta) {
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
for (key in key_list) {
if (args.meta && key instanceof String) {
def path = key
if (args.meta.containsKey(key)) {
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
}
path = path instanceof String ? path : ''
path_list.add(path)
}
}
}
if (ioptions.publish_files instanceof Map) {
for (ext in ioptions.publish_files) {
if (args.filename.endsWith(ext.key)) {
def ext_list = path_list.collect()
ext_list.add(ext.value)
return "${getPathFromList(ext_list)}/$args.filename"
}
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}

View file

@ -0,0 +1,60 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process IMPUTEME_VCFTOPRS {
tag "$meta.id"
label 'process_low'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
conda (params.enable_conda ? "YOUR-TOOL-HERE" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://containers.biocontainers.pro/s3/SingImgsRepo/imputeme/vv1.0.7_cv1/imputeme_vv1.0.7_cv1.img"
} else {
container "biocontainers/imputeme:vv1.0.7_cv1"
}
input:
tuple val(meta), path(vcf)
output:
tuple val(meta), path("*.json"), emit: json
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
#!/usr/bin/env Rscript
#Set configuration - either from options.args or from defaults
source("/imputeme/code/impute-me/functions.R")
if(file.exists('$options.args')){
set_conf("set_from_file",'$options.args')
}else{
set_conf("set_from_file", "/imputeme/code/impute-me/template/nextflow_default_configuration.R")
}
#main run
return_message <- prepare_individual_genome('$vcf',overrule_vcf_checks=T)
uniqueID <- sub(' </b>.+\$','',sub('^.+this run is <b> ','',return_message))
convert_vcfs_to_simple_format(uniqueID=uniqueID)
crawl_for_snps_to_analyze(uniqueIDs=uniqueID)
run_export_script(uniqueIDs=uniqueID)
file.copy(paste0("./",uniqueID,"/",uniqueID,"_data.json"),"output.json")
#version export. Have to hardcode process name and software name because
#won't run inside an R-block
version_file_path="versions.yml"
f <- file(version_file_path,"w")
writeLines("IMPUTEME_VCFTOPRS:", f)
writeLines(paste0(" imputeme: ", sub("^v","",get_conf("version"))),f)
close(f)
"""
}

View file

@ -0,0 +1,41 @@
name: imputeme_vcftoprs
description: inputs a VCF-file with whole genome DNA sequencing. Outputs a JSON with polygenic risk scores.
keywords:
- PRS, VCF
tools:
- imputeme:
description:
homepage: www.impute.me
documentation: https://hub.docker.com/repository/docker/lassefolkersen/impute-me
tool_dev_url: https://github.com/lassefolkersen/impute-me
doi: "https://doi.org/10.3389/fgene.2020.00578"
licence: LGPL3
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ vcf:'test', single_end:false ]
- vcf:
type: file
description: vcf file
pattern: "*.{vcf}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- json:
type: file
description: json containing Z-scores for all calculated PRS
pattern: "*.{json}"
authors:
- "@lassefolkersen"

View file

@ -609,6 +609,10 @@ homer/makeucscfile:
- modules/homer/makeucscfile/**
- tests/modules/homer/makeucscfile/**
imputeme/vcftoprs:
- modules/imputeme/vcftoprs/**
- tests/modules/imputeme/vcftoprs/**
idr:
- modules/idr/**
- tests/modules/idr/**

View file

@ -119,6 +119,8 @@ params {
gnomad_r2_1_1_vcf_gz_tbi = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/gnomAD.r2.1.1.vcf.gz.tbi"
mills_and_1000g_indels_vcf_gz = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/mills_and_1000G.indels.vcf.gz"
mills_and_1000g_indels_vcf_gz_tbi = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/mills_and_1000G.indels.vcf.gz.tbi"
syntheticvcf_short_vcf_gz = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/syntheticvcf_short.vcf.gz"
syntheticvcf_short_vcf_gz_tbi = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/syntheticvcf_short.vcf.gz.tbi"
index_salmon = "${test_data_dir}/genomics/homo_sapiens/genome/index/salmon"
repeat_expansions = "${test_data_dir}/genomics/homo_sapiens/genome/loci/repeat_expansions.json"
}

View file

@ -0,0 +1,15 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { IMPUTEME_VCFTOPRS } from '../../../../modules/imputeme/vcftoprs/main.nf' addParams( options: [:] )
workflow test_imputeme_vcftoprs {
input = [
[ id:'test' ], // meta map
file(params.test_data['homo_sapiens']['genome']['syntheticvcf_short_vcf_gz'], checkIfExists: true)
]
IMPUTEME_VCFTOPRS ( input )
}

View file

@ -0,0 +1,8 @@
- name: imputeme vcftoprs test_imputeme_vcftoprs
command: nextflow run tests/modules/imputeme/vcftoprs -entry test_imputeme_vcftoprs -c tests/config/nextflow.config
tags:
- imputeme
- imputeme/vcftoprs
files:
- path: output/imputeme/output.json
contains: [ 'type_2_diabetes_32541925":{"GRS":[24.01]' ]