Open
Description
Hi,
I have a function that plots standard error and loglikelihood to visually decide on a K value. I am taking the mean standard error and I am wondering if this is the best way of getting the standard error value for each K. Is there a better way to do this? I'm thinking of extending the code to make it decide K automatically.
estimateK = function(inputFile, kStart, kEnd, nIters=20,is.BG=NULL){
likelihoodList= list()
errorList= list()
i = 0
for (k in kStart:kEnd){
i= i+1
if (is.null(is.BG)){
currSig = getPMSignature(inputFile, K = k,numInit = nIters)
errorList[[i]] = mean(bootPMSignature(inputFile,currSig,bootNum = 20)[[1]])
}
else{
BG_prob = readBGFile(inputFile)
currSig = getPMSignature(inputFile, K = k,numInit = nIters,BG = BG_prob)
errorList[[i]] = mean(bootPMSignature(inputFile,currSig,bootNum = 20,BG = BG_prob)[[1]])
}
likelihoodList[[i]] = currSig@loglikelihood
}
estimate_mat = cbind(c(kStart:kEnd),unlist(likelihoodList),unlist(errorList))
twoord.plot(lx = estimate_mat[,1],ly = estimate_mat[,2], rx =estimate_mat[,1], ry = estimate_mat[,3], type='l',xlab='Number of signatures',ylab = 'Log Likelihood',rylab = 'Standard Error')
return(estimate_mat)
}
Metadata
Metadata
Assignees
Labels
No labels