{"id":619,"date":"2025-08-19T18:24:00","date_gmt":"2025-08-19T10:24:00","guid":{"rendered":"https:\/\/www.kz-hub.tech\/?p=619"},"modified":"2025-08-19T19:13:26","modified_gmt":"2025-08-19T11:13:26","slug":"conipher%e6%a0%b9%e6%8d%ae%e7%aa%81%e5%8f%98%e5%8c%ba%e5%88%86%e8%82%bf%e7%98%a4%e4%ba%9a%e5%85%8b%e9%9a%86alpaca%e9%89%b4%e5%ae%9a%e4%ba%9a%e5%85%8b%e9%9a%86%e7%9a%84cnv%e6%94%b9%e5%8f%98","status":"publish","type":"post","link":"https:\/\/www.kz-hub.tech\/index.php\/2025\/08\/19\/conipher%e6%a0%b9%e6%8d%ae%e7%aa%81%e5%8f%98%e5%8c%ba%e5%88%86%e8%82%bf%e7%98%a4%e4%ba%9a%e5%85%8b%e9%9a%86alpaca%e9%89%b4%e5%ae%9a%e4%ba%9a%e5%85%8b%e9%9a%86%e7%9a%84cnv%e6%94%b9%e5%8f%98\/","title":{"rendered":"CONIPHER\u6839\u636e\u7a81\u53d8\u533a\u5206\u80bf\u7624\u4e9a\u514b\u9686+ALPACA\u9274\u5b9a\u4e9a\u514b\u9686\u7684CNV\u6539\u53d8"},"content":{"rendered":"<h2>0. \u5b98\u7f51\uff1a<\/h2>\n<p>CONIPHER: <a href=\"https:\/\/github.com\/McGranahanLab\/CONIPHER\">https:\/\/github.com\/McGranahanLab\/CONIPHER<\/a><br \/>\nALPACA: <a href=\"https:\/\/github.com\/McGranahanLab\/ALPACA-model\">https:\/\/github.com\/McGranahanLab\/ALPACA-model<\/a><br \/>\nASCAT: <a href=\"https:\/\/github.com\/VanLoo-lab\/ascat\">https:\/\/github.com\/VanLoo-lab\/ascat<\/a><br \/>\nrefphase: <a href=\"https:\/\/bitbucket.org\/schwarzlab\/refphase\/src\/master\/\">https:\/\/bitbucket.org\/schwarzlab\/refphase\/src\/master\/<\/a><\/p>\n<h2>1. Dependency\u8f6f\u4ef6\u5b89\u88c5<\/h2>\n<p>conipher:<\/p>\n<pre><code class=\"language-bash\">conda create -n conipher -c conda-forge -c bioconda conipher<\/code><\/pre>\n<p>alpaca: \u9700gurobi\u8bc1\u4e66\uff0c\u672c\u5730\u5b89\u88c5<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/github.com\/McGranahanLab\/ALPACA-model.git\ncd ALPACA-model\nconda env create --name alpaca --file environment.yml\nconda run -n alpaca pip install dist\/*.whl<\/code><\/pre>\n<p>ASCAT: \u8fd0\u884calpaca\u9700\u8981refphase\uff0crefphase\u9700\u8981ASCAT<\/p>\n<pre><code class=\"language-R\"># R\nBiocManager::install(c(&#039;GenomicRanges&#039;,&#039;IRanges&#039;)\ndevtools::install_bitbucket(&quot;schwarzlab\/ascat_v3_fork\/ASCAT&quot;) # \u9700\u8981\u5b89\u88c5\u4ed6\u4eec\u4fee\u6539\u8fc7\u7684ASCAT V3\u624d\u884c<\/code><\/pre>\n<p>refphase:<\/p>\n<pre><code>BiocManager::install(&quot;GenomicRanges&quot;)\ndevtools::install_bitbucket(&quot;schwarzlab\/refphase&quot;)<\/code><\/pre>\n<h2>2. CONIPHER<\/h2>\n<h3>2.1 \u51c6\u5907\u8f93\u5165\u6587\u4ef6<\/h3>\n<p>\u5bf9\u591a\u7076\u6837\u672c\u8fd0\u884cMutect2\uff0cvarscan2\u540e\uff0c\u7b5b\u9009PASS\uff0c\u4f7f\u7528Annovar\u3001vcf2maf\u6ce8\u91ca\uff0c\u4e4b\u540e\u5206\u522b\u5408\u5e76\u6837\u672c\uff1a<\/p>\n<pre><code class=\"language-bash\"># mutect2\ncat *.hg38_multianno.maf | awk &#039;NR&lt;=3 || (!\/^#\/ &amp;&amp; $1!=&quot;Hugo_Symbol&quot;)&#039; &gt; 6patients_mutect2_pass.Somatic.hc.hg38_multianno.maf\n\n# varscan2\ncat *.hc.hg38_multianno.maf | awk &#039;NR&lt;=3 || (!\/^#\/ &amp;&amp; $1!=&quot;Hugo_Symbol&quot;)&#039; &gt; 6patients_varscan2_pass.Somatic.hc.hg38_multianno.maf<\/code><\/pre>\n<p>\u5728R\u4e2d\u7b5b\u9009\u8fc7\u6ee4\uff0c\u53ea\u7559\u4e0b\u4e24\u4e2a\u8f6f\u4ef6\u5171\u540c\u9274\u5b9a\u5230\u7684\u3001gnomAD EAS (east asian population) AF&lt;= 0.05\u30011000GenomesProject EAS &lt;= 0.05,  Tumor and normal total coverage &gt;=20 &amp; &lt;=1000\uff0cTumor ALT read count &gt;= 3\uff0cNormal ALT read count &lt;= 1\uff0cTumor VAF &gt;=0.05\uff0cNormal VAF &lt;=0.05 \u7684\u7a81\u53d8<\/p>\n<pre><code class=\"language-R\">mutect2_maf_df &lt;- read.table(&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/Mutation\/mutect2_TNpaired\/6patients_mutect2_pass.Somatic.hc.hg38_multianno.maf&quot;, header = T, sep = &#039;\\t&#039;, quote = &quot;&quot;)\nvarscan2_maf_df &lt;- read.table(&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/Mutation\/varscan2\/6patients_varscan2_pass.Somatic.hc.hg38_multianno.maf&quot;, header = T, sep = &#039;\\t&#039;, quote = &quot;&quot;)\n\ntable(mutect2_maf_df$Tumor_Sample_Barcode)\ntable(varscan2_maf_df$Tumor_Sample_Barcode)\n\nfilter_maf_df &lt;- function(maf_df){\n  # reformat gnomAD EAS (east asian population) AF and only keep AF &lt;= 0.05\n  maf_df$gnomADe_EAS_AF[is.na(maf_df$gnomADe_EAS_AF)] &lt;- 0\n  maf_df &lt;- subset(maf_df,gnomADe_EAS_AF &lt;= 0.05)\n\n  # reformat 1000GenomesProject EAS (east asian population) AF and only keep AF &lt;= 0.05\n  maf_df$EAS_AF[is.na(maf_df$EAS_AF)] &lt;- 0\n  maf_df &lt;- subset(maf_df,EAS_AF &lt;= 0.05)\n\n  # subset Tumor and normal total coverage &gt;=20 &amp; &lt;=1000\n  maf_df &lt;- subset(maf_df,t_depth &gt;= 20 &amp; t_depth &lt;= 1000)\n  maf_df &lt;- subset(maf_df,n_depth &gt;= 20 &amp; n_depth &lt;= 1000)\n\n  # subset Tumor ALT read count &gt;= 3\n  maf_df &lt;- subset(maf_df,t_alt_count &gt;= 3)\n\n  # subset Normal ALT read count &lt;= 1\n  maf_df &lt;- subset(maf_df,n_alt_count &lt;= 1)\n\n  # subset Tumor VAF &gt;=0.05\n  maf_df$tVAF &lt;- maf_df$t_alt_count\/maf_df$t_depth\n  maf_df &lt;- subset(maf_df,tVAF&gt;=0.05)\n\n  # subset Normal VAF &lt;=0.05\n  maf_df$nVAF &lt;- maf_df$n_alt_count\/maf_df$n_depth\n  maf_df &lt;- subset(maf_df,nVAF&lt;=0.05)\n\n  maf_df$mut_id &lt;- paste0(maf_df$Tumor_Sample_Barcode,&quot;:&quot;,\n                          maf_df$Chromosome,&quot;:&quot;,\n                          maf_df$Start_Position,&quot;:&quot;,\n                          maf_df$End_Position,&quot;:&quot;,\n                          maf_df$Reference_Allele,&quot;:&quot;,\n                          maf_df$Tumor_Seq_Allele2)\n\n  return(maf_df)\n}\n\nmutect2_filtered &lt;- filter_maf_df(mutect2_maf_df)\nvarscan2_filtered &lt;- filter_maf_df(varscan2_maf_df)\n\nmutect2_varscan2_filtered_intersect &lt;- subset(mutect2_filtered,mut_id %in% varscan2_filtered$mut_id)\ntable(mutect2_varscan2_filtered_intersect$Tumor_Sample_Barcode)\n\nwrite.table(mutect2_filtered,&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/Mutation\/mutect2_TNpaired\/6patients_mutect2_pass.Somatic.hc.hg38_multianno_filtered.maf&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(varscan2_filtered,&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/Mutation\/varscan2\/6patients_varscan2_pass.Somatic.hc.hg38_multianno_filtered.maf&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(mutect2_varscan2_filtered_intersect,&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/Mutation\/6patients_mutect2_varscan2_intersect_pass.Somatic.hc.hg38_multianno_filtered.maf&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\n<\/code><\/pre>\n<p>\u76f4\u63a5\u5220\u9664-BNPT\u548c-FA\uff0c\u83b7\u53d6\u5355\u72ec\u4ee5-M\u548c-E\u533a\u5206\u7684Tumor_Sample_Barcode\uff0c\u7559\u4e0b\u5982FETB01-M\u8fd9\u6837\u7684\u7f16\u53f7\uff0c\u8fd9\u6837\u53ef\u4ee5\u63d0\u53d6\u914d\u5bf9\u4e0a\u76ae\u3001\u57fa\u8d28\u6837\u672c\u4e2d\u7684PASS\u4f4d\u70b9<\/p>\n<pre><code class=\"language-R\">Merged_maf_df$Tumor_Sample_Barcode &lt;- gsub(&quot;-BNPT&quot;,&quot;&quot;,Merged_maf_df$Tumor_Sample_Barcode)\nMerged_maf_df$Tumor_Sample_Barcode &lt;- gsub(&quot;-FA&quot;,&quot;&quot;,Merged_maf_df$Tumor_Sample_Barcode)\ntable(Merged_maf_df$Tumor_Sample_Barcode)\n\nwrite.table(Merged_maf_df,&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/Mutation\/6patients_mutect2_varscan2_intersect_pass_Tumor_Sample_Barcode_merged.Somatic.hc.hg38_multianno_filtered.maf&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)<\/code><\/pre>\n<p>\u4f7f\u7528maf2vcf\u628a\u63d0\u53d6\u5b8c\u7684\u4f4d\u70b9\u8f6c\u6362\u4e3avcf\u6587\u4ef6\uff0c\u5176\u4e2d--per-tn-vcfs\u4f1a\u6839\u636eTumor_Sample_Barcode\uff0cvcf\u62c6\u5206\u4e3a\u6bcf\u4e2a\u914d\u5bf9\u6837\u672c\u4e00\u4e2a\uff08\u5982FETB01-M\u7684\u7a81\u53d8\u4f4d\u70b9\u4f1a\u5408\u5728\u4e00\u8d77\u6210\u4e00\u4e2avcf\uff09,\u751f\u6210\u7684vcf\u6587\u4ef6\u7684\u540d\u5b57\u4f1a\u662f\u201cFETB01-M_vs_FETB01-B.vcf\u201d\u7684\u683c\u5f0f<\/p>\n<pre><code>maf2vcf.pl --input-maf 6patients_mutect2_varscan2_intersect_pass_Tumor_Sample_Barcode_merged.Somatic.hc.hg38_multianno_filtered.maf --output-dir \/groups\/phyllodes\/home\/share\/Results\/WES\/maf2vcf --output-vcf 6patients_mutect2_varscan2_intersect_pass_Tumor_Sample_Barcode_merged --ref-fasta \/home\/zhoukaiwen\/database\/GRCh38\/genecode_GRCh38.p14.genome.fa --per-tn-vcfs<\/code><\/pre>\n<p>\u4e3acall Somatic Mutation \u4e2d\u7684 sample_pair\u6dfb\u52a0\u4e00\u5217(\u6700\u53f3\u8fb9)\uff0c\u6309\u7ec4\u7ec7\u7c7b\u578b\u533a\u5206\uff08FETB01-M\uff09<\/p>\n<pre><code>FETB01-BNPT-E   FETB01-B        FETB01  FETB01-E\nFETB01-BNPT-M   FETB01-B        FETB01  FETB01-M\nFETB01-FA-E     FETB01-B        FETB01  FETB01-E\nFETB01-FA-M     FETB01-B        FETB01  FETB01-M\nFETB02-BNPT-E   FETB02-B        FETB02  FETB02-E\nFETB02-BNPT-M   FETB02-B        FETB02  FETB02-M\nFETB02-FA-E     FETB02-B        FETB02  FETB02-E\nFETB02-FA-M     FETB02-B        FETB02  FETB02-M\nFETB03-BNPT-E   FETB03-B        FETB03  FETB03-E\nFETB03-BNPT-M   FETB03-B        FETB03  FETB03-M\nFETB03-FA-E     FETB03-B        FETB03  FETB03-E\nFETB03-FA-M     FETB03-B        FETB03  FETB03-M\nFETB04-BNPT-E   FETB04-B        FETB04  FETB04-E\nFETB04-BNPT-M   FETB04-B        FETB04  FETB04-M\nFETB04-FA-E     FETB04-B        FETB04  FETB04-E\nFETB04-FA-M     FETB04-B        FETB04  FETB04-M\nFETB05-BNPT-E   FETB05-B        FETB05  FETB05-E\nFETB05-BNPT-M   FETB05-B        FETB05  FETB05-M\nFETB05-FA-E     FETB05-B        FETB05  FETB05-E\nFETB05-FA-M     FETB05-B        FETB05  FETB05-M\nFETB06-BNPT-E   FETB06-B        FETB06  FETB06-E\nFETB06-BNPT-M   FETB06-B        FETB06  FETB06-M\nFETB06-FA-E     FETB06-B        FETB06  FETB06-E\nFETB06-FA-M     FETB06-B        FETB06  FETB06-M<\/code><\/pre>\n<p>\u4f7f\u7528mutect2 force call \u6a21\u5f0f\uff0c\u4ee5\u4e0a\u4e00\u6b65\u751f\u6210\u7684vcf\u6587\u4ef6\u4e3atarget region\uff0ccall Somatic mutation\uff0c\u8fd9\u4e00\u6b65call\u5b8c\u7a81\u53d8\u540e\u4e00\u6837\u7528Annovar\u6ce8\u91ca\u3001\u5e76\u901a\u8fc7vcf2maf\u518d\u6b21\u8f6c\u6362\u4e3amaf\u6587\u4ef6\uff0c<\/p>\n<pre><code class=\"language-bash\"># Call \u7a81\u53d8\nperl -ne &#039;chomp; next if \/^$\/; @a = split \/\\t\/; print &quot;bcftools sort $a[3]\\_vs\\_$a[1].vcf -o $a[3]\\_vs\\_$a[1].sorted.vcf &amp;&amp; gatk IndexFeatureFile -I $a[3]\\_vs\\_$a[1].sorted.vcf &amp;&amp; gatk Mutect2 -R ~\/database\/GRCh38\/genecode_GRCh38.p14.genome.fa -I ..\/align\/$a[0]_bqsr.bam -I ..\/align\/$a[1]_bqsr.bam -tumor $a[0] -normal $a[1] --alleles $a[3]\\_vs\\_$a[1].sorted.vcf -L $a[3]\\_vs\\_$a[1].sorted.vcf --germline-resource ~\/database\/gatk_bundle\/hg38\/somatic-hg38_af-only-gnomad.hg38.vcf.gz -pon ~\/database\/gatk_bundle\/hg38\/somatic-hg38_1000g_pon.hg38.vcf.gz --f1r2-tar-gz $a[0].shared.sites.f1r2.tar.gz -O $a[0].shared.sites.raw.vcf &amp;&amp; echo $a[0] Mutect2 force call ok\\n&quot;&#039; sample_pair.txt &gt; Mutect2_force_call_short.sh\n\n# Annovar\u3001vcf2maf\u7701\u7565\n\n# \u5408\u5e76maf\u6587\u4ef6\ncat *.shared.sites.maf | awk &#039;NR&lt;=3 || (!\/^#\/ &amp;&amp; $1!=&quot;Hugo_Symbol&quot;)&#039; &gt; 6patients.shared.sites.maf<\/code><\/pre>\n<p>\u81f3\u6b64\uff0c\u5236\u4f5c\u597d\u4e86\u7ecf\u8fc7\u8d28\u91cf\u8fc7\u6ee4\u3001\u6837\u672c\u914d\u5bf9\u7684\u7a81\u53d8\u7684maf\u6587\u4ef6<br \/>\n\u63a5\u4e0b\u6765\uff0c\u5236\u4f5cCONIPHER\u8f93\u5165\u6587\u4ef6<\/p>\n<pre><code class=\"language-R\"># R\nmutation_maf &lt;- read.table(&quot;6patients.shared.sites.maf&quot;,header = T, sep = &#039;\\t&#039;,quote = &quot;&quot;)\n\nmutation_maf &lt;- as_tibble(mutation_maf) %&gt;%\n  separate(Tumor_Sample_Barcode, into = c(&quot;SampleID&quot;, &quot;middle&quot;, &quot;Tissue&quot;), sep = &quot;-&quot;, fill = &quot;right&quot;, remove = FALSE) %&gt;%\n  mutate(Tissue = coalesce(Tissue, middle)) %&gt;%\n  dplyr::select(-middle)\n\nFiltered_mutationTable &lt;- mutation_maf[,c(&quot;Tumor_Sample_Barcode&quot;,&quot;SampleID&quot;,&quot;Tissue&quot;,&quot;Chromosome&quot;,&quot;Start_Position&quot;,&quot;Reference_Allele&quot;,&quot;Tumor_Seq_Allele2&quot;,&quot;t_ref_count&quot;,&quot;t_alt_count&quot;,&quot;t_depth&quot;)]\n\ncolnames(Filtered_mutationTable) &lt;- c(&quot;SAMPLE&quot;,&quot;CASE_ID&quot;,&quot;Tissue&quot;,&quot;CHR&quot;,&quot;POS&quot;,&quot;REF&quot;,&quot;ALT&quot;,&quot;REF_COUNT&quot;,&quot;VAR_COUNT&quot;,&quot;DEPTH&quot;)\n\nFiltered_mutationTable$CHR &lt;- gsub(&quot;chr&quot;,&quot;&quot;,Filtered_mutationTable$CHR)\n\n# \u6b64\u5904\u9700\u8981\u8fd0\u884csequenza\u4e4b\u540e\u5408\u5e76\u7ed3\u679c\uff0c\u8be6\u89c1sequenza\u6d41\u7a0b\u6587\u4ef6\nmerged_pp &lt;- read.table(&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/sequenza\/merged_solutions.txt&quot;,header = T,sep = &#039;\\t&#039;)\nmerged_seg &lt;- read.table(&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/sequenza\/merged_segments.txt&quot;,header = T,sep = &#039;\\t&#039;)\nmerged_pp_seg &lt;- merge(merged_seg, merged_pp, by = &quot;sample_id&quot;, all.x = TRUE)\n\nmerged_pp_seg &lt;- merged_pp_seg[c(&quot;sample_id&quot;,&quot;chromosome&quot;,&quot;start.pos&quot;,&quot;end.pos&quot;,&quot;A&quot;,&quot;B&quot;,&quot;cellularity&quot;,&quot;ploidy&quot;)]\nmerged_pp_seg$chromosome &lt;- gsub(&quot;chr&quot;,&quot;&quot;,merged_pp_seg$chromosome)\n\nmatched &lt;- Filtered_mutationTable %&gt;%\n  inner_join(merged_pp_seg, by = c(&quot;SAMPLE&quot; = &quot;sample_id&quot;)) %&gt;%\n  filter(CHR == chromosome &amp; POS &gt;= start.pos &amp; POS &lt;= end.pos)\n\nmatched &lt;- matched[,-(11:13)]\n\ncolnames(matched)[which(colnames(matched)==&quot;A&quot;)] &lt;- &quot;COPY_NUMBER_A&quot;\ncolnames(matched)[which(colnames(matched)==&quot;B&quot;)] &lt;- &quot;COPY_NUMBER_B&quot;\ncolnames(matched)[which(colnames(matched)==&quot;cellularity&quot;)] &lt;- &quot;ACF&quot;\ncolnames(matched)[which(colnames(matched)==&quot;ploidy&quot;)] &lt;- &quot;PLOIDY&quot;\n\n# Then, do an anti_join to get rows from mutationTable that did NOT match\nunmatched &lt;- anti_join(Filtered_mutationTable, matched, by = colnames(Filtered_mutationTable)[1:10])\nunmatched$COPY_NUMBER_A &lt;- 1\nunmatched$COPY_NUMBER_B &lt;- 1\nunmatched$ACF &lt;- &quot;UnKnown&quot;\nunmatched$PLOIDY &lt;- &quot;UnKnown&quot;\n\n# Merge Final input fo CONIPHER #\ntable(colnames(matched) %in% colnames(unmatched))\nConipher_Input &lt;- rbind(matched,unmatched)\nConipher_Input &lt;- Conipher_Input[order(Conipher_Input$SAMPLE),]\nConipher_Input &lt;- Conipher_Input %&gt;%\n  group_by(SAMPLE) %&gt;%\n  mutate(\n    ACF = if_else(ACF == &quot;UnKnown&quot;, ACF[ACF != &quot;UnKnown&quot;][1], ACF),\n    PLOIDY = if_else(PLOIDY == &quot;UnKnown&quot;, PLOIDY[PLOIDY != &quot;UnKnown&quot;][1], PLOIDY)\n  ) %&gt;%\n  ungroup()\n\nConipher_Input &lt;- Conipher_Input[, c(2, 1, 3:ncol(Conipher_Input))]\nConipher_Input &lt;- subset(Conipher_Input,!(SAMPLE %in% c(&quot;FETB01-BPT-M-Unstained&quot;,&quot;FETB01-BPT-E-Unstained&quot;)))\nConipher_Input$SAMPLE &lt;- gsub(&quot;-&quot;,&quot;_&quot;,Conipher_Input$SAMPLE)\nConipher_Input$CHR &lt;- factor(Conipher_Input$CHR,levels=c(1:22,&quot;X&quot;))\nConipher_Input &lt;- Conipher_Input[order(Conipher_Input$SAMPLE,Conipher_Input$CHR),]\nConipher_Input &lt;- unique(Conipher_Input)\n\nConipher_Input_FETB01_Epi &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB01&quot; &amp; Tissue ==&quot;E&quot;)\nConipher_Input_FETB01_Stroma &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB01&quot; &amp; Tissue ==&quot;M&quot;)\nConipher_Input_FETB02_Epi &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB02&quot; &amp; Tissue ==&quot;E&quot;)\nConipher_Input_FETB02_Stroma &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB02&quot; &amp; Tissue ==&quot;M&quot;)\nConipher_Input_FETB03_Epi &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB03&quot; &amp; Tissue ==&quot;E&quot;)\nConipher_Input_FETB03_Stroma &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB03&quot; &amp; Tissue ==&quot;M&quot;)\nConipher_Input_FETB04_Epi &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB04&quot; &amp; Tissue ==&quot;E&quot;)\nConipher_Input_FETB04_Stroma &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB04&quot; &amp; Tissue ==&quot;M&quot;)\nConipher_Input_FETB05_Epi &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB05&quot; &amp; Tissue ==&quot;E&quot;)\nConipher_Input_FETB05_Stroma &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB05&quot; &amp; Tissue ==&quot;M&quot;)\nConipher_Input_FETB06_Epi &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB06&quot; &amp; Tissue ==&quot;E&quot;)\nConipher_Input_FETB06_Stroma &lt;- subset(Conipher_Input,CASE_ID == &quot;FETB06&quot; &amp; Tissue ==&quot;M&quot;)\n\nwrite.table(Conipher_Input_FETB01_Epi,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB01_Epi.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB01_Stroma,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB01_Stroma.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB02_Epi,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB02_Epi.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB02_Stroma,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB02_Stroma.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB03_Epi,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB03_Epi.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB03_Stroma,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB03_Stroma.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB04_Epi,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB04_Epi.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB04_Stroma,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB04_Stroma.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB05_Epi,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB05_Epi.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB05_Stroma,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB05_Stroma.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB06_Epi,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB06_Epi.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\nwrite.table(Conipher_Input_FETB06_Stroma,&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/conipher\/Conipher_Input_FETB06_Stroma.txt&quot;,col.names = T,row.names = F,sep = &#039;\\t&#039;,quote = F)\n<\/code><\/pre>\n<h3>2.2 \u6b63\u5f0f\u8fd0\u884c<\/h3>\n<pre><code class=\"language-bash\"># \u6a21\u677f\u5982\u4e0b\nlibrary(CONIPHER)\nlibrary(tidyverse)\n\n# cluster+tree-building\nconipher_run(case_id = &quot;FETB01&quot;,\n             prefix = &quot;FETB01&quot;,\n             out_dir = &quot;FETB01&quot;,\n             input_tsv_loc = &quot;Conipher_Input_FETB01.txt&quot;)\n<\/code><\/pre>\n<h2>3. \u8fd0\u884c ASCAT<\/h2>\n<pre><code># EXAMPLE_ASCAT.R\nlibrary(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<pre><code class=\"language-bash\"># Create_Run_ASCAT.sh\n#!\/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<h2>4. \u8fd0\u884crefphase<\/h2>\n<pre><code class=\"language-R\"># R\nlibrary(ASCAT)\nlibrary(refphase)\noptions(bitmapType=&#039;cairo&#039;)\npatient &lt;- &quot;FETB01-M&quot;\nnormal_sample &lt;- &quot;FETB01-B&quot;\ntumor_samples &lt;- c(&quot;FETB01-BNPT-M&quot;, &quot;FETB01-FA-M&quot;)\n\n# Do some extra work to create a table that will be needed when we run refphase in the next step. This is not needed by ASCAT itself.\nrefphase_sample_data &lt;- data.frame(sample_id = tumor_samples,\n                                   segmentation = paste0(tumor_samples, &quot;_refphase_segs.tsv&quot;),\n                                   snps = paste0(tumor_samples, &quot;_refphase_snps.tsv&quot;),\n                                   purity = NA, ploidy = NA, row.names = tumor_samples)\n\n# ascat_input and ascat_output are required for refphase later on\nascat_input &lt;- list()\nascat_output &lt;- list()\nfor (tumor_sample in tumor_samples) {\n  cur_ascat_input &lt;- ascat.loadData(Tumor_LogR_file = paste0(&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/ASCAT\/&quot;,tumor_sample, &quot;_LogR.txt&quot;),\n                                    Tumor_BAF_file = paste0(&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/ASCAT\/&quot;,tumor_sample, &quot;_BAF.txt&quot;),\n                                    Germline_LogR_file = paste0(&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/ASCAT\/&quot;,tumor_sample, &quot;_LogR.txt&quot;),\n                                    Germline_BAF_file = paste0(&quot;\/data02\/zhangmengmeng\/BPT\/LCM-WES\/ASCAT\/&quot;,tumor_sample, &quot;_BAF.txt&quot;),\n                                    gender = &quot;XX&quot;, genomeVersion = &quot;hg38&quot;)\n  ascat.plotRawData(cur_ascat_input,img.prefix =paste0(tumor_sample,&quot;_Before_correction_&quot;))\n  cur_ascat_input = ascat.correctLogR(cur_ascat_input,\n                                      GCcontentfile = &quot;\/data02\/zhangmengmeng\/database\/ASCAT_ref\/GC_G1000_hg38.txt&quot;,\n                                      replictimingfile = &quot;\/data02\/zhangmengmeng\/database\/ASCAT_ref\/RT_G1000_hg38.txt&quot;)\n  ascat.plotRawData(cur_ascat_input,img.prefix =paste0(tumor_sample,&quot;_After_correction_&quot;))\n  cur_ascat_input &lt;- ascat.aspcf(cur_ascat_input)\n  ascat.plotSegmentedData(cur_ascat_input)\n  cur_ascat_output &lt;- ascat.runAscat(cur_ascat_input, gamma = 1.0)\n\n  ascat_input[[tumor_sample]] &lt;- cur_ascat_input\n  ascat_output[[tumor_sample]] &lt;- cur_ascat_output\n\n  # Save the segmentation in the default ASCAT format\n  write.table(cur_ascat_output$segments, file = paste0(tumor_sample, &quot;_segments.txt&quot;), sep = &quot;\\t&quot;, quote = FALSE, row.names = FALSE)\n\n  refphase_sample_data[tumor_sample, &quot;purity&quot;] &lt;- cur_ascat_output$aberrantcellfraction[[1]]\n  refphase_sample_data[tumor_sample, &quot;ploidy&quot;] &lt;- cur_ascat_output$ploidy[[1]]\n}\n\nwrite.table(refphase_sample_data, file = paste0(patient,&quot;_refphase-sample-data.tsv&quot;), sep = &quot;\\t&quot;, quote = FALSE, row.names = FALSE)\n\n# Load the ascat input and output\nrefphase_input &lt;- refphase_load(\n  data_format = &quot;ascat3&quot;, samples = tumor_samples,\n  ascat_input = ascat_input, ascat_output = ascat_output\n)\n# (Optional) If your data shows reference bias, which presents itself as BAFs\n# in regions with a balanced copy number that are systematically shifted away\n# from 0.5 (usually something like 0.47), this can try to correct for that.\nrefphase_input &lt;- center_baf(refphase_input)\n\n# (Optional) Fit SNP logr data to improve copy number re-estimation in refphase,\n# when using the default ASCAT formula-based method fo re-estimating copy\n# numbers\nrefphase_input &lt;- fit_logr_to_ascat(refphase_input)\n\n# Run refphase on the experimental data\nresults &lt;- refphase(refphase_input)\nsave(results, file = paste0(patient, &quot;-refphase-results.RData&quot;))\n\nwrite_segs(results$phased_segs, file = paste0(patient, &quot;-refphase-segmentation.tsv&quot;))\n\n# (optional) output the SNPs, including phasing information\nwrite_snps(results$phased_snps, file = paste0(patient, &quot;-refphase-phased-snps.tsv.gz&quot;))\n\n# Ploidy might have changed, if we have updated any copy numbers\nwrite.table(results$sample_data, file = paste0(patient, &quot;-refphase-sample-data-updated.tsv&quot;), sep = &quot;\\t&quot;, row.names = FALSE)\n\n# Plot the results as PDFs (these files can be huge, over 100 MB in some cases)\npdf(paste0(patient, &quot;-refphase-genome.pdf&quot;), width = 10, height = 4 * nrow(results$sample_data), family = &quot;sans&quot;)\nplot(results, what = &quot;genome&quot;)\ndev.off()\n\npdf(paste0(patient, &quot;-refphase-chromosomes.pdf&quot;), width = 10, height = 2 + 4 * nrow(results$sample_data), family = &quot;sans&quot;)\nplot_all_chromosomes(results$sample_data, results$phased_snps, list(refphase = results$phased_segs, orig = refphase_input$segs), cn_event_calls = results$cn_event_calls)\ndev.off()\n\n# Plot the results as individual PNG files\npng(paste0(patient, &quot;-refphase-genome.png&quot;), width = 600, height = 200 + 300 * nrow(results$sample_data), family = &quot;sans&quot;)\nplot(results, what = &quot;genome&quot;)\ndev.off()\n\npng(paste0(patient, &quot;-refphase-chromosomes-%02d.png&quot;), width = 700, height = 300 * nrow(results$sample_data), family = &quot;sans&quot;)\nplot_all_chromosomes(results$sample_data, results$phased_snps, list(refphase = results$phased_segs, orig = refphase_input$segs), cn_event_calls = results$cn_event_calls)\ndev.off()<\/code><\/pre>\n<h2>5. \u8fd0\u884calpaca<\/h2>\n<p>\u7531\u4e8econipher\u548crephase\u4e2d\uff0c\u6837\u672c\u540d\u5b57\u683c\u5f0f\u4e0d\u540c\uff08CONIPHER\u4e0d\u5141\u8bb8\u201c-\u201d\uff0c\u53ea\u80fd\u7528\u201c_\u201d\uff0c\u56e0\u6b64\u9700\u8981\u5728R\u4e2d\u8fdb\u884c\u4fee\u6539\uff09<\/p>\n<pre><code class=\"language-R\"># R \u53c2\u8003\u6a21\u677f\nload(&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/refphase\/FETB04-M-refphase-results.RData&quot;)\ntree_rds &lt;- readRDS(&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/CONIPHER\/FETB04_S\/Trees\/FETB04-M.tree.RDS&quot;)\n\nrename_conipher_output &lt;- function(rds){\n  rownames(rds$ccf_table_pyclone) &lt;- sub(&quot;^([^:]+):&quot;, &quot;\\\\1-M:&quot;, rownames(rds$ccf_table_pyclone))\n  colnames(rds$ccf_table_pyclone) &lt;- sub(&quot;_&quot;, &quot;-&quot;, colnames(rds$ccf_table_pyclone))\n  colnames(rds$ccf_table_pyclone) &lt;- sub(&quot;_&quot;, &quot;-&quot;, colnames(rds$ccf_table_pyclone))\n\n  rownames(rds$ccf_table_absolute) &lt;- sub(&quot;^([^:]+):&quot;, &quot;\\\\1-M:&quot;, rownames(rds$ccf_table_absolute))\n  colnames(rds$ccf_table_absolute) &lt;- sub(&quot;_&quot;, &quot;-&quot;, colnames(rds$ccf_table_absolute))\n  colnames(rds$ccf_table_absolute) &lt;- sub(&quot;_&quot;, &quot;-&quot;, colnames(rds$ccf_table_absolute))\n\n  rownames(rds$ccf_table_pyclone_clean) &lt;- sub(&quot;^([^:]+):&quot;, &quot;\\\\1-M:&quot;, rownames(rds$ccf_table_pyclone_clean))\n  colnames(rds$ccf_table_pyclone_clean) &lt;- sub(&quot;_&quot;, &quot;-&quot;, colnames(rds$ccf_table_pyclone_clean))\n  colnames(rds$ccf_table_pyclone_clean) &lt;- sub(&quot;_&quot;, &quot;-&quot;, colnames(rds$ccf_table_pyclone_clean)) \n\n  rownames(rds$ccf_table_absolute_clean) &lt;- sub(&quot;^([^:]+):&quot;, &quot;\\\\1-M:&quot;, rownames(rds$ccf_table_absolute_clean))\n  colnames(rds$ccf_table_absolute_clean) &lt;- sub(&quot;_&quot;, &quot;-&quot;, colnames(rds$ccf_table_absolute_clean))\n  colnames(rds$ccf_table_absolute_clean) &lt;- sub(&quot;_&quot;, &quot;-&quot;, colnames(rds$ccf_table_absolute_clean)) \n\n  colnames(rds$clonality_table) &lt;- gsub(&quot;_&quot;, &quot;-&quot;, colnames(rds$clonality_table)) \n\n  rds$graph_pyclone$sampleID &lt;- paste0(rds$graph_pyclone$sampleID,&quot;-M&quot;)\n  rds$parameters$sampleID &lt;- paste0(rds$parameters$sampleID,&quot;-M&quot;)\n  rds$parameters$prefix &lt;- paste0(rds$parameters$prefix,&quot;-M&quot;)\n\n  colnames(rds$clonality_out$clonality_table_corrected) &lt;- gsub(&quot;_&quot;, &quot;-&quot;, colnames(rds$clonality_out$clonality_table_corrected)) \n  colnames(rds$clonality_out$clonality_table_original) &lt;- gsub(&quot;_&quot;, &quot;-&quot;, colnames(rds$clonality_out$clonality_table_original)) \n  colnames(rds$clone_proportion_out$clone_proportion_table) &lt;- gsub(&quot;_&quot;, &quot;-&quot;, colnames(rds$clone_proportion_out$clone_proportion_table)) \n\n  rds$subclonal_expansion_score_out$subclonal_exp_score$sample &lt;- gsub(&quot;_&quot;, &quot;-&quot;, rds$subclonal_expansion_score_out$subclonal_exp_score$sample)\n  rownames(rds$subclonal_expansion_score_out$subclonal_exp_score) &lt;- rds$subclonal_expansion_score_out$subclonal_exp_score$sample\n\n  rds$subclonal_expansion_score_out$subclonal_exp_score_min_sce_trees$`1`$sample &lt;- gsub(&quot;_&quot;, &quot;-&quot;, rds$subclonal_expansion_score_out$subclonal_exp_score_min_sce_trees$`1`$sample)\n  rownames(rds$subclonal_expansion_score_out$subclonal_exp_score_min_sce_trees$`1`) &lt;- rds$subclonal_expansion_score_out$subclonal_exp_score_min_sce_trees$`1`$sample\n  return(rds)\n}\n\ntree_rds_renamed &lt;- rename_conipher_output(tree_rds)\n\nsaveRDS(tree_rds_renamed,&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/ALPACA\/FETB04-M.renamed.tree.RDS&quot;)<\/code><\/pre>\n<p>\u8fd0\u884cALPACA<\/p>\n<pre><code>tumour_id=&quot;FETB04-M&quot;\nrefphase_rData=&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/refphase\/${tumour_id}-refphase-results.RData&quot;\nCONIPHER_tree_object=&quot;\/Users\/zhoukaiwen\/Desktop\/Breast_Phyllodes_Tumor\/Bioinfo\/WES\/ALPACA\/${tumour_id}.renamed.tree.RDS&quot;\nprep_input_dir=&quot;.\/${tumour_id}\/input&quot;\nrun_input_dir=&quot;${tumour_id}\/input&quot;\nrun_output_dir=&quot;${tumour_id}\/output&quot;\n\nalpaca input-conversion \\\n    --tumour_id $tumour_id \\\n    --refphase_rData $refphase_rData \\\n    --CONIPHER_tree_object $CONIPHER_tree_object \\\n    --CONIPHER_tree_index 1 \\\n    --output_dir $prep_input_dir\n\n# \u91cd\u65b0\u8c03\u6574\u6837\u672c\u547d\u540d\uff0cR\u8f93\u51fa\u65f6\u81ea\u52a8\u4f1a\u628a\u5217\u540d\u4e2d\u7684-\u4fee\u6539\u4e3a_\uff0c\u8fd9\u91cc\u6539\u56de\u6765\nsed -i &#039;&#039; &#039;s\/_\/-\/g&#039; &quot;$(pwd)\/${run_input_dir}\/cp_table.csv&quot;\n\n# \u4f1a\u6709\u4e0d\u91cd\u590d\u7684CN segments\uff0c\u8fd9\u91cc\u53ea\u6311\u9009\u91cd\u590d\u7684CNV\u533a\u6bb5\nmv &quot;$(pwd)\/${run_input_dir}\/ALPACA_input_table.csv&quot; &quot;$(pwd)\/${run_input_dir}\/ALPACA_input_table.csv.backup&quot;\nawk -F, &#039;NR==1{print; next} {count[$3]++; lines[NR]=$0; seg[NR]=$3} END{for(i=2;i&lt;=NR;i++) if(count[seg[i]]&gt;1) print lines[i]}&#039; &quot;$(pwd)\/${run_input_dir}\/ALPACA_input_table.csv.backup&quot; &gt; &quot;$(pwd)\/${run_input_dir}\/ALPACA_input_table.csv&quot;\n\n# \u8f6f\u4ef6bug\uff1aalpaca run\u8bbe\u7f6e\u4e86run_input_dir\u7684\u60c5\u51b5\u4e0b\uff0c\u4f1a\u9ed8\u8ba4\u8f93\u5165\u8def\u5f84\u4e3a${tumour_id}\/${tumour_id}\uff0c\u6545\u8fd0\u884c\u524d\u521b\u5efa\u8f6f\u94fe\u63a5\nln -s &quot;$(pwd)\/${tumour_id}\/input&quot; &quot;${tumour_id}\/${tumour_id}&quot;\n\nalpaca run \\\n    --input_tumour_directory &quot;${run_input_dir}&quot; \\\n    --output_directory &quot;${run_output_dir}&quot;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>0. \u5b98\u7f51\uff1a CONIPHER: https:\/\/github.com\/McGranahanLab\/CONIP&#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-619","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\/619","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=619"}],"version-history":[{"count":2,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/619\/revisions"}],"predecessor-version":[{"id":621,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/619\/revisions\/621"}],"wp:attachment":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/media?parent=619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/categories?post=619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/tags?post=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}