Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gavinha/TitanCNA
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinha committed May 7, 2019
2 parents 5aa0249 + 88a51c0 commit 9470fdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"]
Expand Down Expand Up @@ -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)){
Expand Down
4 changes: 2 additions & 2 deletions scripts/snakemake/TitanCNA.snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ rule selectSolution:
"logs/titan/selectSolution.log"
shell:
"""
ploidyRun2=results/titan/titanCNA_ploidy2/
ploidyRun2=results/titan/hmm/titanCNA_ploidy2/
if [ -d results/titan/hmm/titanCNA_ploidy3/ ]; then
ploidyRun3=results/titan/hmm/titanCNA_ploidy3/
else
Expand All @@ -85,4 +85,4 @@ rule selectSolution:
fi
Rscript {params.solutionRscript} --ploidyRun2 $ploidyRun2 --ploidyRun3 $ploidyRun3 --ploidyRun4 $ploidyRun4 --threshold {params.threshold} --outFile {output} > {log} 2> {log}
"""


0 comments on commit 9470fdc

Please sign in to comment.