{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "291febae-6325-4502-b575-67868c6038f1",
   "metadata": {},
   "source": [
    "# 1.QC to bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "68adfa87-19cd-42b6-bde5-97b5e86f3378",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T06:45:21.602185Z",
     "iopub.status.busy": "2025-11-13T06:45:21.601520Z",
     "iopub.status.idle": "2025-11-13T06:45:21.762197Z",
     "shell.execute_reply": "2025-11-13T06:45:21.760971Z",
     "shell.execute_reply.started": "2025-11-13T06:45:21.602145Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[0m\u001b[01;31mGFP_OE_250926N_R1.fastq.gz\u001b[0m  \u001b[01;31mrox2_OE_250926N_R1.fastq.gz\u001b[0m\n",
      "\u001b[01;31mGFP_OE_250926N_R2.fastq.gz\u001b[0m  \u001b[01;31mrox2_OE_250926N_R2.fastq.gz\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "cd ./0_data/\n",
    "ls"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4747a5af-1976-43e9-9755-e41563bab474",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T06:45:22.569654Z",
     "iopub.status.busy": "2025-11-13T06:45:22.569210Z",
     "iopub.status.idle": "2025-11-13T07:07:58.196298Z",
     "shell.execute_reply": "2025-11-13T07:07:58.194939Z",
     "shell.execute_reply.started": "2025-11-13T06:45:22.569619Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GFP_OE\n",
      "Detecting adapter sequence for read1...\n",
      ">I7_Nextera_Transposase_1 | >Trans2_rc | >I7_Nextera_Transposase_1 | >Trans2_rc\n",
      "CTGTCTCTTATACACATCTCCGAGCCCACGAGAC\n",
      "\n",
      "Detecting adapter sequence for read2...\n",
      ">I5_Nextera_Transposase_1 | >Trans1_rc | >I5_Nextera_Transposase_1 | >Trans1_rc\n",
      "CTGTCTCTTATACACATCTGACGCTGCCGACGA\n",
      "\n",
      "WARNING: fastp uses up to 16 threads although you specified 50\n",
      "Read1 before filtering:\n",
      "total reads: 21437850\n",
      "total bases: 3215677500\n",
      "Q20 bases: 3041184237(94.5737%)\n",
      "Q30 bases: 2824348619(87.8306%)\n",
      "\n",
      "Read2 before filtering:\n",
      "total reads: 21437850\n",
      "total bases: 3215677500\n",
      "Q20 bases: 3146664392(97.8539%)\n",
      "Q30 bases: 2994646853(93.1265%)\n",
      "\n",
      "Read1 after filtering:\n",
      "total reads: 21182137\n",
      "total bases: 2357310971\n",
      "Q20 bases: 2339405695(99.2404%)\n",
      "Q30 bases: 2267885738(96.2065%)\n",
      "\n",
      "Read2 after filtering:\n",
      "total reads: 21182137\n",
      "total bases: 2357820595\n",
      "Q20 bases: 2322471304(98.5008%)\n",
      "Q30 bases: 2225144751(94.3729%)\n",
      "\n",
      "Filtering result:\n",
      "reads passed filter: 42364274\n",
      "reads failed due to low quality: 489316\n",
      "reads failed due to too many N: 21974\n",
      "reads failed due to too short: 136\n",
      "reads with adapter trimmed: 28099246\n",
      "bases trimmed due to adapters: 1656753510\n",
      "\n",
      "Duplication rate: 19.0219%\n",
      "\n",
      "Insert size peak (evaluated by paired-end reads): 65\n",
      "\n",
      "JSON report: GFP_OE.json\n",
      "HTML report: GFP_OE.html\n",
      "\n",
      "fastp -i GFP_OE_250926N_R1.fastq.gz -o GFP_OE_R1.fq.gz -I GFP_OE_250926N_R2.fastq.gz -O GFP_OE_R2.fq.gz -w 50 -j GFP_OE.json -h GFP_OE.html --detect_adapter_for_pe \n",
      "fastp v0.23.4, time used: 92 seconds\n",
      "Time loading reference: 00:00:00\n",
      "Time loading forward index: 00:00:00\n",
      "Time loading mirror index: 00:00:00\n",
      "Multiseed full-index search: 00:13:41\n",
      "21182137 reads; of these:\n",
      "  21182137 (100.00%) were paired; of these:\n",
      "    8133888 (38.40%) aligned concordantly 0 times\n",
      "    9453759 (44.63%) aligned concordantly exactly 1 time\n",
      "    3594490 (16.97%) aligned concordantly >1 times\n",
      "61.60% overall alignment rate\n",
      "Time searching: 00:13:41\n",
      "Overall time: 00:13:41\n",
      "\n",
      "sambamba 1.0.1\n",
      " by Artem Tarasov and Pjotr Prins (C) 2012-2023\n",
      "    LDC 1.38.0 / DMD v2.108.1 / LLVM17.0.6 / bootstrap LDC - the LLVM D compiler (1.38.0)\n",
      "\n",
      "finding positions of the duplicate reads in the file...\n",
      "  sorted 10099542 end pairs\n",
      "     and 0 single ends (among them 0 unmatched pairs)\n",
      "  collecting indices of duplicate reads...   done in 1156 ms\n",
      "  found 4808164 duplicates\n",
      "collected list of positions in 0 min 33 sec\n",
      "removing duplicates...\n",
      "collected list of positions in 1 min 3 sec\n",
      "[bam_sort_core] merging from 0 files and 50 in-memory blocks...\n",
      "rox2_OE\n",
      "Detecting adapter sequence for read1...\n",
      ">I7_Nextera_Transposase_1 | >Trans2_rc | >I7_Nextera_Transposase_1 | >Trans2_rc\n",
      "CTGTCTCTTATACACATCTCCGAGCCCACGAGAC\n",
      "\n",
      "Detecting adapter sequence for read2...\n",
      ">I5_Nextera_Transposase_1 | >Trans1_rc | >I5_Nextera_Transposase_1 | >Trans1_rc\n",
      "CTGTCTCTTATACACATCTGACGCTGCCGACGA\n",
      "\n",
      "WARNING: fastp uses up to 16 threads although you specified 50\n",
      "Read1 before filtering:\n",
      "total reads: 17852151\n",
      "total bases: 2677822650\n",
      "Q20 bases: 2533817930(94.6223%)\n",
      "Q30 bases: 2356033905(87.9832%)\n",
      "\n",
      "Read2 before filtering:\n",
      "total reads: 17852151\n",
      "total bases: 2677822650\n",
      "Q20 bases: 2628370097(98.1533%)\n",
      "Q30 bases: 2515635155(93.9433%)\n",
      "\n",
      "Read1 after filtering:\n",
      "total reads: 17680442\n",
      "total bases: 1922737123\n",
      "Q20 bases: 1911026019(99.3909%)\n",
      "Q30 bases: 1863858583(96.9378%)\n",
      "\n",
      "Read2 after filtering:\n",
      "total reads: 17680442\n",
      "total bases: 1923663379\n",
      "Q20 bases: 1895872097(98.5553%)\n",
      "Q30 bases: 1821084749(94.6675%)\n",
      "\n",
      "Filtering result:\n",
      "reads passed filter: 35360884\n",
      "reads failed due to low quality: 295198\n",
      "reads failed due to too many N: 44666\n",
      "reads failed due to too short: 3554\n",
      "reads with adapter trimmed: 23892708\n",
      "bases trimmed due to adapters: 1470086534\n",
      "\n",
      "Duplication rate: 38.3336%\n",
      "\n",
      "Insert size peak (evaluated by paired-end reads): 63\n",
      "\n",
      "JSON report: rox2_OE.json\n",
      "HTML report: rox2_OE.html\n",
      "\n",
      "fastp -i rox2_OE_250926N_R1.fastq.gz -o rox2_OE_R1.fq.gz -I rox2_OE_250926N_R2.fastq.gz -O rox2_OE_R2.fq.gz -w 50 -j rox2_OE.json -h rox2_OE.html --detect_adapter_for_pe \n",
      "fastp v0.23.4, time used: 65 seconds\n",
      "Time loading reference: 00:00:00\n",
      "Time loading forward index: 00:00:00\n",
      "Time loading mirror index: 00:00:00\n",
      "Multiseed full-index search: 00:02:46\n",
      "17680442 reads; of these:\n",
      "  17680442 (100.00%) were paired; of these:\n",
      "    14629554 (82.74%) aligned concordantly 0 times\n",
      "    2137968 (12.09%) aligned concordantly exactly 1 time\n",
      "    912920 (5.16%) aligned concordantly >1 times\n",
      "17.26% overall alignment rate\n",
      "Time searching: 00:02:46\n",
      "Overall time: 00:02:46\n",
      "\n",
      "sambamba 1.0.1\n",
      " by Artem Tarasov and Pjotr Prins (C) 2012-2023\n",
      "    LDC 1.38.0 / DMD v2.108.1 / LLVM17.0.6 / bootstrap LDC - the LLVM D compiler (1.38.0)\n",
      "\n",
      "finding positions of the duplicate reads in the file...\n",
      "  sorted 2241580 end pairs\n",
      "     and 0 single ends (among them 0 unmatched pairs)\n",
      "  collecting indices of duplicate reads...   done in 433 ms\n",
      "  found 2631878 duplicates\n",
      "collected list of positions in 0 min 7 sec\n",
      "removing duplicates...\n",
      "collected list of positions in 0 min 15 sec\n",
      "[bam_sort_core] merging from 0 files and 50 in-memory blocks...\n"
     ]
    }
   ],
   "source": [
    "for i in `ls *_R1.fastq.gz`\n",
    "do\n",
    "    prefix=${i%%_R1.fastq.gz}\n",
    "    name=${i%%_25*}\n",
    "    echo $name\n",
    "\n",
    "    fastp -i $i -o ${name}_R1.fq.gz -I ${prefix}_R2.fastq.gz -O ${name}_R2.fq.gz -w 50  -j ${name}.json -h ${name}.html --detect_adapter_for_pe\n",
    "    bowtie2 -t -q -p 50 --local --very-sensitive-local --no-mixed --no-discordant --no-unal --phred33 -X 2000 -x '/home/yhli/genome/dm6Bowtie2/dm6' -1 ${name}_R1.fq.gz -2 ${name}_R2.fq.gz -S ./${name}.sam\n",
    "    samtools view -@ 50 -F 0x904 -q 20 -b -h -o ${name}.bam ${name}.sam \n",
    "\tsambamba markdup -r -t 50 ${name}.bam ${name}.rmdup.bam\n",
    "\tsamtools view -@ 50 -h ${name}.rmdup.bam | grep -v 'random'|grep -v 'chrUn'|grep -v 'chrM'|samtools view -@ 50 -bS -o ${name}.rmChr.bam\n",
    "    samtools sort -@ 50 ${name}.rmChr.bam > ${name}.final.bam\n",
    "\tsamtools index -@ 50 ${name}.final.bam\n",
    "\n",
    "    total=`echo $(($(zcat ${i} | wc -l )/2))`\n",
    "\tmap=`samtools view -@ 50 -c ${name}.bam`\n",
    "\trmdup=`samtools view -@ 50 -c ${name}.rmdup.bam`\n",
    "\tfinal=`samtools view -@ 50 -c ${name}.final.bam`\n",
    "\techo -e \"${name} ${total} ${map} ${rmdup} ${final}\" >> mapping.log\n",
    "\n",
    "    rm ${name}.sam\n",
    "    rm ${name}.bam\n",
    "    rm ${name}.rmChr.bam\n",
    "    rm ${name}.rmdup.bam\n",
    "done"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1ad5dbb1-ba47-4546-8ece-f7b4043fcaba",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:07:58.199076Z",
     "iopub.status.busy": "2025-11-13T07:07:58.198632Z",
     "iopub.status.idle": "2025-11-13T07:13:57.354035Z",
     "shell.execute_reply": "2025-11-13T07:13:57.352690Z",
     "shell.execute_reply.started": "2025-11-13T07:07:58.199043Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GFP_OE\n",
      "Time loading reference: 00:00:00\n",
      "Time loading forward index: 00:00:00\n",
      "Time loading mirror index: 00:00:00\n",
      "Multiseed full-index search: 00:02:38\n",
      "21182137 reads; of these:\n",
      "  21182137 (100.00%) were paired; of these:\n",
      "    20787439 (98.14%) aligned concordantly 0 times\n",
      "    376255 (1.78%) aligned concordantly exactly 1 time\n",
      "    18443 (0.09%) aligned concordantly >1 times\n",
      "1.86% overall alignment rate\n",
      "Time searching: 00:02:38\n",
      "Overall time: 00:02:38\n",
      "\n",
      "sambamba 1.0.1\n",
      " by Artem Tarasov and Pjotr Prins (C) 2012-2023\n",
      "    LDC 1.38.0 / DMD v2.108.1 / LLVM17.0.6 / bootstrap LDC - the LLVM D compiler (1.38.0)\n",
      "\n",
      "finding positions of the duplicate reads in the file...\n",
      "  sorted 382007 end pairs\n",
      "     and 0 single ends (among them 0 unmatched pairs)\n",
      "  collecting indices of duplicate reads...   done in 57 ms\n",
      "  found 93256 duplicates\n",
      "collected list of positions in 0 min 1 sec\n",
      "removing duplicates...\n",
      "collected list of positions in 0 min 2 sec\n",
      "[bam_sort_core] merging from 0 files and 50 in-memory blocks...\n",
      "rox2_OE\n",
      "Time loading reference: 00:00:00\n",
      "Time loading forward index: 00:00:00\n",
      "Time loading mirror index: 00:00:00\n",
      "Multiseed full-index search: 00:02:11\n",
      "17680442 reads; of these:\n",
      "  17680442 (100.00%) were paired; of these:\n",
      "    17463014 (98.77%) aligned concordantly 0 times\n",
      "    206845 (1.17%) aligned concordantly exactly 1 time\n",
      "    10583 (0.06%) aligned concordantly >1 times\n",
      "1.23% overall alignment rate\n",
      "Time searching: 00:02:11\n",
      "Overall time: 00:02:11\n",
      "\n",
      "sambamba 1.0.1\n",
      " by Artem Tarasov and Pjotr Prins (C) 2012-2023\n",
      "    LDC 1.38.0 / DMD v2.108.1 / LLVM17.0.6 / bootstrap LDC - the LLVM D compiler (1.38.0)\n",
      "\n",
      "finding positions of the duplicate reads in the file...\n",
      "  sorted 209852 end pairs\n",
      "     and 0 single ends (among them 0 unmatched pairs)\n",
      "  collecting indices of duplicate reads...   done in 33 ms\n",
      "  found 130690 duplicates\n",
      "collected list of positions in 0 min 0 sec\n",
      "removing duplicates...\n",
      "collected list of positions in 0 min 1 sec\n",
      "[bam_sort_core] merging from 0 files and 50 in-memory blocks...\n"
     ]
    }
   ],
   "source": [
    "for i in `ls *_R1.fq.gz`\n",
    "do\n",
    "    prefix=${i%%_R1.fq.gz}\n",
    "    name=${i%%_R1*gz}\n",
    "    echo $name\n",
    "\n",
    "    bowtie2 -t -q -p 50 --local --very-sensitive-local --no-mixed --no-discordant --no-unal --phred33 -X 2000 -x '/home/share/iGenome/Escherichia_coli_K_12_MG1655/NCBI/2001-10-15/Sequence/Bowtie2Index/genome' -1 ${name}_R1.fq.gz -2 ${name}_R2.fq.gz -S ./${name}.sam\n",
    "    samtools view -@ 50 -F 0x904 -q 20 -b -h -o ${name}.bam ${name}.sam \n",
    "\tsambamba markdup -r -t 50 ${name}.bam ${name}.rmdup.bam\n",
    "\tsamtools view -@ 50 -h ${name}.rmdup.bam | grep -v 'random'|grep -v 'chrUn'|grep -v 'chrM'|samtools view -@ 50 -bS -o ${name}.rmChr.bam\n",
    "    samtools sort -@ 50 ${name}.rmChr.bam > ${name}_Ecoli.final.bam\n",
    "\tsamtools index -@ 50 ${name}_Ecoli.final.bam\n",
    "\n",
    "    total=`echo $(($(zcat ${i} | wc -l )/2))`\n",
    "\tmap=`samtools view -@ 50 -c ${name}.bam`\n",
    "\trmdup=`samtools view -@ 50 -c ${name}.rmdup.bam`\n",
    "\tfinal=`samtools view -@ 50 -c ${name}_Ecoli.final.bam`\n",
    "\techo -e \"${name} ${total} ${map} ${rmdup} ${final}\" >> mapping_Ecoli.log\n",
    "\n",
    "    rm ${name}.sam\n",
    "    rm ${name}.bam\n",
    "    rm ${name}.rmChr.bam\n",
    "    rm ${name}.rmdup.bam\n",
    "done"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "1325caa4-b5b6-4b54-9f97-edd8f82a5342",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:13:57.356167Z",
     "iopub.status.busy": "2025-11-13T07:13:57.355720Z",
     "iopub.status.idle": "2025-11-13T07:13:57.464362Z",
     "shell.execute_reply": "2025-11-13T07:13:57.463153Z",
     "shell.execute_reply.started": "2025-11-13T07:13:57.356133Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GFP_OE 42875700 20199084 15390920 14656476\n",
      "rox2_OE 35704302 4483160 1851282 1687200\n"
     ]
    }
   ],
   "source": [
    "cat ./mapping.log"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "88844cce-f926-4de6-925f-c988ce44efe6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:13:57.467928Z",
     "iopub.status.busy": "2025-11-13T07:13:57.466998Z",
     "iopub.status.idle": "2025-11-13T07:13:57.575480Z",
     "shell.execute_reply": "2025-11-13T07:13:57.574270Z",
     "shell.execute_reply.started": "2025-11-13T07:13:57.467892Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GFP_OE 42364274 764014 670758 670758\n",
      "rox2_OE 35360884 419704 289014 289014\n"
     ]
    }
   ],
   "source": [
    "cat ./mapping_Ecoli.log"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "18783feb-d3bc-4c40-b481-9068b5c3b022",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:13:57.577353Z",
     "iopub.status.busy": "2025-11-13T07:13:57.576926Z",
     "iopub.status.idle": "2025-11-13T07:16:21.821965Z",
     "shell.execute_reply": "2025-11-13T07:16:21.820607Z",
     "shell.execute_reply.started": "2025-11-13T07:13:57.577320Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GFP_OE\n",
      "14.9085\n",
      "bamFilesList: ['GFP_OE.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: 50\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n",
      "rox2_OE\n",
      "34.6004\n",
      "bamFilesList: ['rox2_OE.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: 50\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n"
     ]
    }
   ],
   "source": [
    "for i in `ls *_Ecoli.final.bam`\n",
    "do\n",
    "    name=${i%_Ecoli.final.bam}\n",
    "    echo $name\n",
    "    scaleFactor=`awk -v name=\"${name}\" '$1==name {print 10000000/$5}' mapping_Ecoli.log`\n",
    "    echo $scaleFactor\n",
    "    bedtools genomecov -bg -scale $scaleFactor -ibam ${name}.final.bam > ${name}_norm.bedgraph\n",
    "    bamCoverage -bs 20 --smoothLength 50 -p 50 -b ${name}.final.bam -o ${name}_20.bw --normalizeUsing None --scaleFactor $scaleFactor\n",
    "done"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "07decb33-d878-4c96-b80f-77b84938f972",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:16:21.824056Z",
     "iopub.status.busy": "2025-11-13T07:16:21.823623Z",
     "iopub.status.idle": "2025-11-13T07:19:42.371277Z",
     "shell.execute_reply": "2025-11-13T07:19:42.369781Z",
     "shell.execute_reply.started": "2025-11-13T07:16:21.824023Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "application/gzip\n",
      "application/gzip\n",
      "application/gzip\n",
      "Started analysis of GFP_OE_250926N_R1.fastq.gz\n",
      "application/gzip\n",
      "Started analysis of GFP_OE_250926N_R2.fastq.gz\n",
      "Started analysis of rox2_OE_250926N_R1.fastq.gz\n",
      "Started analysis of rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 5% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 5% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 5% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 5% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 10% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 10% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 10% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 10% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 15% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 15% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 15% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 15% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 20% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 20% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 20% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 25% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 25% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 20% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 25% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 30% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 30% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 25% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 35% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 35% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 30% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 30% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 40% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 40% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 35% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 35% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 45% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 45% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 40% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 40% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 50% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 50% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 45% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 55% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 55% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 45% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 50% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 60% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 60% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 50% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 65% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 55% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 65% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 55% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 70% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 70% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 60% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 60% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 75% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 75% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 65% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 80% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 65% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 80% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 70% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 85% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 85% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 70% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 90% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 75% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 90% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 75% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 95% complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 95% complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 80% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Analysis complete for rox2_OE_250926N_R2.fastq.gz\n",
      "Approx 80% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Analysis complete for rox2_OE_250926N_R1.fastq.gz\n",
      "Approx 85% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 85% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 90% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 90% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Approx 95% complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Approx 95% complete for GFP_OE_250926N_R1.fastq.gz\n",
      "Analysis complete for GFP_OE_250926N_R2.fastq.gz\n",
      "Analysis complete for GFP_OE_250926N_R1.fastq.gz\n",
      "\n",
      "  \u001b[38;5;208m///\u001b[0m \u001b]8;id=685770;https://multiqc.info\u001b\\\u001b[1mMultiQC\u001b[0m\u001b]8;;\u001b\\ 🔍 \u001b[2m| v1.17\u001b[0m\n",
      "\n",
      "\u001b[34m|           multiqc\u001b[0m | Search path : /home/yhli/result/Dm-roX2OE-ATAC-202510/0_data\n",
      "\u001b[2K\u001b[34m|\u001b[0m         \u001b[34msearching\u001b[0m | \u001b[38;5;70m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[35m100%\u001b[0m \u001b[32m34/34\u001b[0m  m \u001b[35m 29%\u001b[0m \u001b[32m10/34\u001b[0m \u001b[2m./GFP_OE_20.bw\u001b[0m\n",
      "\u001b[?25h\u001b[34m|            fastqc\u001b[0m | Found 4 reports\n",
      "\u001b[34m|           multiqc\u001b[0m | Report      : multiqc_report.html\n",
      "\u001b[34m|           multiqc\u001b[0m | Data        : multiqc_data\n",
      "\u001b[34m|           multiqc\u001b[0m | MultiQC complete\n"
     ]
    }
   ],
   "source": [
    "fastqc -t 50 *.fastq.gz\n",
    "multiqc ./"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "464e528f-e7a3-424f-8dc8-71ded3d9494d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-09-25T06:03:38.398271Z",
     "iopub.status.busy": "2024-09-25T06:03:38.397832Z",
     "iopub.status.idle": "2024-09-25T06:11:39.878134Z",
     "shell.execute_reply": "2024-09-25T06:11:39.876618Z",
     "shell.execute_reply.started": "2024-09-25T06:03:38.398240Z"
    }
   },
   "source": [
    "------\n",
    "\n",
    "# macs call peak \n",
    "\n",
    "bamCoverage & bamCompare"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "8a58aafc-3396-4705-8a74-7286bf2e99f4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:19:42.373447Z",
     "iopub.status.busy": "2025-11-13T07:19:42.373032Z",
     "iopub.status.idle": "2025-11-13T07:19:42.478078Z",
     "shell.execute_reply": "2025-11-13T07:19:42.476861Z",
     "shell.execute_reply.started": "2025-11-13T07:19:42.373415Z"
    }
   },
   "outputs": [],
   "source": [
    "cd ../1_macs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a262c194-2a08-4fcd-9f50-6fd8ba84323c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:19:42.479911Z",
     "iopub.status.busy": "2025-11-13T07:19:42.479508Z",
     "iopub.status.idle": "2025-11-13T07:20:56.120397Z",
     "shell.execute_reply": "2025-11-13T07:20:56.118912Z",
     "shell.execute_reply.started": "2025-11-13T07:19:42.479880Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GFP_OE_Ecoli\n",
      "normalization: RPKM\n",
      "bamFilesList: ['../0_data/GFP_OE_Ecoli.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: None\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n",
      "normalization: RPKM\n",
      "bamFilesList: ['../0_data/GFP_OE_Ecoli.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: None\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n",
      "GFP_OE\n",
      "normalization: RPKM\n",
      "bamFilesList: ['../0_data/GFP_OE.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: None\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n",
      "normalization: RPKM\n",
      "bamFilesList: ['../0_data/GFP_OE.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: None\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n",
      "rox2_OE_Ecoli\n",
      "normalization: RPKM\n",
      "bamFilesList: ['../0_data/rox2_OE_Ecoli.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: None\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n",
      "normalization: RPKM\n",
      "bamFilesList: ['../0_data/rox2_OE_Ecoli.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: None\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n",
      "rox2_OE\n",
      "normalization: RPKM\n",
      "bamFilesList: ['../0_data/rox2_OE.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: None\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n",
      "normalization: RPKM\n",
      "bamFilesList: ['../0_data/rox2_OE.final.bam']\n",
      "binLength: 20\n",
      "numberOfSamples: None\n",
      "blackListFileName: None\n",
      "skipZeroOverZero: False\n",
      "bed_and_bin: False\n",
      "genomeChunkSize: None\n",
      "defaultFragmentLength: read length\n",
      "numberOfProcessors: 50\n",
      "verbose: False\n",
      "region: None\n",
      "bedFile: None\n",
      "minMappingQuality: None\n",
      "ignoreDuplicates: False\n",
      "chrsToSkip: []\n",
      "stepSize: 20\n",
      "center_read: False\n",
      "samFlag_include: None\n",
      "samFlag_exclude: None\n",
      "minFragmentLength: 0\n",
      "maxFragmentLength: 0\n",
      "zerosToNans: False\n",
      "smoothLength: None\n",
      "save_data: False\n",
      "out_file_for_raw_data: None\n",
      "maxPairedFragmentLength: 1000\n"
     ]
    }
   ],
   "source": [
    "for i in `ls ../0_data/*.final.bam`\n",
    "do\n",
    "    name=${i%%.final.bam}\n",
    "    name=${name##*/}\n",
    "    echo $name\n",
    "\n",
    "    bamCoverage -bs 20 -p 50 -b $i -o ${name}_20_RPKM.bw --normalizeUsing RPKM\n",
    "    # bamCoverage -bs 20 -p 50 -b $i -o ${name}_20.bw --normalizeUsing None \n",
    "    bamCoverage -bs 20 -p 50 -b $i -o ${name}_20_RPKM.bdg --normalizeUsing RPKM --outFileFormat bedgraph\n",
    "    # bamCoverage -bs 20 -p 50 -b $i -o ${name}_20.bdg --normalizeUsing None --outFileFormat bedgraph\n",
    "done"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "310152ac-26c7-4226-9831-2ef228316c38",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:20:56.122675Z",
     "iopub.status.busy": "2025-11-13T07:20:56.122257Z",
     "iopub.status.idle": "2025-11-13T07:23:42.641540Z",
     "shell.execute_reply": "2025-11-13T07:23:42.640197Z",
     "shell.execute_reply.started": "2025-11-13T07:20:56.122642Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Skipping NM_001015101, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001015100, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001110584, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133555, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133555_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133555_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133554, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133554_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133554_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133553, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133553_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133550, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133550_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133550_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133549, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133549_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133559, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133559_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133559_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133558, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133562, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001110608, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_048533, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r10, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r10, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r10, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r10, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r11, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r11, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r11, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r11, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r12, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r12, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r12, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r12, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001144069_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r13, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r13, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r13, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r13, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001316662_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026600_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133547_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_125439_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026603_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026602_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_125438_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026605, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026612, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026627, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001110696, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026633, due to being absent in the computeMatrix output.\n",
      "Skipping NR_048534, due to being absent in the computeMatrix output.\n"
     ]
    }
   ],
   "source": [
    "computeMatrix scale-regions -p 50 -R '/home/share/chipRef/dm6_genes.bed' --missingDataAsZero -a 3000 -b 3000 -m 5000 -bs 20 -S './GFP_OE_20_RPKM.bw' './rox2_OE_20_RPKM.bw' --samplesLabel GFP-OE roX2-OE -o matrix.mat.gz\n",
    "plotHeatmap -m matrix.mat.gz -o heatmap_RPKM.png --colorMap coolwarm --heatmapHeight 12 --heatmapWidth 6 --perGroup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5f70af61-12da-4a19-b98d-8531a21256d2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:23:42.646170Z",
     "iopub.status.busy": "2025-11-13T07:23:42.645754Z",
     "iopub.status.idle": "2025-11-13T07:26:39.066663Z",
     "shell.execute_reply": "2025-11-13T07:26:39.065018Z",
     "shell.execute_reply.started": "2025-11-13T07:23:42.646139Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Skipping NM_001015101, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001015100, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001110584, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133555, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133555_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133555_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133554, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133554_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133554_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133553, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133553_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133550, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133550_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133550_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133549, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133549_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133559, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133559_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133559_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133558, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133562, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r2, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001110608, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_048533, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r3, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r7, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r10, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r10, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r10, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r10, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r11, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r11, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r11, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r4, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r11, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r8, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r12, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r12, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r12, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r5, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r12, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001144069_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133557_r13, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133556_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133552_r13, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133551_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133545_r13, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133560_r6, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133561_r13, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156799_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_156798_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163218_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163217_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NR_163216_r9, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001316662_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026600_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_133547_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_125439_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026603_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026602_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_125438_r1, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026605, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026612, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026627, due to being absent in the computeMatrix output.\n",
      "Skipping NM_001110696, due to being absent in the computeMatrix output.\n",
      "Skipping NR_026633, due to being absent in the computeMatrix output.\n",
      "Skipping NR_048534, due to being absent in the computeMatrix output.\n"
     ]
    }
   ],
   "source": [
    "computeMatrix scale-regions -p 50 -R '/home/share/chipRef/dm6_genes.bed' --missingDataAsZero -a 3000 -b 3000 -m 5000 -bs 20 -S '../0_data/GFP_OE_20.bw' '../0_data/rox2_OE_20.bw' --samplesLabel GFP-OE roX2-OE -o matrix.mat.gz\n",
    "plotHeatmap -m matrix.mat.gz -o heatmap.png --colorMap coolwarm --heatmapHeight 12 --heatmapWidth 6 --perGroup\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "93e6980f-e107-4fdf-a676-74141fe2c39f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:26:39.069507Z",
     "iopub.status.busy": "2025-11-13T07:26:39.069027Z",
     "iopub.status.idle": "2025-11-13T07:28:38.407941Z",
     "shell.execute_reply": "2025-11-13T07:28:38.406845Z",
     "shell.execute_reply.started": "2025-11-13T07:26:39.069467Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO  @ 13 Nov 2025 15:26:39: [44 MB] \n",
      "# Command line: callpeak -t ../0_data/GFP_OE.final.bam -g dm -n GFP_OE --shift -100 --extsize 200 --nomodel -B -f BAMPE\n",
      "# ARGUMENTS LIST:\n",
      "# name = GFP_OE\n",
      "# format = BAMPE\n",
      "# ChIP-seq file = ['../0_data/GFP_OE.final.bam']\n",
      "# control file = None\n",
      "# effective genome size = 1.43e+08\n",
      "# band width = 300\n",
      "# model fold = [5, 50]\n",
      "# qvalue cutoff = 5.00e-02\n",
      "# The maximum gap between significant sites is assigned as the read length/tag size.\n",
      "# The minimum length of peaks is assigned as the predicted fragment length \"d\".\n",
      "# Larger dataset will be scaled towards smaller dataset.\n",
      "# Range for calculating regional lambda is: 10000 bps\n",
      "# Broad region calling is off\n",
      "# Paired-End mode is on\n",
      " \n",
      "INFO  @ 13 Nov 2025 15:26:39: [44 MB] #1 read fragment files... \n",
      "INFO  @ 13 Nov 2025 15:26:39: [44 MB] #1 read treatment fragments... \n",
      "INFO  @ 13 Nov 2025 15:26:44: [83 MB]  1000000 fragments parsed \n",
      "INFO  @ 13 Nov 2025 15:26:48: [96 MB]  2000000 fragments parsed \n",
      "INFO  @ 13 Nov 2025 15:26:52: [104 MB]  3000000 fragments parsed \n",
      "INFO  @ 13 Nov 2025 15:26:56: [115 MB]  4000000 fragments parsed \n",
      "INFO  @ 13 Nov 2025 15:27:01: [118 MB]  5000000 fragments parsed \n",
      "INFO  @ 13 Nov 2025 15:27:05: [131 MB]  6000000 fragments parsed \n",
      "INFO  @ 13 Nov 2025 15:27:09: [139 MB]  7000000 fragments parsed \n",
      "INFO  @ 13 Nov 2025 15:27:10: [142 MB] 7328238 fragments have been read. \n",
      "INFO  @ 13 Nov 2025 15:27:16: [142 MB] #1 mean fragment size is determined as 154.7 bp from treatment \n",
      "INFO  @ 13 Nov 2025 15:27:16: [142 MB] #1 fragment size = 154.7 \n",
      "INFO  @ 13 Nov 2025 15:27:16: [142 MB] #1  total fragments in treatment: 7328238 \n",
      "INFO  @ 13 Nov 2025 15:27:16: [142 MB] #1 user defined the maximum fragments... \n",
      "INFO  @ 13 Nov 2025 15:27:16: [142 MB] #1 filter out redundant fragments by allowing at most 1 identical fragment(s) \n",
      "INFO  @ 13 Nov 2025 15:27:28: [142 MB] #1  fragments after filtering in treatment: 7326315 \n",
      "INFO  @ 13 Nov 2025 15:27:28: [142 MB] #1  Redundant rate of treatment: 0.00 \n",
      "INFO  @ 13 Nov 2025 15:27:28: [142 MB] #1 finished! \n",
      "INFO  @ 13 Nov 2025 15:27:28: [142 MB] #2 Build Peak Model... \n",
      "INFO  @ 13 Nov 2025 15:27:28: [142 MB] #2 Skipped... \n",
      "INFO  @ 13 Nov 2025 15:27:28: [142 MB] #3 Call peaks... \n",
      "INFO  @ 13 Nov 2025 15:27:28: [142 MB] #3 Pre-compute pvalue-qvalue table... \n",
      "INFO  @ 13 Nov 2025 15:27:54: [803 MB] #3 In the peak calling step, the following will be performed simultaneously: \n",
      "INFO  @ 13 Nov 2025 15:27:54: [803 MB] #3   Write bedGraph files for treatment pileup (after scaling if necessary)... GFP_OE_treat_pileup.bdg \n",
      "INFO  @ 13 Nov 2025 15:27:54: [803 MB] #3   Write bedGraph files for control lambda (after scaling if necessary)... GFP_OE_control_lambda.bdg \n",
      "INFO  @ 13 Nov 2025 15:27:54: [803 MB] #3   Pileup will be based on sequencing depth in treatment. \n",
      "INFO  @ 13 Nov 2025 15:27:54: [803 MB] #3 Call peaks for each chromosome... \n",
      "INFO  @ 13 Nov 2025 15:28:25: [803 MB] #4 Write output xls file... GFP_OE_peaks.xls \n",
      "INFO  @ 13 Nov 2025 15:28:25: [803 MB] #4 Write peak in narrowPeak format file... GFP_OE_peaks.narrowPeak \n",
      "INFO  @ 13 Nov 2025 15:28:25: [803 MB] #4 Write summits bed file... GFP_OE_summits.bed \n",
      "INFO  @ 13 Nov 2025 15:28:25: [803 MB] Done! \n",
      "INFO  @ 13 Nov 2025 15:28:26: [44 MB] \n",
      "# Command line: callpeak -t ../0_data/rox2_OE.final.bam -g dm -n roX2_OE --shift -100 --extsize 200 --nomodel -B -f BAMPE\n",
      "# ARGUMENTS LIST:\n",
      "# name = roX2_OE\n",
      "# format = BAMPE\n",
      "# ChIP-seq file = ['../0_data/rox2_OE.final.bam']\n",
      "# control file = None\n",
      "# effective genome size = 1.43e+08\n",
      "# band width = 300\n",
      "# model fold = [5, 50]\n",
      "# qvalue cutoff = 5.00e-02\n",
      "# The maximum gap between significant sites is assigned as the read length/tag size.\n",
      "# The minimum length of peaks is assigned as the predicted fragment length \"d\".\n",
      "# Larger dataset will be scaled towards smaller dataset.\n",
      "# Range for calculating regional lambda is: 10000 bps\n",
      "# Broad region calling is off\n",
      "# Paired-End mode is on\n",
      " \n",
      "INFO  @ 13 Nov 2025 15:28:26: [44 MB] #1 read fragment files... \n",
      "INFO  @ 13 Nov 2025 15:28:26: [44 MB] #1 read treatment fragments... \n",
      "INFO  @ 13 Nov 2025 15:28:30: [84 MB] 843600 fragments have been read. \n",
      "INFO  @ 13 Nov 2025 15:28:30: [84 MB] #1 mean fragment size is determined as 175.2 bp from treatment \n",
      "INFO  @ 13 Nov 2025 15:28:30: [84 MB] #1 fragment size = 175.2 \n",
      "INFO  @ 13 Nov 2025 15:28:30: [84 MB] #1  total fragments in treatment: 843600 \n",
      "INFO  @ 13 Nov 2025 15:28:30: [84 MB] #1 user defined the maximum fragments... \n",
      "INFO  @ 13 Nov 2025 15:28:30: [84 MB] #1 filter out redundant fragments by allowing at most 1 identical fragment(s) \n",
      "INFO  @ 13 Nov 2025 15:28:31: [84 MB] #1  fragments after filtering in treatment: 815963 \n",
      "INFO  @ 13 Nov 2025 15:28:31: [84 MB] #1  Redundant rate of treatment: 0.03 \n",
      "INFO  @ 13 Nov 2025 15:28:31: [84 MB] #1 finished! \n",
      "INFO  @ 13 Nov 2025 15:28:31: [84 MB] #2 Build Peak Model... \n",
      "INFO  @ 13 Nov 2025 15:28:31: [84 MB] #2 Skipped... \n",
      "INFO  @ 13 Nov 2025 15:28:31: [84 MB] #3 Call peaks... \n",
      "INFO  @ 13 Nov 2025 15:28:31: [84 MB] #3 Pre-compute pvalue-qvalue table... \n",
      "INFO  @ 13 Nov 2025 15:28:35: [147 MB] #3 In the peak calling step, the following will be performed simultaneously: \n",
      "INFO  @ 13 Nov 2025 15:28:35: [147 MB] #3   Write bedGraph files for treatment pileup (after scaling if necessary)... roX2_OE_treat_pileup.bdg \n",
      "INFO  @ 13 Nov 2025 15:28:35: [147 MB] #3   Write bedGraph files for control lambda (after scaling if necessary)... roX2_OE_control_lambda.bdg \n",
      "INFO  @ 13 Nov 2025 15:28:35: [147 MB] #3   Pileup will be based on sequencing depth in treatment. \n",
      "INFO  @ 13 Nov 2025 15:28:35: [147 MB] #3 Call peaks for each chromosome... \n",
      "INFO  @ 13 Nov 2025 15:28:38: [147 MB] #4 Write output xls file... roX2_OE_peaks.xls \n",
      "INFO  @ 13 Nov 2025 15:28:38: [147 MB] #4 Write peak in narrowPeak format file... roX2_OE_peaks.narrowPeak \n",
      "INFO  @ 13 Nov 2025 15:28:38: [147 MB] #4 Write summits bed file... roX2_OE_summits.bed \n",
      "INFO  @ 13 Nov 2025 15:28:38: [147 MB] Done! \n"
     ]
    }
   ],
   "source": [
    "macs3 callpeak  -t '../0_data/GFP_OE.final.bam'  -g dm -n GFP_OE --shift -100 --extsize 200 --nomodel -B -f BAMPE \n",
    "macs3 callpeak  -t '../0_data/rox2_OE.final.bam' -g dm -n roX2_OE --shift -100 --extsize 200 --nomodel -B -f BAMPE "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1c1af458-ed18-4a0c-af3a-c6f1f1934874",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:28:38.410066Z",
     "iopub.status.busy": "2025-11-13T07:28:38.409625Z",
     "iopub.status.idle": "2025-11-13T07:28:38.518585Z",
     "shell.execute_reply": "2025-11-13T07:28:38.517569Z",
     "shell.execute_reply.started": "2025-11-13T07:28:38.410032Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  21337 GFP_OE_peaks.narrowPeak\n",
      "   2070 roX2_OE_peaks.narrowPeak\n",
      "  23407 总计\n"
     ]
    }
   ],
   "source": [
    "wc -l *narrowPeak"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ad814e3c-72b1-4841-91fb-f2077cba359d",
   "metadata": {},
   "source": [
    "# FRiP"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "f93ef977-119e-4f36-b2be-eb9fe26676a2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:28:38.520404Z",
     "iopub.status.busy": "2025-11-13T07:28:38.519976Z",
     "iopub.status.idle": "2025-11-13T07:29:44.633315Z",
     "shell.execute_reply": "2025-11-13T07:29:44.632033Z",
     "shell.execute_reply.started": "2025-11-13T07:28:38.520371Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GFP_OE: 24.22 %\n"
     ]
    }
   ],
   "source": [
    "total=$(samtools view -c ../0_data/GFP_OE.final.bam)\n",
    "peak=$(bedtools sort -i ./GFP_OE_peaks.narrowPeak | bedtools merge -i stdin | bedtools intersect -u -nonamecheck -a ../0_data/GFP_OE.final.bam -b stdin -ubam | samtools view -c)\n",
    "frip=$(bc<<<\"scale=2;100*$peak/$total\")\n",
    "echo \"GFP_OE: $frip %\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "dd3a27f0-7bb4-4e04-b815-846142c7f5d4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:29:44.635403Z",
     "iopub.status.busy": "2025-11-13T07:29:44.634961Z",
     "iopub.status.idle": "2025-11-13T07:29:52.100558Z",
     "shell.execute_reply": "2025-11-13T07:29:52.099353Z",
     "shell.execute_reply.started": "2025-11-13T07:29:44.635370Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "roX2_OE: 16.24 %\n"
     ]
    }
   ],
   "source": [
    "total=$(samtools view -c ../0_data/rox2_OE.final.bam)\n",
    "peak=$(bedtools sort -i ./roX2_OE_peaks.narrowPeak | bedtools merge -i stdin | bedtools intersect -u -nonamecheck -a ../0_data/rox2_OE.final.bam -b stdin -ubam | samtools view -c)\n",
    "frip=$(bc<<<\"scale=2;100*$peak/$total\")\n",
    "echo \"roX2_OE: $frip %\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d5100c15-69ba-47df-8a53-d0b00c915c72",
   "metadata": {},
   "source": [
    "# filter peak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1f0c62fa-0c7b-4df1-9644-a39ab9dae9ae",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:29:52.102553Z",
     "iopub.status.busy": "2025-11-13T07:29:52.102118Z",
     "iopub.status.idle": "2025-11-13T07:30:05.518731Z",
     "shell.execute_reply": "2025-11-13T07:30:05.517561Z",
     "shell.execute_reply.started": "2025-11-13T07:29:52.102519Z"
    }
   },
   "outputs": [],
   "source": [
    "awk 'BEGIN {OFS=\"\\t\"} {print $1, $2, $3, \"\", $4}' ../0_data/GFP_OE_norm.bedgraph| awk '$4 >= 50' > GFP_OE_check.bed\n",
    "awk 'BEGIN {OFS=\"\\t\"} {print $1, $2, $3, \"\", $4}' ../0_data/rox2_OE_norm.bedgraph| awk '$4 >= 50' > roX2_OE_check.bed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "9885af96-f2fd-4fbe-914a-206e5504e812",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:30:05.520556Z",
     "iopub.status.busy": "2025-11-13T07:30:05.520160Z",
     "iopub.status.idle": "2025-11-13T07:30:27.195152Z",
     "shell.execute_reply": "2025-11-13T07:30:27.193841Z",
     "shell.execute_reply.started": "2025-11-13T07:30:05.520526Z"
    }
   },
   "outputs": [],
   "source": [
    "intersectBed -a ./GFP_OE_peaks.narrowPeak -b ./GFP_OE_check.bed -wa |sort | uniq > GFP_OE.filteredPeak\n",
    "intersectBed -a ./roX2_OE_peaks.narrowPeak -b ./roX2_OE_check.bed -wa |sort | uniq > roX2_OE.filteredPeak"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b362bb61-41f9-45af-af79-3c055eb5a1e9",
   "metadata": {},
   "source": [
    "# diff peak by macs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "0cb3fced-bca3-4c71-84ad-b7af97d0bd43",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:30:27.197270Z",
     "iopub.status.busy": "2025-11-13T07:30:27.196828Z",
     "iopub.status.idle": "2025-11-13T07:31:49.375397Z",
     "shell.execute_reply": "2025-11-13T07:31:49.374224Z",
     "shell.execute_reply.started": "2025-11-13T07:30:27.197234Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO  @ 13 Nov 2025 15:30:27: [43 MB] Read and build treatment 1 bedGraph... \n",
      "INFO  @ 13 Nov 2025 15:30:40: [134 MB] Read and build control 1 bedGraph... \n",
      "INFO  @ 13 Nov 2025 15:30:56: [251 MB] Read and build treatment 2 bedGraph... \n",
      "INFO  @ 13 Nov 2025 15:30:58: [262 MB] Read and build control 2 bedGraph... \n",
      "INFO  @ 13 Nov 2025 15:31:49: [858 MB] Write peaks... \n",
      "INFO  @ 13 Nov 2025 15:31:49: [858 MB] Done \n"
     ]
    }
   ],
   "source": [
    "macs3 bdgdiff --t1 ./GFP_OE_treat_pileup.bdg --c1 ./GFP_OE_control_lambda.bdg --t2 ./roX2_OE_treat_pileup.bdg --c2 ./roX2_OE_control_lambda.bdg --o-prefix diffpeak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "297abed1-d456-489a-9f90-1e9cb60be1e8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:31:49.377349Z",
     "iopub.status.busy": "2025-11-13T07:31:49.376951Z",
     "iopub.status.idle": "2025-11-13T07:32:04.616624Z",
     "shell.execute_reply": "2025-11-13T07:32:04.615360Z",
     "shell.execute_reply.started": "2025-11-13T07:31:49.377319Z"
    }
   },
   "outputs": [],
   "source": [
    "intersectBed -a ./diffpeak_c3.0_cond1.bed -b ./GFP_OE_check.bed -wa |sort |uniq > GFP_OE_high.filteredPeak\n",
    "intersectBed -a ./diffpeak_c3.0_cond2.bed -b ./roX2_OE_check.bed -wa |sort |uniq > roX2_OE_high.filteredPeak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "b602c787-85b2-4c62-9ffd-e7ec1e16f4c0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:32:04.618641Z",
     "iopub.status.busy": "2025-11-13T07:32:04.618204Z",
     "iopub.status.idle": "2025-11-13T07:33:05.164897Z",
     "shell.execute_reply": "2025-11-13T07:33:05.163640Z",
     "shell.execute_reply.started": "2025-11-13T07:32:04.618607Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\tPeak file = ./GFP_OE_high.filteredPeak\n",
      "\tGenome = mm10\n",
      "\tOrganism = mouse\n",
      "\tPeak/BED file conversion summary:\n",
      "\t\tBED/Header formatted lines: 7154\n",
      "\t\tpeakfile formatted lines: 0\n",
      "\t\tDuplicated Peak IDs: 0\n",
      "\n",
      "\tPeak File Statistics:\n",
      "\t\tTotal Peaks: 7154\n",
      "\t\tRedundant Peak IDs: 0\n",
      "\t\tPeaks lacking information: 0 (need at least 5 columns per peak)\n",
      "\t\tPeaks with misformatted coordinates: 0 (should be integer)\n",
      "\t\tPeaks with misformatted strand: 0 (should be either +/- or 0/1)\n",
      "\n",
      "\tPeak file looks good!\n",
      "\n",
      "\tReading Positions...\n",
      "\t-----------------------\n",
      "\toffset=0\n",
      "\tFinding Closest TSS...\n",
      "\tAnnotating:...\n",
      "\t\tAnnotation\tNumber of peaks\tTotal size (bp)\tLog2 Ratio (obs/exp)\tLogP enrichment (+values depleted)\n",
      "\t\t3UTR\t4.0\t2261924\t-0.814\t1.776\n",
      "\t\tmiRNA\t0.0\t1572\t-0.007\t0.005\n",
      "\t\tncRNA\t0.0\t440273\t-1.245\t1.369\n",
      "\t\tTTS\t17.0\t3209804\t0.769\t-3.647\n",
      "\t\tpseudo\t1.0\t112683\t1.513\t-1.219\n",
      "\t\tExon\t12.0\t3597618\t0.102\t-0.815\n",
      "\t\tIntron\t210.0\t104460498\t-0.629\t32.352\n",
      "\t\tIntergenic\t1043.0\t299951322\t0.162\t-27.584\n",
      "\t\tPromoter\t11.0\t3534405\t0.002\t-0.618\n",
      "\t\t5UTR\t1.0\t295082\t0.125\t-0.510\n",
      "\tNOTE: If this part takes more than 2 minutes, there is a good chance\n",
      "\t\tyour machine ran out of memory: consider hitting ctrl+C and rerunning\n",
      "\t\tthe command with \"-noann\"\n",
      "\tTo capture annotation stats in a file, use \"-annStats <filename>\" next time\n",
      "\tAnnotating:...\n",
      "\t\tAnnotation\tNumber of peaks\tTotal size (bp)\tLog2 Ratio (obs/exp)\tLogP enrichment (+values depleted)\n",
      "\t\t3UTR\t4.0\t2261924\t-0.813\t1.773\n",
      "\t\tOther\t2.0\t1955102\t-1.603\t2.842\n",
      "\t\tRC?\t0.0\t1630\t-0.007\t0.005\n",
      "\t\tRNA\t0.0\t14251\t-0.063\t0.044\n",
      "\t\tmiRNA\t0.0\t1572\t-0.007\t0.005\n",
      "\t\tncRNA\t0.0\t440273\t-1.244\t1.369\n",
      "\t\tTTS\t17.0\t3209804\t0.769\t-3.651\n",
      "\t\tLINE\t335.0\t111932786\t-0.054\t1.507\n",
      "\t\tLINE?\t0.0\t676\t-0.003\t0.002\n",
      "\t\tsrpRNA\t0.0\t5924\t-0.026\t0.018\n",
      "\t\tSINE\t77.0\t25041054\t-0.015\t0.708\n",
      "\t\tRC\t0.0\t8253\t-0.037\t0.026\n",
      "\t\ttRNA\t0.0\t32296\t-0.138\t0.100\n",
      "\t\tDNA?\t0.0\t17074\t-0.075\t0.053\n",
      "\t\tpseudo\t1.0\t112683\t1.514\t-1.219\n",
      "\t\tDNA\t17.0\t3488124\t0.650\t-3.007\n",
      "\t\tExon\t12.0\t3597618\t0.102\t-0.816\n",
      "\t\tIntron\t124.0\t61231934\t-0.618\t17.457\n",
      "\t\tIntergenic\t506.0\t128425146\t0.343\t-22.457\n",
      "\t\tPromoter\t11.0\t3534405\t0.002\t-0.619\n",
      "\t\t5UTR\t1.0\t295082\t0.125\t-0.510\n",
      "\t\tLTR?\t0.0\t25957\t-0.112\t0.081\n",
      "\t\tscRNA\t0.0\t99626\t-0.389\t0.310\n",
      "\t\tCpG-Island\t0.0\t344607\t-1.051\t1.071\n",
      "\t\tLow_complexity\t5.0\t2951732\t-0.875\t2.255\n",
      "\t\tLTR\t175.0\t58417076\t-0.053\t1.145\n",
      "\t\tSimple_repeat\t11.0\t8091972\t-1.193\t6.725\n",
      "\t\tsnRNA\t0.0\t32747\t-0.140\t0.102\n",
      "\t\tUnknown\t1.0\t1294779\t-2.008\t2.413\n",
      "\t\tSINE?\t0.0\t4205\t-0.019\t0.013\n",
      "\t\tSatellite\t0.0\t1200921\t-2.245\t3.737\n",
      "\t\trRNA\t0.0\t24604\t-0.106\t0.076\n",
      "\tCounting Tags in Peaks from each directory...\n",
      "\tOrganism: mouse\n",
      "\tLoading Gene Informaiton...\n",
      "\tOutputing Annotation File...\n",
      "\tDone annotating peaks file\n",
      "\n",
      "\n",
      "\tPeak file = ./roX2_OE_high.filteredPeak\n",
      "\tGenome = mm10\n",
      "\tOrganism = mouse\n",
      "\tPeak/BED file conversion summary:\n",
      "\t\tBED/Header formatted lines: 2\n",
      "\t\tpeakfile formatted lines: 0\n",
      "\t\tDuplicated Peak IDs: 0\n",
      "\n",
      "\tPeak File Statistics:\n",
      "\t\tTotal Peaks: 2\n",
      "\t\tRedundant Peak IDs: 0\n",
      "\t\tPeaks lacking information: 0 (need at least 5 columns per peak)\n",
      "\t\tPeaks with misformatted coordinates: 0 (should be integer)\n",
      "\t\tPeaks with misformatted strand: 0 (should be either +/- or 0/1)\n",
      "\n",
      "\tPeak file looks good!\n",
      "\n",
      "\tReading Positions...\n",
      "\t-----------------------\n",
      "\toffset=0\n",
      "\tFinding Closest TSS...\n",
      "\tAnnotating:.\n",
      "\t\tAnnotation\tNumber of peaks\tTotal size (bp)\tLog2 Ratio (obs/exp)\tLogP enrichment (+values depleted)\n",
      "\t\t3UTR\t0.0\t912091\t-0.008\t0.005\n",
      "\t\tmiRNA\t0.0\t1565\t-0.000\t0.000\n",
      "\t\tncRNA\t0.0\t176408\t-0.001\t0.001\n",
      "\t\tTTS\t0.0\t1271936\t-0.011\t0.007\n",
      "\t\tpseudo\t0.0\t49137\t-0.000\t0.000\n",
      "\t\tExon\t0.0\t1345645\t-0.011\t0.008\n",
      "\t\tIntron\t0.0\t42814874\t-0.417\t0.289\n",
      "\t\tIntergenic\t1.0\t122614479\t0.477\t-0.331\n",
      "\t\tPromoter\t0.0\t1381821\t-0.012\t0.008\n",
      "\t\t5UTR\t0.0\t113196\t-0.001\t0.001\n",
      "\tNOTE: If this part takes more than 2 minutes, there is a good chance\n",
      "\t\tyour machine ran out of memory: consider hitting ctrl+C and rerunning\n",
      "\t\tthe command with \"-noann\"\n",
      "\tTo capture annotation stats in a file, use \"-annStats <filename>\" next time\n",
      "\tAnnotating:.\n",
      "\t\tAnnotation\tNumber of peaks\tTotal size (bp)\tLog2 Ratio (obs/exp)\tLogP enrichment (+values depleted)\n",
      "\t\t3UTR\t0.0\t912091\t-0.008\t0.005\n",
      "\t\tOther\t0.0\t680155\t-0.006\t0.004\n",
      "\t\tRC?\t0.0\t551\t-0.000\t0.000\n",
      "\t\tRNA\t0.0\t7041\t-0.000\t0.000\n",
      "\t\tmiRNA\t0.0\t1565\t-0.000\t0.000\n",
      "\t\tncRNA\t0.0\t176408\t-0.001\t0.001\n",
      "\t\tTTS\t0.0\t1271936\t-0.011\t0.007\n",
      "\t\tLINE\t0.0\t58384850\t-0.603\t0.418\n",
      "\t\tLINE?\t0.0\t252\t-0.000\t0.000\n",
      "\t\tsrpRNA\t0.0\t2237\t-0.000\t0.000\n",
      "\t\tSINE\t0.0\t9603004\t-0.083\t0.058\n",
      "\t\tRC\t0.0\t3592\t-0.000\t0.000\n",
      "\t\ttRNA\t0.0\t16844\t-0.000\t0.000\n",
      "\t\tDNA?\t0.0\t9487\t-0.000\t0.000\n",
      "\t\tpseudo\t0.0\t49137\t-0.000\t0.000\n",
      "\t\tDNA\t0.0\t1615643\t-0.014\t0.009\n",
      "\t\tExon\t0.0\t1345645\t-0.011\t0.008\n",
      "\t\tIntron\t0.0\t23504225\t-0.213\t0.148\n",
      "\t\tIntergenic\t1.0\t46586251\t1.875\t-1.300\n",
      "\t\tPromoter\t0.0\t1381821\t-0.012\t0.008\n",
      "\t\t5UTR\t0.0\t113196\t-0.001\t0.001\n",
      "\t\tLTR?\t0.0\t13679\t-0.000\t0.000\n",
      "\t\tscRNA\t0.0\t35595\t-0.000\t0.000\n",
      "\t\tCpG-Island\t0.0\t100760\t-0.001\t0.001\n",
      "\t\tLow_complexity\t0.0\t1019307\t-0.009\t0.006\n",
      "\t\tLTR\t0.0\t21103798\t-0.190\t0.132\n",
      "\t\tSimple_repeat\t0.0\t2623670\t-0.022\t0.015\n",
      "\t\tsnRNA\t0.0\t16730\t-0.000\t0.000\n",
      "\t\tUnknown\t0.0\t89653\t-0.001\t0.001\n",
      "\t\tSINE?\t0.0\t1305\t-0.000\t0.000\n",
      "\t\tSatellite\t0.0\t199408\t-0.002\t0.001\n",
      "\t\trRNA\t0.0\t17021\t-0.000\t0.000\n",
      "\tCounting Tags in Peaks from each directory...\n",
      "\tOrganism: mouse\n",
      "\tLoading Gene Informaiton...\n",
      "\tOutputing Annotation File...\n",
      "\tDone annotating peaks file\n",
      "\n"
     ]
    }
   ],
   "source": [
    "annotatePeaks.pl ./GFP_OE_high.filteredPeak mm10 > GFP_high.csv\n",
    "annotatePeaks.pl ./roX2_OE_high.filteredPeak mm10 > roX2_high.csv"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4aa60b93-dfa7-429f-8068-4f8dbc80fd92",
   "metadata": {},
   "source": [
    "# package Version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c39cedef-d1f1-4925-85e9-ad6bc2bd04f8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-11-13T07:33:05.694780Z",
     "iopub.status.busy": "2025-11-13T07:33:05.694363Z",
     "iopub.status.idle": "2025-11-13T07:33:07.799690Z",
     "shell.execute_reply": "2025-11-13T07:33:07.798616Z",
     "shell.execute_reply.started": "2025-11-13T07:33:05.694748Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fastp 0.23.4\n",
      "\n",
      "/home/yhli/miniconda3/bin/bowtie2-align-s version 2.5.4 64-bit Built on fv-az356-861 Tue Jun 11 00:21:46 UTC 2024 Compiler: gcc version 12.3.0 (conda-forge gcc 12.3.0-7) Options: -O3 -msse2 -funroll-loops -g3 -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/yhli/miniconda3/include -fdebug-prefix-map=/opt/conda/conda-bld/bowtie2_1718065018344/work=/usr/local/src/conda/bowtie2-2.5.4 -fdebug-prefix-map=/home/yhli/miniconda3=/usr/local/src/conda-prefix -O3 Sizeof {int, long, long long, void*, size_t, off_t}: {4, 8, 8, 8, 8, 8}\n",
      "samtools 1.20 Using htslib 1.20 Copyright (C) 2024 Genome Research Ltd. Samtools compilation details: Features: build=configure curses=yes CC: /opt/conda/conda-bld/samtools_1720645213030/_build_env/bin/x86_64-conda-linux-gnu-cc CPPFLAGS: -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/yhli/miniconda3/include CFLAGS: -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/yhli/miniconda3/include -fdebug-prefix-map=/opt/conda/conda-bld/samtools_1720645213030/work=/usr/local/src/conda/samtools-1.20 -fdebug-prefix-map=/home/yhli/miniconda3=/usr/local/src/conda-prefix LDFLAGS: -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/yhli/miniconda3/lib -Wl,-rpath-link,/home/yhli/miniconda3/lib -L/home/yhli/miniconda3/lib HTSDIR: LIBS: CURSES_LIB: -ltinfow -lncursesw HTSlib compilation details: Features: build=configure libcurl=yes S3=yes GCS=yes libdeflate=yes lzma=yes bzip2=yes plugins=yes plugin-path=/home/yhli/miniconda3/libexec/htslib htscodecs=1.6.0 CC: /opt/conda/conda-bld/htslib_1720639468368/_build_env/bin/x86_64-conda-linux-gnu-cc CPPFLAGS: -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/yhli/miniconda3/include CFLAGS: -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/yhli/miniconda3/include -fdebug-prefix-map=/opt/conda/conda-bld/htslib_1720639468368/work=/usr/local/src/conda/htslib-1.20 -fdebug-prefix-map=/home/yhli/miniconda3=/usr/local/src/conda-prefix -fvisibility=hidden LDFLAGS: -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/yhli/miniconda3/lib -Wl,-rpath-link,/home/yhli/miniconda3/lib -L/home/yhli/miniconda3/lib -fvisibility=hidden -rdynamic HTSlib URL scheme handlers present: built-in: preload, data, file libcurl: imaps, pop3, gophers, http, smb, gopher, sftp, ftps, imap, smtp, wss, ws, smtps, rtsp, scp, ftp, telnet, mqtt, https, smbs, tftp, pop3s, dict Google Cloud Storage: gs+http, gs+https, gs Amazon S3: s3+https, s3+http, s3 S3 Multipart Upload: s3w, s3w+https, s3w+http crypt4gh-needed: crypt4gh mem: mem\n",
      "\n",
      "sambamba 1.0.1\n",
      " by Artem Tarasov and Pjotr Prins (C) 2012-2023\n",
      "    LDC 1.38.0 / DMD v2.108.1 / LLVM17.0.6 / bootstrap LDC - the LLVM D compiler (1.38.0)\n",
      "\n",
      "\n",
      "sambamba 1.0.1\n",
      " by Artem Tarasov and Pjotr Prins (C) 2012-2023\n",
      "    LDC 1.38.0 / DMD v2.108.1 / LLVM17.0.6 / bootstrap LDC - the LLVM D compiler (1.38.0)\n",
      "\n",
      "\n",
      "bedtools v2.31.1\n",
      "FastQC v0.12.1\n",
      "multiqc, version 1.17\n",
      "macs3 3.0.2\n",
      "deeptools 3.5.5\n",
      "homer : Empirical Motif Optimizer\n",
      "usage: ./homer [data] [parameters] -a [action]\n",
      "This program is meant to be called from other programs (i.e. findMotifsGenome.pl), and not used directly\n",
      "Data options:\n",
      "\t-dna|-prot : Sequence type (-dna)\n",
      "\t-s <file> : Sequence File\n",
      "\t-g <file> : Group/Stat File\n",
      "\t-mer <file> : Mer File\n",
      "\t-m <file> : PSSM Motif File\n",
      "\t-o <file> : output file prefix\n",
      "\t-seed <file> : seed file\n",
      "\t-offset <#> : offset of sequence from TSS (-2000)\n",
      "Parameter options:\n",
      "\t-exact : remember mapping between mers and genes (default: approx)\n",
      "\t-w : Weight sequences (according to addition columns in group file: 1st-gene 2nd-sequence)\n",
      "\t-T : Test all sequences as candidate motifs (default: only test target sequences)\n",
      "\t-noautoscale : Do not autoscale sequences to be equal in foreground and background\n",
      "\t-freqAdjust : Compute log-odds using frequency, default (0.25)\n",
      "\t-dual : find dual motifs in the form A<gap>B where A and B can be rev-opposites\n",
      "\t-flip : find dual motifs in the form A<gap>B or B<gap>A\n",
      "\t-zoopsapprox <OFF,#(max to count)> : (counts multiple motifs per sequence | default: 2)\n",
      "\t-norevopp : don't search opposite strand (default->DNA:yes, Protein:no)\n",
      "\t-min <#> : min mer size (6)\n",
      "\t-max <#> : max mer size [also standard mer size] (10)\n",
      "\t-len <#> : Find motifs of length # (default=10)\n",
      "\t-gap <#,#,#-#> : Find motifs with gaps(0)(i.e. -gap 3 -gap 2,4,5 -gap 1-10\n",
      "\t    Gaps will only be in the center of motif and will only use even lengthed motifs\n",
      "\t-mis <#> : # of mismatches to check for degeneracy (1)\n",
      "\t-IUPAC <#> : # of IUPAC codes per mer that can be used during global optimization (0)\n",
      "\t-iupactype <1,2,or3> : Type of IUPAC symbols used\n",
      "\t\t1: (default) Only N is used\n",
      "\t\t2: Only N and 2 bp symbols are used (i.e. R = A or G\n",
      "\t\t3: Full IUPAC code is used (includes 3-way symbols)\n",
      "\t-S <#> : number of seeds to check during profile optimization(50)\n",
      "\t-branch <#> : sets depth of optimization (closer to zero the more sensitive (0.5))\n",
      "\t-I <#> : maximum number of iterations during optimization (5)\n",
      "\t-rmalign : DO NOT remove aligned seeds\n",
      "\t-maxneg <0 to 1> maximum percentage of negative genes that can contain the motif\n",
      "\t-speed <NORMAL|FAST>: Program will heuristically avoid performing exhaustive\n",
      "\t    calculations (default: FAST)\n",
      "Scoring Functions:\n",
      "\t-alg <method> : scoring algorithm (default: hypergeo)\n",
      "\t    hypergeo - hypergeometric scoring (ZOOPS)\n",
      "\t    binomial - binomical scoring [for variable length seq] (ZOOPS) (requires exact)\n",
      "\t    approxbinomial - binomical scoring [for variable length seq] (ZOOPS) (requires exact)\n",
      "\t    sitehypergeo - hypergeometric scoring across seq positions (very slow)\n",
      "\t    sitebinomial - binomial scoring across seq positions\n",
      "\t    fisher <#> - fisher exact test (slow, # scales exponentially)\n",
      "\t      <# = largest repetition to consider [default=2]>\n",
      "\t    rank - group file must have sortable numeric value\n",
      "\t    freqdiff - used by most bayesian/nnet programs\n",
      "\t    logit - used by most bayesian/nnet programs\n",
      "Background Modeling options (this forces a binomial style scoring function):\n",
      "\t-b <method> [method options...]\n",
      "\t    markov <#> - generate hmm from target sequences using a hmm of order #\n",
      "\t    bmarkov <#> - generate hmm from background sequences using a hmm of order #\n",
      "\t    mosaic - generate mosaic hmm from background sequences **coming soon**\n",
      "Filter Options:\n",
      "\t-N <float> : filtering cutoff for ratio of N's in sequence (0.9)\n",
      "\t-seqless <#> : filter sequences shorter than #\n",
      "\t-seqmore <#> : filter sequences longer than #\n",
      "Actions (-a):\n",
      "\tMOTIFS - Find motifs <outfile>.motifs# where # = motif length\n",
      "\tMERS - Create mer file (low memory) <stdout>\n",
      "\tDMERS - Create degenerate mer file <stdout>\n",
      "\tFIND - find motifs in sequence <stdout>\n",
      "\tOPTPVALUE - optimize motif threshold and pvalue (exact)<stdout>\n",
      "\tGETPVALUE - get the p-value enrichment for a given motif(exact)<stdout>\n",
      "\tGENESCORE - returns highest motif score for each gene <stdout>\n",
      "\tREFINE - optimize motif PSSM profile, threshold, and pvalue <stdout>\n",
      "\tREFINETHRESH - optimize motif PSSM threshold and pvalue <stdout>\n",
      "\tCLUSTER - cluster mers from seed file (can't use exact scoring) <outfile>\n",
      "\tSORTMERS - sort a mer file according to pvalue <stdout>\n",
      "\tREMOVE - removes motif from sequence (replaces with N's) <stdout>\n",
      "\n",
      "This program is meant to be called from other programs (i.e. findMotifsGenome.pl), and not used directly\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "echo `fastp --version`\n",
    "echo `bowtie2 --version`\n",
    "echo `samtools --version`\n",
    "echo `sambamba --version`\n",
    "echo `bedtools --version`\n",
    "echo `fastqc --version`\n",
    "echo `multiqc --version`\n",
    "echo `macs3 --version`\n",
    "echo `deeptools --version`\n",
    "echo `homer --version`"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c46b59e5-5bdf-4011-9914-137d0ea34b1a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-13T06:17:03.494830Z",
     "iopub.status.busy": "2025-01-13T06:17:03.494311Z",
     "iopub.status.idle": "2025-01-13T06:17:03.805686Z",
     "shell.execute_reply": "2025-01-13T06:17:03.804013Z",
     "shell.execute_reply.started": "2025-01-13T06:17:03.494798Z"
    }
   },
   "source": [
    "# Citations\n",
    "\n",
    "---\n",
    "fastp \n",
    "> Shifu Chen. 2023. Ultrafast one-pass FASTQ data preprocessing, quality control, and deduplication using fastp. iMeta 2: e107. https://doi.org/10.1002/imt2.107\n",
    "\n",
    "> Shifu Chen, Yanqing Zhou, Yaru Chen, Jia Gu; fastp: an ultra-fast all-in-one FASTQ preprocessor, Bioinformatics, Volume 34, Issue 17, 1 September 2018, Pages i884–i890, https://doi.org/10.1093/bioinformatics/bty560\n",
    "\n",
    "multiqc\n",
    "> Ewels P, Magnusson M, Lundin S, Käller M. MultiQC: summarize analysis results for multiple tools and samples in a single report. Bioinformatics. 2016;32(19):3047-3048. doi:10.1093/bioinformatics/btw354\n",
    "\n",
    "bowtie2\n",
    "> Langmead, B., Salzberg, S. Fast gapped-read alignment with Bowtie 2. Nat Methods 9, 357–359 (2012). https://doi.org/10.1038/nmeth.1923\n",
    "\n",
    "samtools\n",
    "> Li H, Handsaker B, Wysoker A, et al. The Sequence Alignment/Map format and SAMtools. Bioinformatics. 2009;25(16):2078-2079. doi:10.1093/bioinformatics/btp352\n",
    "\n",
    "sambamba\n",
    ">  Tarasov A, Vilella AJ, Cuppen E, Nijman IJ, Prins P. Sambamba: fast processing of NGS alignment formats. Bioinformatics. 2015;31(12):2032-2034. doi:10.1093/bioinformatics/btv098\n",
    "\n",
    "bedtools\n",
    "> Quinlan AR, Hall IM. BEDTools: a flexible suite of utilities for comparing genomic features. Bioinformatics. 2010;26(6):841-842. doi:10.1093/bioinformatics/btq033\n",
    "\n",
    "hg38-blacklist.v2\n",
    "> Amemiya, H.M., Kundaje, A. & Boyle, A.P. The ENCODE Blacklist: Identification of Problematic Regions of the Genome. Sci Rep 9, 9354 (2019). https://doi.org/10.1038/s41598-019-45839-z\n",
    "\n",
    "macs3\n",
    "> Zhang, Y., Liu, T., Meyer, C.A. et al. Model-based Analysis of ChIP-Seq (MACS). Genome Biol 9, R137 (2008). https://doi.org/10.1186/gb-2008-9-9-r137\n",
    "\n",
    "deeptools\n",
    "> Ramírez F, Ryan DP, Grüning B, et al. deepTools2: a next generation web server for deep-sequencing data analysis. Nucleic Acids Res. 2016;44(W1):W160-W165. doi:10.1093/nar/gkw257\n",
    "\n",
    "meme Suite\n",
    "> Bailey TL, Johnson J, Grant CE, Noble WS. The MEME Suite. Nucleic Acids Res. 2015;43(W1):W39-W49. doi:10.1093/nar/gkv416\n",
    "\n",
    "WashU Epigenome browser\n",
    "> Li D, Purushotham D, Harrison JK, et al. WashU Epigenome Browser update 2022. Nucleic Acids Res. 2022;50(W1):W774-W781. doi:10.1093/nar/gkac238\n",
    "\n",
    "> https://epigenomegateway.wustl.edu/browser/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b402563-4356-41ba-acce-0dcf45df7405",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b82c91da-ef29-4306-9cb3-62bb2a9e1114",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Bash",
   "language": "bash",
   "name": "bash"
  },
  "language_info": {
   "codemirror_mode": "shell",
   "file_extension": ".sh",
   "mimetype": "text/x-sh",
   "name": "bash"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
