git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/SICtools@115095 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -83,18 +83,22 @@ function(bam1,bam2,refFsa,regChr,regStart,regEnd,minBaseQuality = 13, |
83 | 83 |
testDf <- data.frame(chr = testTmp2[,1],testMtx,stringsAsFactors=FALSE) |
84 | 84 |
|
85 | 85 |
## for genotype duplicated positions, trace back |
86 |
- countMtxDup <- countMtx[!maxBaseIndex & !allZeroIndex,] |
|
87 |
- countMtxDupDf <- as.data.frame(countMtxDup[duplicated(countMtxDup[,-11]),,drop=FALSE],stringsAsFactors=FALSE) |
|
86 |
+ countMtxDup <- countMtx[!maxBaseIndex & !allZeroIndex,,drop=FALSE] |
|
87 |
+ countMtxDupDf <- as.data.frame(countMtxDup[duplicated(countMtxDup[,-11,drop=FALSE]),,drop=FALSE],stringsAsFactors=FALSE) |
|
88 | 88 |
|
89 |
- if(nrow(countMtxDupDf) > 0){ |
|
89 |
+ if(nrow(countMtxDupDf) > 0 & nrow(testDf) > 0){ |
|
90 |
+ |
|
91 |
+ countMtxDupDfFull <- cbind(countMtxDupDf,testDf[match(apply(countMtxDupDf[,-11,drop=FALSE],1,paste,collapse=' '),apply(testDf[,3:12],1,paste,collapse=' ')),c('X12','X13')]) |
|
92 |
+ countMtxDupDfFull <- countMtxDupDfFull[!is.na(countMtxDupDfFull$X12),,drop=FALSE] |
|
93 |
+ |
|
94 |
+ if(nrow(countMtxDupDfFull) > 0){ |
|
95 |
+ countMtxDupDfFull[,'X14'] <- unique(testDf$chr) |
|
96 |
+ countMtxDupDfFull <- countMtxDupDfFull[,c(14,11,1:10,12,13)] |
|
97 |
+ colnames(countMtxDupDfFull) <- colnames(testDf) |
|
98 |
+ testDf <- rbind(testDf,countMtxDupDfFull) |
|
99 |
+ testDf <- testDf[order(testDf[,'X1']),] |
|
100 |
+ } |
|
90 | 101 |
|
91 |
- countMtxDupDfFull <- cbind(countMtxDupDf,testDf[match(apply(countMtxDupDf[,-11],1,paste,collapse=' '),apply(testDf[,3:12],1,paste,collapse=' ')),c('X12','X13')]) |
|
92 |
- countMtxDupDfFull <- countMtxDupDfFull[!is.na(countMtxDupDfFull$X12),] |
|
93 |
- countMtxDupDfFull[,'X14'] <- unique(testDf$chr) |
|
94 |
- countMtxDupDfFull <- countMtxDupDfFull[,c(14,11,1:10,12,13)] |
|
95 |
- colnames(countMtxDupDfFull) <- colnames(testDf) |
|
96 |
- testDf <- rbind(testDf,countMtxDupDfFull) |
|
97 |
- testDf <- testDf[order(testDf[,'X1']),] |
|
98 | 102 |
} |
99 | 103 |
|
100 | 104 |
return(testDf) |