NAs introduced by coercion

34 views
Skip to first unread message

Алексей Баринов

unread,
Sep 22, 2020, 7:40:51 AM9/22/20
to CODEX/CODEX2 for CNV detection
Hello dear developers. 

I have moved to another virtual machine and faced problem  :

In segment(Y_qc, Yhat, optK = optK, K = K, sampname_qc, ref_qc,  :
  NAs introduced by coercion

BRCAyearmonth_chr17_2_CODEX_frac.txt has NA in chr name column. 

Could you please help to fix ? 


My R script is 


##source("/home/ubuntu/a.R")
library(CODEX)
dirPath <- "/home/ubuntu/data/"
bamFile <- list.files(dirPath, pattern = '*.bam$')
bamdir <- file.path(dirPath, bamFile)
sampname <- as.matrix(read.table(file.path(dirPath, "sampname")))
bedFile <- file.path(dirPath, "/targets/QIASEQBRCAPLUS.BED")
chrlist <- c("chr10","chr13","chr16","chr17")
for (i in chrlist)
{ i-> chr

bambedObj <- getbambed(bamdir = bamdir, bedFile = bedFile, 
                       sampname = sampname, projectname = "BRCAyearmonth", chr)

bamdir <- bambedObj$bamdir; sampname <- bambedObj$sampname

ref <- bambedObj$ref; projectname <- bambedObj$projectname; chr <- bambedObj$chr
coverageObj <- getcoverage(bambedObj, mapqthres = 20)

Y <- coverageObj$Y; readlength <- coverageObj$readlength
gc <- getgc(chr, ref)
mapp <- getmapp(chr, ref)

##leithtrash=20-2000
##K=1:9
qcObj <- qc(Y, sampname, chr, ref, mapp, gc, cov_thresh = c(100, 10000), 
    length_thresh = c(20, 3000), mapp_thresh = 0.8, gc_thresh = c(20, 80))
Y_qc <- qcObj$Y_qc; sampname_qc <- qcObj$sampname_qc; gc_qc <- qcObj$gc_qc
mapp_qc <- qcObj$mapp_qc; ref_qc <- qcObj$ref_qc; qcmat <- qcObj$qcmat
write.table(qcmat, file = paste(projectname, '_', chr, '_qcmat', '.txt', sep=''),
            sep='\t', quote=FALSE, row.names=FALSE)

normObj <- normalize(Y_qc, gc_qc, K = 1:9)
#normObj <- normalize2(Y_qc, gc_qc, K = 1:2, normal_index=c(1,3))



Yhat <- normObj$Yhat; AIC <- normObj$AIC; BIC <- normObj$BIC

RSS <- normObj$RSS; K <- normObj$K

choiceofK(AIC, BIC, RSS, K, filename = paste(projectname, "_", chr, 
"_choiceofK", ".pdf", sep = ""))
filename <- paste(projectname, "_", chr,".pdf", sep = "")

Kmax <- length(AIC)

par(mfrow = c(1, 3))

plot(K, RSS, type = "b", xlab = "Number of latent variables")
plot(K, AIC, type = "b", xlab = "Number of latent variables")
plot(K, BIC, type = "b", xlab = "Number of latent variables")

optK = K[which.max(BIC)]
finalcall <- segment(Y_qc, Yhat, optK = optK, K = K, sampname_qc,
    ref_qc, chr, lmax = 200, mode = "integer")

finalcall

write.table(finalcall, file = paste(projectname, '_', chr, '_', optK,
'_CODEX_frac.txt', sep=''), sep='\t', quote=FALSE, row.names=FALSE)
save.image(file = paste(projectname, '_', chr, '_image', '.rda', sep=''),
compress='xz')

}



Reply all
Reply to author
Forward
0 new messages