Download scripts/01_chipseq/chipseq_pipeline.sh from jchen2025/zga-replication-analysis: direct link, hf CLI and curl.
- Browser
- Download file 2.45 kB
-
https://huggingface.co/datasets/jchen2025/zga-replication-analysis/resolve/main/scripts/01_chipseq/chipseq_pipeline.sh
- Command line
-
hf download hf://datasets/jchen2025/zga-replication-analysis/scripts/01_chipseq/chipseq_pipeline.sh
-
curl -L -o chipseq_pipeline.sh https://huggingface.co/datasets/jchen2025/zga-replication-analysis/resolve/main/scripts/01_chipseq/chipseq_pipeline.sh
2.45 kB
| # ChIP-seq pipeline (single-end): trim -> align -> dedup -> input-subtracted RPM / CPM bigWig -> peaks -> repeat annotation | |
| # Thesis section 4.2.1 steps (1)-(6). | |
| # | |
| # Usage: bash chipseq_pipeline.sh <ip_sample> <input_sample> | |
| # expects <sample>.fastq.gz in the current directory | |
| set -euo pipefail | |
| source "$(dirname "$0")/../../config/config.sh" | |
| IP=${1:?IP sample name} | |
| IN=${2:?input/IgG sample name} | |
| mkdir -p trim bam bw peaks anno | |
| for s in "$IP" "$IN"; do | |
| # (1) adapter / quality trimming + FastQC (Trim Galore v0.6.4) | |
| trim_galore "$s.fastq.gz" --gzip -o trim --cores 8 --fastqc | |
| # (2) alignment to dm6 (Bowtie 2 v2.3.5.1, samtools) | |
| bowtie2 -x "$BOWTIE2_INDEX" -p "$THREADS" -U "trim/${s}_trimmed.fq.gz" \ | |
| | samtools sort -@ "$THREADS" -O bam -o "bam/${s}_sort.bam" | |
| # (3) remove PCR / sequencing duplicates (GATK MarkDuplicates v4.1.4.1) | |
| gatk MarkDuplicates -I "bam/${s}_sort.bam" --ADD_PG_TAG_TO_READS false \ | |
| --REMOVE_SEQUENCING_DUPLICATES true --CREATE_INDEX true \ | |
| -O "bam/${s}.rmdup.bam" -M "bam/${s}.rmdup.matrix.txt" | |
| # CPM-normalised coverage track (deepTools bamCoverage) | |
| bamCoverage -p "$THREADS" -b "bam/${s}.rmdup.bam" --skipNAs \ | |
| --normalizeUsing CPM -o "bw/${s}.CPM.bw" | |
| done | |
| # (4) IP minus input, negatives set to 0, rescaled to RPM (deepTools bamCompare v3.3.1) | |
| bamCompare -p "$THREADS" -b1 "bam/${IP}.rmdup.bam" -b2 "bam/${IN}.rmdup.bam" \ | |
| --skipNAs --scaleFactorsMethod readCount --operation subtract \ | |
| --extendReads 200 --outFileFormat bedgraph -o "bw/${IP}.compareInput.bedgraph" | |
| awk 'BEGIN{OFS="\t"} {if($4<0) $4=0; print}' "bw/${IP}.compareInput.bedgraph" > "bw/${IP}.move0.bedgraph" | |
| totalreads=$(awk '{s+=$4} END{print s}' "bw/${IP}.move0.bedgraph") | |
| echo "signal remaining after input subtraction: $totalreads" | |
| awk -v t="$totalreads" 'BEGIN{OFS="\t"} {$4=$4/t*1e6; print}' "bw/${IP}.move0.bedgraph" \ | |
| | sort -k1,1 -k2,2n > "bw/${IP}.rpm.sort.bedgraph" | |
| bedGraphToBigWig "bw/${IP}.rpm.sort.bedgraph" "$CHROM_SIZES" "bw/${IP}.rpm.bw" | |
| # (5) peak calling with input as control (MACS2 v2.2.6) | |
| macs2 callpeak -t "bam/${IP}.rmdup.bam" -c "bam/${IN}.rmdup.bam" \ | |
| -f BAM -g "$GENOME_SIZE" -n "$IP" --outdir peaks | |
| cut -f1-6 "peaks/${IP}_peaks.narrowPeak" > "peaks/${IP}_peaks.bed" | |
| # (6) overlap peaks with repeat annotation (bedtools v2.30.0) | |
| bedtools intersect -a "peaks/${IP}_peaks.bed" -b "$REPEAT_GTF" -wa -wb > "anno/${IP}_overlap_repeat_anno.txt" | |