... | ... |
@@ -1,9 +1,9 @@ |
1 | 1 |
#' Create file to curate PureCN results |
2 |
-#' |
|
2 |
+#' |
|
3 | 3 |
#' Function to create a CSV file that can be used to mark the correct solution |
4 | 4 |
#' in the output of a \code{\link{runAbsoluteCN}} run. |
5 |
-#' |
|
6 |
-#' |
|
5 |
+#' |
|
6 |
+#' |
|
7 | 7 |
#' @param file.rds Output of the \code{\link{runAbsoluteCN}} function, |
8 | 8 |
#' serialized with \code{saveRDS}. |
9 | 9 |
#' @param overwrite.uncurated Overwrite existing files unless flagged as |
... | ... |
@@ -15,48 +15,48 @@ |
15 | 15 |
#' @author Markus Riester |
16 | 16 |
#' @seealso \code{\link{runAbsoluteCN}} |
17 | 17 |
#' @examples |
18 |
-#' |
|
18 |
+#' |
|
19 | 19 |
#' data(purecn.example.output) |
20 | 20 |
#' file.rds <- "Sample1_PureCN.rds" |
21 |
-#' saveRDS(purecn.example.output, file=file.rds) |
|
22 |
-#' createCurationFile(file.rds) |
|
23 |
-#' |
|
21 |
+#' saveRDS(purecn.example.output, file = file.rds) |
|
22 |
+#' createCurationFile(file.rds) |
|
23 |
+#' |
|
24 | 24 |
#' @export createCurationFile |
25 | 25 |
#' @importFrom utils write.csv |
26 |
-createCurationFile <- function(file.rds, overwrite.uncurated = TRUE, |
|
27 |
- overwrite.curated=FALSE) { |
|
26 |
+createCurationFile <- function(file.rds, overwrite.uncurated = TRUE, |
|
27 |
+ overwrite.curated = FALSE) { |
|
28 | 28 |
rds <- readRDS(file.rds) |
29 | 29 |
res <- rds$results[[1]] |
30 | 30 |
contamination <- res$SNV.posterior$posterior.contamination |
31 | 31 |
contamination <- if (is.null(contamination)) 0 else contamination |
32 | 32 |
d.f.curation <- data.frame( |
33 |
- Sampleid=res$seg$ID[1], |
|
34 |
- Purity=res$purity, |
|
35 |
- Ploidy=res$ploidy, |
|
36 |
- Sex=.getSexFromRds(rds), |
|
37 |
- Contamination=contamination, |
|
38 |
- Flagged=res$flag, |
|
39 |
- Failed=FALSE, |
|
40 |
- Curated=FALSE, |
|
41 |
- Comment=res$flag_comment |
|
33 |
+ Sampleid = res$seg$ID[1], |
|
34 |
+ Purity = res$purity, |
|
35 |
+ Ploidy = res$ploidy, |
|
36 |
+ Sex = .getSexFromRds(rds), |
|
37 |
+ Contamination = contamination, |
|
38 |
+ Flagged = res$flag, |
|
39 |
+ Failed = FALSE, |
|
40 |
+ Curated = FALSE, |
|
41 |
+ Comment = res$flag_comment |
|
42 | 42 |
) |
43 | 43 |
|
44 |
- filename <- file.path(dirname(file.rds), |
|
45 |
- paste(gsub(".rds$", "", basename(file.rds)), "csv", sep=".")) |
|
44 |
+ filename <- file.path(dirname(file.rds), |
|
45 |
+ paste(gsub(".rds$", "", basename(file.rds)), "csv", sep = ".")) |
|
46 | 46 |
|
47 | 47 |
if (file.exists(filename)) { |
48 |
- tmp <- read.csv(filename, as.is=TRUE) |
|
48 |
+ tmp <- read.csv(filename, as.is = TRUE) |
|
49 | 49 |
if (tmp$Curated[1] && !overwrite.curated) { |
50 |
- warning(filename, |
|
50 |
+ warning(filename, |
|
51 | 51 |
" already exists and seems to be edited.", |
52 | 52 |
" Will not overwrite it.") |
53 | 53 |
} else if (!overwrite.uncurated) { |
54 | 54 |
warning(filename, " already exists. Will not overwrite it.") |
55 | 55 |
} else { |
56 |
- write.csv(d.f.curation, file=filename, row.names=FALSE) |
|
57 |
- } |
|
56 |
+ write.csv(d.f.curation, file = filename, row.names = FALSE) |
|
57 |
+ } |
|
58 | 58 |
} else { |
59 |
- write.csv(d.f.curation, file=filename, row.names=FALSE) |
|
59 |
+ write.csv(d.f.curation, file = filename, row.names = FALSE) |
|
60 | 60 |
} |
61 | 61 |
invisible(d.f.curation) |
62 | 62 |
} |
... | ... |
@@ -64,16 +64,16 @@ createCurationFile <- function(file.rds, overwrite.uncurated = TRUE, |
64 | 64 |
.getSexFromRds <- function(rds) { |
65 | 65 |
# if run without VCF, then we don't have sex information from VCF |
66 | 66 |
if (is.null(rds$input$sex.vcf)) return(rds$input$sex) |
67 |
- |
|
67 |
+ |
|
68 | 68 |
# conflict of coverage and snp based sex genotyper? |
69 | 69 |
if (!is.na(rds$input$sex) && !is.na(rds$input$sex.vcf)) { |
70 | 70 |
if (rds$input$sex == rds$input$sex.vcf) return(rds$input$sex) |
71 |
- return(paste("Coverage:", rds$input$sex, "VCF:", rds$input$sex.vcf)) |
|
72 |
- } |
|
73 |
- # believe coverage based more than VCF in case we have only limited |
|
71 |
+ return(paste("Coverage:", rds$input$sex, "VCF:", rds$input$sex.vcf)) |
|
72 |
+ } |
|
73 |
+ # believe coverage based more than VCF in case we have only limited |
|
74 | 74 |
# number of SNPs on chrX |
75 | 75 |
if (!is.na(rds$input$sex)) { |
76 | 76 |
return(rds$input$sex) |
77 |
- } |
|
77 |
+ } |
|
78 | 78 |
return(rds$input$sex.vcf) |
79 | 79 |
} |
... | ... |
@@ -55,7 +55,7 @@ createCurationFile <- function(file.rds, overwrite.uncurated = TRUE, |
55 | 55 |
} else { |
56 | 56 |
write.csv(d.f.curation, file=filename, row.names=FALSE) |
57 | 57 |
} |
58 |
- } else { |
|
58 |
+ } else { |
|
59 | 59 |
write.csv(d.f.curation, file=filename, row.names=FALSE) |
60 | 60 |
} |
61 | 61 |
invisible(d.f.curation) |
... | ... |
@@ -62,10 +62,16 @@ createCurationFile <- function(file.rds, overwrite.uncurated = TRUE, |
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
.getSexFromRds <- function(rds) { |
65 |
+ # if run without VCF, then we don't have sex information from VCF |
|
66 |
+ if (is.null(rds$input$sex.vcf)) return(rds$input$sex) |
|
67 |
+ |
|
68 |
+ # conflict of coverage and snp based sex genotyper? |
|
65 | 69 |
if (!is.na(rds$input$sex) && !is.na(rds$input$sex.vcf)) { |
66 | 70 |
if (rds$input$sex == rds$input$sex.vcf) return(rds$input$sex) |
67 | 71 |
return(paste("Coverage:", rds$input$sex, "VCF:", rds$input$sex.vcf)) |
68 | 72 |
} |
73 |
+ # believe coverage based more than VCF in case we have only limited |
|
74 |
+ # number of SNPs on chrX |
|
69 | 75 |
if (!is.na(rds$input$sex)) { |
70 | 76 |
return(rds$input$sex) |
71 | 77 |
} |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@126298 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -27,7 +27,7 @@ createCurationFile <- function(file.rds, overwrite.uncurated = TRUE, |
27 | 27 |
overwrite.curated=FALSE) { |
28 | 28 |
rds <- readRDS(file.rds) |
29 | 29 |
res <- rds$results[[1]] |
30 |
- contamination <- res$SNV.posterior$beta.model$posterior.contamination |
|
30 |
+ contamination <- res$SNV.posterior$posterior.contamination |
|
31 | 31 |
contamination <- if (is.null(contamination)) 0 else contamination |
32 | 32 |
d.f.curation <- data.frame( |
33 | 33 |
Sampleid=res$seg$ID[1], |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@125950 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -8,6 +8,8 @@ |
8 | 8 |
#' serialized with \code{saveRDS}. |
9 | 9 |
#' @param overwrite.uncurated Overwrite existing files unless flagged as |
10 | 10 |
#' \sQuote{Curated}. |
11 |
+#' @param overwrite.curated Overwrite existing files even if flagged as |
|
12 |
+#' \sQuote{Curated}. |
|
11 | 13 |
#' @return A \code{data.frame} with the tumor purity and ploidy of the maximum |
12 | 14 |
#' likelihood solution. |
13 | 15 |
#' @author Markus Riester |
... | ... |
@@ -21,7 +23,8 @@ |
21 | 23 |
#' |
22 | 24 |
#' @export createCurationFile |
23 | 25 |
#' @importFrom utils write.csv |
24 |
-createCurationFile <- function(file.rds, overwrite.uncurated = TRUE) { |
|
26 |
+createCurationFile <- function(file.rds, overwrite.uncurated = TRUE, |
|
27 |
+ overwrite.curated=FALSE) { |
|
25 | 28 |
rds <- readRDS(file.rds) |
26 | 29 |
res <- rds$results[[1]] |
27 | 30 |
contamination <- res$SNV.posterior$beta.model$posterior.contamination |
... | ... |
@@ -43,7 +46,7 @@ createCurationFile <- function(file.rds, overwrite.uncurated = TRUE) { |
43 | 46 |
|
44 | 47 |
if (file.exists(filename)) { |
45 | 48 |
tmp <- read.csv(filename, as.is=TRUE) |
46 |
- if (tmp$Curated[1]) { |
|
49 |
+ if (tmp$Curated[1] && !overwrite.curated) { |
|
47 | 50 |
warning(filename, |
48 | 51 |
" already exists and seems to be edited.", |
49 | 52 |
" Will not overwrite it.") |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@125771 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -24,12 +24,14 @@ |
24 | 24 |
createCurationFile <- function(file.rds, overwrite.uncurated = TRUE) { |
25 | 25 |
rds <- readRDS(file.rds) |
26 | 26 |
res <- rds$results[[1]] |
27 |
- |
|
27 |
+ contamination <- res$SNV.posterior$beta.model$posterior.contamination |
|
28 |
+ contamination <- if (is.null(contamination)) 0 else contamination |
|
28 | 29 |
d.f.curation <- data.frame( |
29 | 30 |
Sampleid=res$seg$ID[1], |
30 | 31 |
Purity=res$purity, |
31 | 32 |
Ploidy=res$ploidy, |
32 | 33 |
Sex=.getSexFromRds(rds), |
34 |
+ Contamination=contamination, |
|
33 | 35 |
Flagged=res$flag, |
34 | 36 |
Failed=FALSE, |
35 | 37 |
Curated=FALSE, |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@125364 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -1,13 +1,27 @@ |
1 |
-createCurationFile <- structure(function(# Create file to curate PureCN results |
|
2 |
-### Function to create a CSV file that can be used to mark the correct solution |
|
3 |
-### in the output of a \code{\link{runAbsoluteCN}} run. |
|
4 |
-file.rds, |
|
5 |
-### Output of the \code{\link{runAbsoluteCN}} function, serialized |
|
6 |
-### with \code{saveRDS}. |
|
7 |
-##seealso<< \code{\link{runAbsoluteCN}} |
|
8 |
-overwrite.uncurated=TRUE |
|
9 |
-### Overwrite existing files unless flagged as \sQuote{Curated}. |
|
10 |
-) { |
|
1 |
+#' Create file to curate PureCN results |
|
2 |
+#' |
|
3 |
+#' Function to create a CSV file that can be used to mark the correct solution |
|
4 |
+#' in the output of a \code{\link{runAbsoluteCN}} run. |
|
5 |
+#' |
|
6 |
+#' |
|
7 |
+#' @param file.rds Output of the \code{\link{runAbsoluteCN}} function, |
|
8 |
+#' serialized with \code{saveRDS}. |
|
9 |
+#' @param overwrite.uncurated Overwrite existing files unless flagged as |
|
10 |
+#' \sQuote{Curated}. |
|
11 |
+#' @return A \code{data.frame} with the tumor purity and ploidy of the maximum |
|
12 |
+#' likelihood solution. |
|
13 |
+#' @author Markus Riester |
|
14 |
+#' @seealso \code{\link{runAbsoluteCN}} |
|
15 |
+#' @examples |
|
16 |
+#' |
|
17 |
+#' data(purecn.example.output) |
|
18 |
+#' file.rds <- "Sample1_PureCN.rds" |
|
19 |
+#' saveRDS(purecn.example.output, file=file.rds) |
|
20 |
+#' createCurationFile(file.rds) |
|
21 |
+#' |
|
22 |
+#' @export createCurationFile |
|
23 |
+#' @importFrom utils write.csv |
|
24 |
+createCurationFile <- function(file.rds, overwrite.uncurated = TRUE) { |
|
11 | 25 |
rds <- readRDS(file.rds) |
12 | 26 |
res <- rds$results[[1]] |
13 | 27 |
|
... | ... |
@@ -40,14 +54,7 @@ overwrite.uncurated=TRUE |
40 | 54 |
write.csv(d.f.curation, file=filename, row.names=FALSE) |
41 | 55 |
} |
42 | 56 |
invisible(d.f.curation) |
43 |
-### A \code{data.frame} with the tumor purity and ploidy of the |
|
44 |
-### maximum likelihood solution. |
|
45 |
-},ex=function() { |
|
46 |
-data(purecn.example.output) |
|
47 |
-file.rds <- "Sample1_PureCN.rds" |
|
48 |
-saveRDS(purecn.example.output, file=file.rds) |
|
49 |
-createCurationFile(file.rds) |
|
50 |
-}) |
|
57 |
+} |
|
51 | 58 |
|
52 | 59 |
.getSexFromRds <- function(rds) { |
53 | 60 |
if (!is.na(rds$input$sex) && !is.na(rds$input$sex.vcf)) { |
... | ... |
@@ -59,4 +66,3 @@ createCurationFile(file.rds) |
59 | 66 |
} |
60 | 67 |
return(rds$input$sex.vcf) |
61 | 68 |
} |
62 |
- |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@124685 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -44,7 +44,7 @@ overwrite.uncurated=TRUE |
44 | 44 |
### maximum likelihood solution. |
45 | 45 |
},ex=function() { |
46 | 46 |
data(purecn.example.output) |
47 |
-file.rds <- 'Sample1_PureCN.rds' |
|
47 |
+file.rds <- "Sample1_PureCN.rds" |
|
48 | 48 |
saveRDS(purecn.example.output, file=file.rds) |
49 | 49 |
createCurationFile(file.rds) |
50 | 50 |
}) |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@122964 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -8,12 +8,14 @@ file.rds, |
8 | 8 |
overwrite.uncurated=TRUE |
9 | 9 |
### Overwrite existing files unless flagged as \sQuote{Curated}. |
10 | 10 |
) { |
11 |
- res <- readRDS(file.rds)$results[[1]] |
|
11 |
+ rds <- readRDS(file.rds) |
|
12 |
+ res <- rds$results[[1]] |
|
12 | 13 |
|
13 | 14 |
d.f.curation <- data.frame( |
14 | 15 |
Sampleid=res$seg$ID[1], |
15 | 16 |
Purity=res$purity, |
16 | 17 |
Ploidy=res$ploidy, |
18 |
+ Sex=.getSexFromRds(rds), |
|
17 | 19 |
Flagged=res$flag, |
18 | 20 |
Failed=FALSE, |
19 | 21 |
Curated=FALSE, |
... | ... |
@@ -46,3 +48,15 @@ file.rds <- 'Sample1_PureCN.rds' |
46 | 48 |
saveRDS(purecn.example.output, file=file.rds) |
47 | 49 |
createCurationFile(file.rds) |
48 | 50 |
}) |
51 |
+ |
|
52 |
+.getSexFromRds <- function(rds) { |
|
53 |
+ if (!is.na(rds$input$sex) && !is.na(rds$input$sex.vcf)) { |
|
54 |
+ if (rds$input$sex == rds$input$sex.vcf) return(rds$input$sex) |
|
55 |
+ return(paste("Coverage:", rds$input$sex, "VCF:", rds$input$sex.vcf)) |
|
56 |
+ } |
|
57 |
+ if (!is.na(rds$input$sex)) { |
|
58 |
+ return(rds$input$sex) |
|
59 |
+ } |
|
60 |
+ return(rds$input$sex.vcf) |
|
61 |
+} |
|
62 |
+ |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@119603 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -6,7 +6,7 @@ file.rds, |
6 | 6 |
### with \code{saveRDS}. |
7 | 7 |
##seealso<< \code{\link{runAbsoluteCN}} |
8 | 8 |
overwrite.uncurated=TRUE |
9 |
-### Overwrite existing files unless flagged as "Curated". |
|
9 |
+### Overwrite existing files unless flagged as \sQuote{Curated}. |
|
10 | 10 |
) { |
11 | 11 |
res <- readRDS(file.rds)$results[[1]] |
12 | 12 |
|
... | ... |
@@ -38,8 +38,8 @@ overwrite.uncurated=TRUE |
38 | 38 |
write.csv(d.f.curation, file=filename, row.names=FALSE) |
39 | 39 |
} |
40 | 40 |
invisible(d.f.curation) |
41 |
-###A data.frame with the tumor purity and ploidy of the maximum likelihood |
|
42 |
-###solution. |
|
41 |
+### A \code{data.frame} with the tumor purity and ploidy of the |
|
42 |
+### maximum likelihood solution. |
|
43 | 43 |
},ex=function() { |
44 | 44 |
data(purecn.example.output) |
45 | 45 |
file.rds <- 'Sample1_PureCN.rds' |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@119236 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -1,8 +1,10 @@ |
1 | 1 |
createCurationFile <- structure(function(# Create file to curate PureCN results |
2 | 2 |
### Function to create a CSV file that can be used to mark the correct solution |
3 |
-### in the output of a runAbsoluteCN() run. |
|
3 |
+### in the output of a \code{\link{runAbsoluteCN}} run. |
|
4 | 4 |
file.rds, |
5 |
-### Output of the runAbsoluteCN() function, serialized with saveRDS() |
|
5 |
+### Output of the \code{\link{runAbsoluteCN}} function, serialized |
|
6 |
+### with \code{saveRDS}. |
|
7 |
+##seealso<< \code{\link{runAbsoluteCN}} |
|
6 | 8 |
overwrite.uncurated=TRUE |
7 | 9 |
### Overwrite existing files unless flagged as "Curated". |
8 | 10 |
) { |
... | ... |
@@ -37,7 +39,7 @@ overwrite.uncurated=TRUE |
37 | 39 |
} |
38 | 40 |
invisible(d.f.curation) |
39 | 41 |
###A data.frame with the tumor purity and ploidy of the maximum likelihood |
40 |
-###solution |
|
42 |
+###solution. |
|
41 | 43 |
},ex=function() { |
42 | 44 |
data(purecn.example.output) |
43 | 45 |
file.rds <- 'Sample1_PureCN.rds' |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@116407 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -24,10 +24,11 @@ overwrite.uncurated=TRUE |
24 | 24 |
if (file.exists(filename)) { |
25 | 25 |
tmp <- read.csv(filename, as.is=TRUE) |
26 | 26 |
if (tmp$Curated[1]) { |
27 |
- warning(paste(filename, |
|
28 |
- "already exists and seems to be edited. Will not overwrite it.")) |
|
27 |
+ warning(filename, |
|
28 |
+ " already exists and seems to be edited.", |
|
29 |
+ " Will not overwrite it.") |
|
29 | 30 |
} else if (!overwrite.uncurated) { |
30 |
- warning(paste(filename, "already exists. Will not overwrite it.")) |
|
31 |
+ warning(filename, " already exists. Will not overwrite it.") |
|
31 | 32 |
} else { |
32 | 33 |
write.csv(d.f.curation, file=filename, row.names=FALSE) |
33 | 34 |
} |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@116399 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -24,7 +24,8 @@ overwrite.uncurated=TRUE |
24 | 24 |
if (file.exists(filename)) { |
25 | 25 |
tmp <- read.csv(filename, as.is=TRUE) |
26 | 26 |
if (tmp$Curated[1]) { |
27 |
- warning(paste(filename, "already exists and seems to be edited. Will not overwrite it.")) |
|
27 |
+ warning(paste(filename, |
|
28 |
+ "already exists and seems to be edited. Will not overwrite it.")) |
|
28 | 29 |
} else if (!overwrite.uncurated) { |
29 | 30 |
warning(paste(filename, "already exists. Will not overwrite it.")) |
30 | 31 |
} else { |
... | ... |
@@ -33,7 +34,7 @@ overwrite.uncurated=TRUE |
33 | 34 |
} else { |
34 | 35 |
write.csv(d.f.curation, file=filename, row.names=FALSE) |
35 | 36 |
} |
36 |
- d.f.curation |
|
37 |
+ invisible(d.f.curation) |
|
37 | 38 |
###A data.frame with the tumor purity and ploidy of the maximum likelihood |
38 | 39 |
###solution |
39 | 40 |
},ex=function() { |
... | ... |
@@ -41,4 +42,4 @@ data(purecn.example.output) |
41 | 42 |
file.rds <- 'Sample1_PureCN.rds' |
42 | 43 |
saveRDS(purecn.example.output, file=file.rds) |
43 | 44 |
createCurationFile(file.rds) |
44 |
-}) |
|
45 |
+}) |
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@116291 bc3139a8-67e5-0310-9ffc-ced21a209358
1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,44 @@ |
1 |
+createCurationFile <- structure(function(# Create file to curate PureCN results |
|
2 |
+### Function to create a CSV file that can be used to mark the correct solution |
|
3 |
+### in the output of a runAbsoluteCN() run. |
|
4 |
+file.rds, |
|
5 |
+### Output of the runAbsoluteCN() function, serialized with saveRDS() |
|
6 |
+overwrite.uncurated=TRUE |
|
7 |
+### Overwrite existing files unless flagged as "Curated". |
|
8 |
+) { |
|
9 |
+ res <- readRDS(file.rds)$results[[1]] |
|
10 |
+ |
|
11 |
+ d.f.curation <- data.frame( |
|
12 |
+ Sampleid=res$seg$ID[1], |
|
13 |
+ Purity=res$purity, |
|
14 |
+ Ploidy=res$ploidy, |
|
15 |
+ Flagged=res$flag, |
|
16 |
+ Failed=FALSE, |
|
17 |
+ Curated=FALSE, |
|
18 |
+ Comment=res$flag_comment |
|
19 |
+ ) |
|
20 |
+ |
|
21 |
+ filename <- file.path(dirname(file.rds), |
|
22 |
+ paste(gsub(".rds$", "", basename(file.rds)), "csv", sep=".")) |
|
23 |
+ |
|
24 |
+ if (file.exists(filename)) { |
|
25 |
+ tmp <- read.csv(filename, as.is=TRUE) |
|
26 |
+ if (tmp$Curated[1]) { |
|
27 |
+ warning(paste(filename, "already exists and seems to be edited. Will not overwrite it.")) |
|
28 |
+ } else if (!overwrite.uncurated) { |
|
29 |
+ warning(paste(filename, "already exists. Will not overwrite it.")) |
|
30 |
+ } else { |
|
31 |
+ write.csv(d.f.curation, file=filename, row.names=FALSE) |
|
32 |
+ } |
|
33 |
+ } else { |
|
34 |
+ write.csv(d.f.curation, file=filename, row.names=FALSE) |
|
35 |
+ } |
|
36 |
+ d.f.curation |
|
37 |
+###A data.frame with the tumor purity and ploidy of the maximum likelihood |
|
38 |
+###solution |
|
39 |
+},ex=function() { |
|
40 |
+data(purecn.example.output) |
|
41 |
+file.rds <- 'Sample1_PureCN.rds' |
|
42 |
+saveRDS(purecn.example.output, file=file.rds) |
|
43 |
+createCurationFile(file.rds) |
|
44 |
+}) |