Skip to content

Commit

Permalink
Merge pull request #249 from broadinstitute/move_activity_to_input
Browse files Browse the repository at this point in the history
Add function to determine list of input activity files so that make_candidate_regions can take them as input (and validate existence of potential H3K27ac inputs).
  • Loading branch information
mayasheth authored Feb 22, 2025
2 parents 812258b + ddcb42d commit 4b05671
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions workflow/rules/neighborhoods.smk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
rule create_neighborhoods:
input:
candidateRegions = os.path.join(RESULTS_DIR, "{biosample}", "Peaks", "macs2_peaks.narrowPeak.sorted.candidateRegions.bed"),
chrom_sizes_bed = os.path.join(RESULTS_DIR, "tmp", os.path.basename(config['ref']['chrom_sizes']) + '.bed')
chrom_sizes_bed = os.path.join(RESULTS_DIR, "tmp", os.path.basename(config['ref']['chrom_sizes']) + '.bed'),
activity_files = get_activity_files
params:
DHS = lambda wildcards: BIOSAMPLES_CONFIG.loc[wildcards.biosample, "DHS"] or '',
ATAC = lambda wildcards: BIOSAMPLES_CONFIG.loc[wildcards.biosample, "ATAC"] or '',
Expand Down Expand Up @@ -41,4 +42,4 @@ rule create_neighborhoods:
--ubiquitously_expressed_genes {params.ubiquitous_genes} \
--H3K27ac {params.H3K27ac} \
{params.qnorm}
"""
"""
8 changes: 8 additions & 0 deletions workflow/rules/utils.smk
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ def get_accessibility_files(wildcards):
files = BIOSAMPLES_CONFIG.loc[wildcards.biosample, "DHS"] or BIOSAMPLES_CONFIG.loc[wildcards.biosample, "ATAC"]
return files.split(",")

def get_activity_files(wildcards):
# for neighborhoods step, to trigger download of necessary inputs
files = get_accessibility_files(wildcards)
k27ac_value = BIOSAMPLES_CONFIG.loc[wildcards.biosample, "H3K27ac"]
if k27ac_value:
k27ac_files = k27ac_value.split(",")
files = files + k27ac_files
return files

def _validate_accessibility_feature(row: pd.Series):
if row["DHS"] and row["ATAC"]:
Expand Down

0 comments on commit 4b05671

Please sign in to comment.