From 84b2916f41040f50d168f3a0a2898ace4deb1b93 Mon Sep 17 00:00:00 2001 From: Ronglai Shen Date: Fri, 29 Jan 2016 11:11:43 -0500 Subject: [PATCH] fix warning --- DESCRIPTION | 2 +- R/facets-emcncf.R | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 34d9718..b7d4570 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: facets Type: Package Title: Cellular Fraction and Copy Numbers from Tumor Sequencing -Version: 0.3.20 +Version: 0.3.21 Date: 2016-01-11 Author: Venkatraman E. Seshan and Ronglai Shen Maintainer: Venkatraman E. Seshan diff --git a/R/facets-emcncf.R b/R/facets-emcncf.R index d91710d..efd22a2 100644 --- a/R/facets-emcncf.R +++ b/R/facets-emcncf.R @@ -87,7 +87,13 @@ emcncf=function(x,trace=FALSE,unif=FALSE,min.nhet=15,maxiter=10,eps=1e-3){ rhov.lsd[t.lsd==2&minor.lsd==1]=NA rhov.lsd[t.lsd==2&rhov.lsd==1]=NA rhov.lsd[chr>=23&rhov.lsd==1]=NA - naive=max(by(rhov.lsd[seglen>35],segclust[seglen>35],function(x)mean(x,na.rm=T)),na.rm=T) + + #if(!all(is.na(rhov.lsd[seglen>35]))){ + # naive=max(by(rhov.lsd[seglen>35],segclust[seglen>35],function(x)mean(x,na.rm=T)),na.rm=T) + #}else{ + naive=quantile(rhov.lsd,prob=0.75,na.rm=T) + #} + rhov.lsd.subset=rhov.lsd rhov.lsd.subset[which.geno.lsd%in%c(3,5,7,10,11,14,15,NA)]=NA @@ -337,7 +343,12 @@ emcncf=function(x,trace=FALSE,unif=FALSE,min.nhet=15,maxiter=10,eps=1e-3){ rhov.long[which.geno.long == 4]=NA rhov.long[chr>=23]=NA - meanrho=max(by(rhov.long[seglen>35],segclust[seglen>35],function(x)mean(x,na.rm=T)),na.rm=T) + if(sum(!is.na(rhov.long[seglen>35]))>1){ + meanrho=max(by(rhov.long[seglen>35],segclust[seglen>35],function(x)mean(x,na.rm=T)),na.rm=T) + }else{ + meanrho=quantile(rhov.long,prob=0.75,na.rm=T) #if no big segments, probably very noisy sample or over-segemnted. can't estimate rho accurately, just take upper quatile + } + rhov.long.subset=rhov.long rhov.long.subset[which.geno.long %in% c(5,7,10,11,14,15,NA)]=NA #Imbalanced gains have big identifiability issue rhov.long.subset[seglen<50]=NA