From ca540485bbbbe45ddb318bfbe4fe56e75499f510 Mon Sep 17 00:00:00 2001 From: mxdeluca Date: Sun, 2 Sep 2018 20:43:47 +1000 Subject: [PATCH 1/3] Changed res_ai[1] to res_ai[,1] to obtain the correct telomeric allelic imbalance for each sample Use of res_ai[1] instead of res_ai[,1] resulted in a constant telomeric AI been used to calculate each sample's HRD score. Rectification to res_ai[,1] corrected the issue The script now assigns the HRD score results as a dataframe in the global environement to enabble easy access and manipulation --- R/scar_score.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/R/scar_score.R b/R/scar_score.R index 5a1fa38..285ef98 100644 --- a/R/scar_score.R +++ b/R/scar_score.R @@ -43,19 +43,19 @@ scar_score<-function(seg,reference = "grch38", seqz=FALSE, ploidy=NULL, sizelimi res_ai<- calc.ai_new(seg = seg, chrominfo = chrominfo) #<-- the first column is what I need #Calculating the large scale transition scores: res_lst <- calc.lst(seg = seg, chrominfo = chrominfo) #<-- You need to use the chrominfo.snp6 file! Nicolai sent it to you! - sum_HRD0<-res_lst+res_hrd+res_ai[1] + sum_HRD0<-res_lst+res_hrd+res_ai[,1] if (is.null(ploidy)){ sum_HRDc<-NA } else { - sum_HRDc<-res_lst-15.5*ploidy+res_hrd+res_ai[1] + sum_HRDc<-res_lst-15.5*ploidy+res_hrd+res_ai[,1] } - #HRDresulst<-c(res_hrd,res_ai,res_lst,sum_HRD0,sum_HRDc) + #HRDresulst<-cbind(res_hrd,res_ai[,1],res_lst,sum_HRD0,sum_HRDc) #names(HRDresulst)<-c("HRD",colnames(res_ai),"LST", "HRD-sum","adjusted-HRDsum") - HRDresulst<-c(res_hrd,res_ai[1],res_lst,sum_HRD0) - names(HRDresulst)<-c("HRD",colnames(res_ai)[1],"LST", "HRD-sum") - run_name<-names(sum_HRD0) - write.table(t(HRDresulst),paste0(outputdir,"/",run_name,"_HRDresults.txt"),col.names=NA,sep="\t",row.names=unique(seg[,1])) + HRDresulst<-cbind(res_hrd,res_ai[,1],res_lst,sum_HRD0) + colnames(HRDresulst)<-c("HRD",colnames(res_ai)[1],"LST", "HRD-sum") + assign("HRDresulst",as.data.frame(HRDresulst),envir = .GlobalEnv) + write.table(t(HRDresulst),paste0(outputdir,"/","HRDresults.txt"),sep="\t") return(t(HRDresulst)) } From 9f967973b1ae0178be5488cf6e47f73781343d27 Mon Sep 17 00:00:00 2001 From: mxdeluca Date: Fri, 9 Nov 2018 13:02:03 +1000 Subject: [PATCH 2/3] wrong index for nA --- R/calc.lst.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/calc.lst.R b/R/calc.lst.R index 51e5426..ce840d4 100644 --- a/R/calc.lst.R +++ b/R/calc.lst.R @@ -5,7 +5,7 @@ #' @param nA column number of copy number of A allele #' @param chr.arm option to use chromosome arms defined during segmentation #' @return number of LSTs -calc.lst<-function(seg, chrominfo=chrominfo,nA=7,chr.arm='no'){ +calc.lst<-function(seg, chrominfo=chrominfo,nA=6,chr.arm='no'){ nB <- nA+1 samples <- unique(seg[,1]) output <- setNames(rep(0,length(samples)), samples) From 17b67dda4c4ebc7f11f644d995f6d58bfd4bb77c Mon Sep 17 00:00:00 2001 From: mxdeluca Date: Fri, 9 Nov 2018 13:02:52 +1000 Subject: [PATCH 3/3] wrong index nA --- R/calc.hrd.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/calc.hrd.R b/R/calc.hrd.R index 7571bf3..5f91f24 100644 --- a/R/calc.hrd.R +++ b/R/calc.hrd.R @@ -4,7 +4,7 @@ #' @param nA column number of copy number of A allele #' @param sizelimit lower limit of the size of LOHs #' @return number of LOH -calc.hrd<-function(seg, nA=7, return.loc=FALSE,sizelimit1){ +calc.hrd<-function(seg, nA=6, return.loc=FALSE,sizelimit1){ nB <- nA+1 output <- rep(0, length(unique(seg[,1]))) names(output) <- unique(seg[,1]) @@ -40,4 +40,3 @@ calc.hrd<-function(seg, nA=7, return.loc=FALSE,sizelimit1){ return(output) } } -