Skip to content
Permalink
Browse files

fix Corrected_Ratio column in output segs file

Corrected_Ratio contained all NAs because correctIntegerCN() was looking at the Median_HaplotypeRatio column.  Median_HaplotypeRatio should only be present in the segs and results objects/files for 10X Genomics WGS data. Now, Median_HaplotypeRatio will not be included in the output files if not using TitanCNA_10X_snakemake pipeline.
Fixes #67. Thanks to @aleighgreen for catching this bug.
  • Loading branch information...
gavinha committed Feb 8, 2019
1 parent 8fbcab5 commit 88a51c0a327c8a590563894b829539b538a95fa5
Showing with 9 additions and 5 deletions.
  1. +9 −5 R/utils.R
@@ -1080,8 +1080,12 @@ outputTitanSegments <- function(results, id, convergeParams, filename = NULL, ig
results$HaplotypeRatio <- pmax(results$HaplotypeRatio, 1-results$HaplotypeRatio)
}
segs <- data.table(Sample = character(), Chromosome = character(), Start_Position.bp. = integer(),
End_Position.bp. = integer(), Length.snp. = integer(), Median_Ratio = numeric(),
Median_HaplotypeRatio = numeric(), Median_logR = numeric(), TITAN_state = integer(),
End_Position.bp. = integer(), Length.snp. = integer(), Median_Ratio = numeric())
# add HaplotypeRatio column if also present in results object
if (!is.null(results$HaplotypeRatio)){
segs <- cbind(segs, Median_HaplotypeRatio = numeric())
}
segs <- cbind(segs, Median_logR = numeric(), TITAN_state = integer(),
TITAN_call = character(), Copy_Number = integer(), MinorCN = integer(), MajorCN = integer(),
Clonal_Cluster = integer(), Cellular_Prevalence = numeric())[1:numSegs]
segs[, Sample := id]
@@ -1106,8 +1110,6 @@ outputTitanSegments <- function(results, id, convergeParams, filename = NULL, ig
segs[j, "Cellular_Prevalence"] <- segDF[1, "CellularPrevalence"]
if (!is.null(segDF$HaplotypeRatio)){
segs[j, "Median_HaplotypeRatio"] <- round(median(segDF$HaplotypeRatio, na.rm = TRUE), digits = 6)
}else{
segs[j, "Median_HaplotypeRatio"] <- NA
}
if (segDF[1, "Chr"] == segDF[numR, "Chr"]){
segs[j, "End_Position.bp."] <- segDF[numR, "Position"]
@@ -1180,7 +1182,9 @@ correctIntegerCN <- function(cn, segs, purity, ploidy, maxCNtoCorrect.autosomes
## determine if Median_HaplotypeRatio (segs) and HaplotypeRatio (cn) columns exists (i.e. 10X analysis)
segs.allelicRatioColName <- "Median_Ratio"
if ("Median_HaplotypeRatio" %in% names(segs)){
segs.allelicRatioColName <- "Median_HaplotypeRatio"
if (segs[, Median_HaplotypeRatio]){
segs.allelicRatioColName <- "Median_HaplotypeRatio"
}
}
cn.allelicRatioColName <- "AllelicRatio"
if ("HaplotypeRatio" %in% names(cn)){

0 comments on commit 88a51c0

Please sign in to comment.
You can’t perform that action at this time.