Browse code

Version bump to make next stable 2.0; linting of some older code.

Markus Riester authored on 19/09/2021 18:58:19
Showing 1 changed files
... ...
@@ -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
 }
Browse code

Added support for GATK4 segmentation files (#6).

Markus Riester authored on 11/08/2019 16:33:11
Showing 1 changed files
1 1
old mode 100755
2 2
new mode 100644
Browse code

Some final code cleanup before 1.8 with lintr.

lima1 authored on 15/10/2017 00:49:40
Showing 1 changed files
... ...
@@ -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)
Browse code

Fix for createCurationFile crash without VCF (https://github.com/lima1/PureCN/issues/14)

Markus Riester authored on 10/10/2017 20:58:54
Showing 1 changed files
... ...
@@ -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
     }    
Browse code

Removed beta.model from SNV.posterior.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@126298 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 29/01/2017 01:50:31
Showing 1 changed files
... ...
@@ -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], 
Browse code

Skip balanced high ploidy solutions from post.optimization; other minor tweaks and documentation improvements.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@125950 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 15/01/2017 20:41:48
Showing 1 changed files
... ...
@@ -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.")
Browse code

Added alpha version of contamination plot.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@125771 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 09/01/2017 03:11:04
Showing 1 changed files
... ...
@@ -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, 
Browse code

Switched from inlinedocs to roxygen2.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@125364 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 21/12/2016 08:33:05
Showing 1 changed files
... ...
@@ -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
-    
Browse code

Use double over single quotes.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@124685 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 01/12/2016 03:58:10
Showing 1 changed files
... ...
@@ -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
 })
Browse code

Interval padding.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@122964 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 23/10/2016 01:42:13
Showing 1 changed files
... ...
@@ -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
+    
Browse code

Added support for 100% pure samples in matched normal mode; Code cleanups; Polishing of manpages.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@119603 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 24/07/2016 21:05:26
Showing 1 changed files
... ...
@@ -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'
Browse code

Formatting of function names and code in manpages.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@119236 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 09/07/2016 23:14:53
Showing 1 changed files
... ...
@@ -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'
Browse code

fixed newly introduced bug in .strip.chr.name, more code cleanups

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@116407 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 17/04/2016 05:14:08
Showing 1 changed files
... ...
@@ -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
         }       
Browse code

shorten lines to 80 characters

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@116399 bc3139a8-67e5-0310-9ffc-ced21a209358

Markus Riester authored on 16/04/2016 23:19:25
Showing 1 changed files
... ...
@@ -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
+})
Browse code

Adding PureCN, MultiDataSet, Harman

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/PureCN@116291 bc3139a8-67e5-0310-9ffc-ced21a209358

Martin Morgan authored on 14/04/2016 20:21:39
Showing 1 changed files
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
+})