Skip to content

Commit

Permalink
update config for snp
Browse files Browse the repository at this point in the history
  • Loading branch information
CChahrour committed Apr 28, 2024
1 parent 282e155 commit d448f8a
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 34 deletions.
124 changes: 95 additions & 29 deletions seqnado/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
template_dir = os.path.join(package_dir, "workflow/config")


# Helper Functions
def get_user_input(prompt, default=None, is_boolean=False, choices=None):
while True:
user_input = (
Expand Down Expand Up @@ -143,19 +142,20 @@ def setup_configuration(assay, genome, template_data):
)

# Make bigwigs
template_data["make_bigwigs"] = get_user_input(
"Do you want to make bigwigs? (yes/no)", default="no", is_boolean=True
)
if template_data["make_bigwigs"]:
template_data["pileup_method"] = get_user_input(
"Pileup method:", default="deeptools", choices=["deeptools", "homer"]
)
template_data["scale"] = get_user_input(
"Scale bigwigs? (yes/no)", default="no", is_boolean=True
)
template_data["make_heatmaps"] = get_user_input(
"Do you want to make heatmaps? (yes/no)", default="no", is_boolean=True
if assay not in ["snp"]:
template_data["make_bigwigs"] = get_user_input(
"Do you want to make bigwigs? (yes/no)", default="no", is_boolean=True
)
if template_data["make_bigwigs"]:
template_data["pileup_method"] = get_user_input(
"Pileup method:", default="deeptools", choices=["deeptools", "homer"]
)
template_data["scale"] = get_user_input(
"Scale bigwigs? (yes/no)", default="no", is_boolean=True
)
template_data["make_heatmaps"] = get_user_input(
"Do you want to make heatmaps? (yes/no)", default="no", is_boolean=True
)

# Call peaks
if assay in ["chip", "atac"]:
Expand Down Expand Up @@ -196,29 +196,75 @@ def setup_configuration(assay, genome, template_data):
else "False"
)

# Make UCSC hub
template_data["make_ucsc_hub"] = get_user_input(
"Do you want to make a UCSC hub? (yes/no)", default="no", is_boolean=True
# SNP options
template_data["call_snps"] = (
get_user_input("Call SNPs? (yes/no)", default="no", is_boolean=True)
if assay == "snp"
else "False"
)

template_data["snp_calling_method"] = (
get_user_input(
"SNP caller:",
default="bcftools",
choices=["bcftools", "deepvariant"],
)
if template_data["call_snps"]
else "False"
)

template_data["UCSC_hub_directory"] = (
get_user_input("UCSC hub directory:", default="seqnado_output/hub/")
if template_data["make_ucsc_hub"]
else "seqnado_output/hub/"
template_data["fasta"] = (
get_user_input("Path to reference fasta:", default="path/to/reference.fasta")
if template_data["call_snps"]
else "False"
)
template_data["email"] = (
get_user_input("What is your email address?", default=f"{username}@example.com")
if template_data["make_ucsc_hub"]
else f"{username}@example.com"
template_data["fasta_index"] = (
get_user_input(
"Path to reference fasta index:", default="path/to/reference.fasta.fai"
)
if template_data["call_snps"]
else "False"
)
template_data["color_by"] = (
get_user_input("Color by (for UCSC hub):", default="samplename")
if template_data["make_ucsc_hub"]
else "samplename"

template_data["snp_database"] = (
get_user_input(
"Path to SNP database:",
default="path/to/snp_database",
)
if template_data["call_snps"]
else "False"
)

# Make UCSC hub
if assay not in ["snp"]:
template_data["make_ucsc_hub"] = get_user_input(
"Do you want to make a UCSC hub? (yes/no)", default="no", is_boolean=True
)

template_data["UCSC_hub_directory"] = (
get_user_input("UCSC hub directory:", default="seqnado_output/hub/")
if template_data["make_ucsc_hub"]
else "seqnado_output/hub/"
)
template_data["email"] = (
get_user_input("What is your email address?", default=f"{username}@example.com")
if template_data["make_ucsc_hub"]
else f"{username}@example.com"
)
template_data["color_by"] = (
get_user_input("Color by (for UCSC hub):", default="samplename")
if template_data["make_ucsc_hub"]
else "samplename"
)

template_data["options"] = (
TOOL_OPTIONS if assay in ["chip", "atac", "snp"] else TOOL_OPTIONS_RNA
TOOL_OPTIONS
if assay in ["chip", "atac"]
else (
TOOL_OPTIONS_RNA
if assay == "rna"
else TOOL_OPTIONS_SNP if assay == "snp" else ""
)
)


Expand Down Expand Up @@ -300,6 +346,26 @@ def setup_configuration(assay, genome, template_data):
"""


TOOL_OPTIONS_SNP = """
trim_galore:
threads: 8
options: --2colour 20
bowtie2:
threads: 8
options:
picard:
threads: 8
options:
bcftools:
threads: 16
options:
"""


def create_config(assay, genome, rerun, debug=False):
env = Environment(loader=FileSystemLoader(template_dir), auto_reload=False)

Expand Down
6 changes: 5 additions & 1 deletion seqnado/workflow/config/config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ remove_blacklist: "{{remove_blacklist}}"
blacklist: "{{blacklist}}"

remove_pcr_duplicates_method: "{{remove_pcr_duplicates_method}}"
library_complexity: "{{library_complexity}}"

shift_atac_reads: "{{shift_atac_reads}}"

Expand All @@ -44,6 +43,11 @@ salmon_index: "{{salmon_index}}"

run_deseq2: "{{run_deseq2}}"

call_snps: "{{call_snps}}"
snp_calling_method: "{{snp_calling_method}}"
fasta: "{{fasta}}"
fasta_index: "{{fasta_index}}"
snp_database: "{{snp_database}}"

make_ucsc_hub: "{{make_ucsc_hub}}"
ucsc_hub_details:
Expand Down
8 changes: 4 additions & 4 deletions seqnado/workflow/rules/variant.smk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ if config["call_snps"]:
output:
vcf="seqnado_output/variant/bcftools/{sample}.vcf.gz",
params:
fasta=config["genome"]["fasta"],
faidx=config["genome"]["fasta_index"],
fasta=config["fasta"],
faidx=config["fasta_index"],
resources:
mem=lambda wildcards, attempt: f"{10 * 2 ** (attempt -1)}GB",
runtime=lambda wildcards, attempt: f"{5 * 2 ** (attempt - 1)}h",
Expand All @@ -33,7 +33,7 @@ if config["call_snps"]:
output:
stats="seqnado_output/variant/bcftools/{sample}_filtered.stats.txt",
params:
fasta=config["genome"]["fasta"],
fasta=config["fasta"],
shell:
"bcftools stats -F {params.fasta} -s - {input.vcf} > {output.stats}"

Expand All @@ -43,7 +43,7 @@ if config["call_snps"]:
output:
summary="seqnado_output/variant/bcftools/{sample}_summary.pdf",
params:
fasta=config["genome"]["fasta"],
fasta=config["fasta"],
out_dir="seqnado_output/variant/bcftools/",
shell:
"plot-vcfstats -p {params.out_dir} {input.stats}"
Expand Down

0 comments on commit d448f8a

Please sign in to comment.