{"id":512,"date":"2025-03-12T08:52:31","date_gmt":"2025-03-12T00:52:31","guid":{"rendered":"https:\/\/www.kz-hub.tech\/?p=512"},"modified":"2025-03-12T15:52:30","modified_gmt":"2025-03-12T07:52:30","slug":"ascatallele-specific-copy-number-analysis-of-tumors","status":"publish","type":"post","link":"https:\/\/www.kz-hub.tech\/index.php\/2025\/03\/12\/ascatallele-specific-copy-number-analysis-of-tumors\/","title":{"rendered":"ASCAT(Allele-Specific Copy Number Analysis of Tumors) + breakclone"},"content":{"rendered":"<p>\u6559\u7a0b\uff1a<a href=\"https:\/\/github.com\/VanLoo-lab\/ascat\/tree\/master\/ExampleData\">https:\/\/github.com\/VanLoo-lab\/ascat\/tree\/master\/ExampleData<\/a><\/p>\n<h3>\u4eceASCAT\u5b98\u7f51\u4e0b\u8f7dReference\u6587\u4ef6<\/h3>\n<p><a href=\"https:\/\/zenodo.org\/records\/14008443\">https:\/\/zenodo.org\/records\/14008443<\/a><br \/>\n\u9700\u4e0b\u8f7d\uff1aG1000_alleles_WES_hg38.zip, G1000_loci_WES_hg38.zip, GC_G1000_WES_hg38.zip, RT_G1000_WES_hg38.zip<\/p>\n<p>\u5168\u90e8\u89e3\u538b\u540e\u4fee\u6539G1000_lociAll_hg38\u6587\u4ef6\u5939\u91cc\u7684\u6240\u6709\u6587\u4ef6\uff0c\u5168\u90e8\u6dfb\u52a0\u201cchr\u201d<\/p>\n<pre><code>for file in *.txt; do\n  sed -i &#039;s\/^\/chr\/&#039; &quot;$file&quot;\ndone<\/code><\/pre>\n<h3>\u6784\u5efaEXAMPLE\u811a\u672c\u7528\u4e8e\u66ff\u6362<\/h3>\n<p>Example_ASCAT.R<\/p>\n<pre><code>library(ASCAT)\noptions(bitmapType=&#039;cairo&#039;)\nSys.setenv(LD_LIBRARY_PATH = paste(&quot;\/data02\/zhangmengmeng\/software\/alleleCount-4.2.1\/lib&quot;, Sys.getenv(&quot;LD_LIBRARY_PATH&quot;), sep=&quot;:&quot;))\nSys.getenv(&quot;LD_LIBRARY_PATH&quot;)\ndyn.load(&quot;\/data02\/zhangmengmeng\/software\/alleleCount-4.2.1\/lib\/libhts.so.3&quot;)\nascat.prepareHTS(\n  tumourseqfile = &quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/align\/TUMOR_bqsr.bam&quot;,\n  normalseqfile = &quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/align\/NORMAL_bqsr.bam&quot;,\n  tumourname = &quot;TUMOR&quot;,\n  normalname = &quot;NORMAL&quot;,\n  allelecounter_exe = &quot;\/data02\/zhangmengmeng\/software\/alleleCount-4.2.1\/bin\/alleleCounter&quot;,\n  alleles.prefix = &quot;\/data02\/zhangmengmeng\/database\/ASCAT_ref\/G1000_allelesAll_hg38\/G1000_alleles_hg38_chr&quot;,\n  loci.prefix = &quot;\/data02\/zhangmengmeng\/database\/ASCAT_ref\/G1000_lociAll_hg38\/G1000_loci_hg38_chr&quot;,\n  BED_file = &quot;\/data02\/zhangmengmeng\/database\/gatk_resource_bundle\/hg38\/AgilentV6_GRCh38_ex_region.sort.bed&quot;,\n  gender = &quot;XX&quot;,\n  genomeVersion = &quot;hg38&quot;,\n  nthreads = 8,\n  tumourLogR_file = &quot;TUMOR_LogR.txt&quot;,\n  tumourBAF_file = &quot;TUMOR_BAF.txt&quot;,\n  normalLogR_file = &quot;NORMAL_LogR.txt&quot;,\n  normalBAF_file = &quot;NORMAL_BAF.txt&quot;)\n\nascat.bc = ascat.loadData(Tumor_LogR_file = &quot;TUMOR_LogR.txt&quot;, Tumor_BAF_file = &quot;TUMOR_BAF.txt&quot;, Germline_LogR_file = &quot;NORMAL_LogR.txt&quot;, Germline_BAF_file = &quot;NORMAL_BAF.txt&quot;, gender = &quot;XX&quot;, genomeVersion = &quot;hg38&quot;)\nascat.plotRawData(ascat.bc, img.prefix = &quot;TUMOR_Before_correction_&quot;)\nascat.bc = ascat.correctLogR(ascat.bc, GCcontentfile = &quot;\/data02\/zhangmengmeng\/database\/ASCAT_ref\/GC_G1000_hg38.txt&quot;, replictimingfile = &quot;\/data02\/zhangmengmeng\/database\/ASCAT_ref\/RT_G1000_hg38.txt&quot;)\nascat.plotRawData(ascat.bc, img.prefix = &quot;TUMOR_After_correction_&quot;)\nascat.bc = ascat.aspcf(ascat.bc)\nascat.plotSegmentedData(ascat.bc)\nascat.output = ascat.runAscat(ascat.bc, gamma=1, write_segments = TRUE)\n\n# Function to count SNPs within segment boundaries\ncount_snps_in_segment &lt;- function(chr, start, end, snp_df) {\n  sum(snp_df$Chromosome == chr &amp; snp_df$Position &gt;= start &amp; snp_df$Position &lt;= end)\n}\n\n# Apply function to each row in segments dataframe\nascat.output$segments$nProbes &lt;- mapply(\n  count_snps_in_segment, \n  ascat.output$segments$chr, \n  ascat.output$segments$startpos, \n  ascat.output$segments$endpos, \n  MoreArgs = list(snp_df = ascat.bc$SNPpo)\n)\nfinal_segment &lt;- ascat.output$segments\ncolnames(final_segment) &lt;- c(&quot;SampleID&quot;,&quot;Chr&quot;,&quot;Start&quot;,&quot;End&quot;,&quot;nMajor&quot;,&quot;nMinor&quot;,&quot;nProbes&quot;)\nwrite.table(final_segment,&quot;TUMOR_final_segment.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nQC = ascat.metrics(ascat.bc,ascat.output)\nsave(ascat.bc, ascat.output, QC, file = &#039;TUMOR_ASCAT_objects.Rdata&#039;)<\/code><\/pre>\n<h3>\u6784\u5efashell\u811a\u672c\u7528\u4e8e\u6279\u91cf\u8dd1ascat<\/h3>\n<p><strong><em>Create_Run_ASCAT.sh<\/em><\/strong><\/p>\n<pre><code>#!\/bin\/bash\n\n# Path to the example R script\nEXAMPLE_SCRIPT=&quot;EXAMPLE_ASCAT.R&quot;\nOUTPUT_SCRIPT=&quot;run_ascat.sh&quot;\n\n# Start the script file\necho &quot;#!\/bin\/bash&quot; &gt; &quot;$OUTPUT_SCRIPT&quot;\n\n# Debugging: Check if sample pairs are correctly read\necho &quot;Processing sample pairs...&quot;\n\n# Ensure strict tab-separated parsing\nwhile IFS=$&#039;\\t&#039; read -r TUMOR NORMAL PATIENT_ID; do\n    # Trim spaces in TUMOR and NORMAL\n    TUMOR=$(echo &quot;$TUMOR&quot; | xargs)\n    NORMAL=$(echo &quot;$NORMAL&quot; | xargs)\n    PATIENT_ID=$(echo &quot;$PATIENT_ID&quot; | xargs)\n\n    # Debug: Show extracted values\n    echo &quot;TUMOR: [$TUMOR], NORMAL: [$NORMAL], PATIENT_ID: [$PATIENT_ID]&quot;\n\n    # Skip invalid lines\n    if [[ -z &quot;$TUMOR&quot; || -z &quot;$NORMAL&quot; ]]; then\n        echo &quot;Skipping invalid line: [$TUMOR] [$NORMAL]&quot;\n        continue\n    fi\n\n    # Define output R script name\n    R_SCRIPT=&quot;ASCAT_${TUMOR}.R&quot;\n\n    # Swap TUMOR and NORMAL in the script and create a new file\n    awk -v t=&quot;$TUMOR&quot; -v n=&quot;$NORMAL&quot; &#039;{gsub(&quot;TUMOR&quot;, t); gsub(&quot;NORMAL&quot;, n)} 1&#039; &quot;$EXAMPLE_SCRIPT&quot; &gt; &quot;$R_SCRIPT&quot;\n\n    # Append the command to run the script (but don&#039;t execute)\n    echo &quot;\/opt\/R\/4.3.0\/lib64\/R\/bin\/Rscript $R_SCRIPT&quot; &gt;&gt; &quot;$OUTPUT_SCRIPT&quot;\n\ndone &lt; sample_pair.txt\n\n# Make the script executable\nchmod +x &quot;$OUTPUT_SCRIPT&quot;\n\necho &quot;Commands saved in run_ascat.sh. You can run it manually with: bash run_ascat.sh&quot;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6559\u7a0b\uff1ahttps:\/\/github.com\/VanLoo-lab\/ascat\/tree\/master\/Exam&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-512","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/comments?post=512"}],"version-history":[{"count":16,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/512\/revisions"}],"predecessor-version":[{"id":528,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/512\/revisions\/528"}],"wp:attachment":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/media?parent=512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/categories?post=512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/tags?post=512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}