Skip to content

Commit

Permalink
ASCAT result now also returns distance matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
haasek committed Jun 16, 2016
1 parent 102d2d9 commit 647c30b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ASCAT/R/ascat.R
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ ascat.plotSegmentedData = function(ASCATobj) {
#' 6. nonaberrantarrays: arrays on which ASCAT analysis indicates that they show virtually no aberrations\cr
#' 7. segments: an array containing the copy number segments of each sample (not including failed arrays)\cr
#' 8. segments_raw: an array containing the copy number segments of each sample without any rounding applied\cr
#' 9. distance_matrix: distances for a range of ploidy and tumor percentage values
#'
#' @export
#'
Expand Down Expand Up @@ -679,6 +680,12 @@ ascat.runAscat = function(ASCATobj, gamma = 0.55, pdfPlot = F, y_limit = 5, circ
n2[,i] = res[[goodarrays[i]]]$nB
}

distance_matrix = vector("list",length(goodarrays))
names(distance_matrix) <- colnames(ASCATobj$Tumor_LogR)[goodarrays]
for (i in 1:length(goodarrays)) {
distance_matrix[[i]] = res[[goodarrays[i]]]$distance_matrix
}

tp = vector(length=length(goodarrays))
psi = vector(length=length(goodarrays))
ploidy = vector(length=length(goodarrays))
Expand Down Expand Up @@ -743,10 +750,11 @@ ascat.runAscat = function(ASCATobj, gamma = 0.55, pdfPlot = F, y_limit = 5, circ
naarrays = NULL
seg = NULL
seg_raw = NULL
distance_matrix = NULL
}

return(list(nA = n1, nB = n2, aberrantcellfraction = tp, ploidy = ploidy, psi = psi, goodnessOfFit = goodnessOfFit,
failedarrays = fa, nonaberrantarrays = naarrays, segments = seg, segments_raw = seg_raw))
failedarrays = fa, nonaberrantarrays = naarrays, segments = seg, segments_raw = seg_raw, distance_matrix = distance_matrix))
}

# helper function to split the genome into parts
Expand Down Expand Up @@ -1489,7 +1497,7 @@ runASCAT = function(lrr, baf, lrrsegmented, bafsegmented, gender, SNPpos, chromo
}

return(list(rho = rho_opt1, psi = psi_opt1, goodnessOfFit = goodnessOfFit_opt1, nonaberrant = nonaberrant,
nA = n1all, nB = n2all, seg = seg, seg_raw = seg_raw))
nA = n1all, nB = n2all, seg = seg, seg_raw = seg_raw, distance_matrix = d))

}

Expand All @@ -1502,7 +1510,7 @@ runASCAT = function(lrr, baf, lrrsegmented, bafsegmented, gender, SNPpos, chromo
dev.off()

warning(paste("ASCAT could not find an optimal ploidy and cellularity value for sample ", name, ".\n", sep=""))
return(list(rho = NA, psi = NA, goodnessOfFit = NA, nonaberrant = F, nA = NA, nB = NA, seg = NA, seg_raw = NA))
return(list(rho = NA, psi = NA, goodnessOfFit = NA, nonaberrant = F, nA = NA, nB = NA, seg = NA, seg_raw = NA, distance_matrix = NA))
}

}
Expand Down

0 comments on commit 647c30b

Please sign in to comment.