Browse code

vignette bugfix/improved target detection in PRC/ROC

RussBainer authored on 18/05/2021 22:55:06
Showing 4 changed files

... ...
@@ -28,14 +28,23 @@ ct.PRC <-
28 28
 
29 29
     direction <- match.arg(direction)
30 30
     stopifnot(is(plot.it, 'logical'))
31
-    
32
-    collapse <- ifelse(sum(target.list %in% summaryDF$geneID) > sum(target.list %in% summaryDF$geneSymbol), 'geneID', 'geneSymbol')
33
-    simpleDF <- ct.simpleResult(summaryDF, collapse)
34
-    
31
+
35 32
     if(!is.character(target.list)){
36 33
       warning("Supplied target.list is not a character vector. Coercing.")
37 34
       target.list <- as.character(target.list)
38 35
     }
36
+    
37
+    #Infer whether Gsdb is ID or feature centric
38
+    gids <- sum(target.list %in% summaryDF$geneID)
39
+    gsids <- sum(target.list %in% summaryDF$geneSymbol)
40
+    
41
+    if(all(c(gsids, gids) == 0)){
42
+      stop('None of the features in the GeneSetDb are present in either the geneID or geneSymbol slots of the first provided result.')
43
+    }
44
+    
45
+    collapse <- ifelse(gids > gsids, 'geneID', 'geneSymbol')
46
+    simpleDF <- ct.simpleResult(summaryDF, collapse)
47
+    
39 48
     present <- intersect(target.list, row.names(simpleDF))
40 49
     
41 50
     if(length(present) != length(target.list)){
... ...
@@ -34,14 +34,23 @@ ct.ROC <-
34 34
 
35 35
     direction <- match.arg(direction)
36 36
     stopifnot(is(plot.it, 'logical'), is(condense, 'logical'))
37
-    
38
-    collapse <- ifelse(sum(target.list %in% summaryDF$geneID) > sum(target.list %in% summaryDF$geneSymbol), 'geneID', 'geneSymbol')
39
-    simpleDF <- ct.simpleResult(summaryDF, collapse)
40
-    
37
+
41 38
     if(!is.character(target.list)){
42 39
       warning("Supplied target.list is not a character vector. Coercing.")
43 40
       target.list <- as.character(target.list)
44 41
     }
42
+    
43
+    #Infer whether Gsdb is ID or feature centric
44
+    gids <- sum(target.list %in% summaryDF$geneID)
45
+    gsids <- sum(target.list %in% summaryDF$geneSymbol)
46
+    
47
+    if(all(c(gsids, gids) == 0)){
48
+      stop('None of the features in the GeneSetDb are present in either the geneID or geneSymbol slots of the first provided result.')
49
+    }
50
+    
51
+    collapse <- ifelse(gids > gsids, 'geneID', 'geneSymbol')
52
+    simpleDF <- ct.simpleResult(summaryDF, collapse)
53
+    
45 54
     present <- intersect(target.list, row.names(simpleDF))
46 55
     
47 56
     if(length(present) != length(target.list)){
48 57
Binary files a/data/essential.genes.RData and b/data/essential.genes.RData differ
... ...
@@ -311,18 +311,21 @@ In some cases, it may be useful to ask whether a set of known targets is disprop
311 311
 ```{r, fig.width=6, fig.height = 6, warning=FALSE}
312 312
 data("essential.genes", package = "gCrisprTools")  #Artificial list created for demonstration
313 313
 data("resultsDF", package = "gCrisprTools")
314
-ROC <- ct.ROC(resultsDF, essential.genes, stat = "deplete.p")
314
+ROC <- ct.ROC(resultsDF, essential.genes, 'enrich')
315 315
 str(ROC)
316 316
 ```
317 317
 
318 318
 ```{r, fig.width=6, fig.height = 6, warning=FALSE}
319
-PRC <- ct.PRC(resultsDF, essential.genes, stat = "deplete.p")
319
+PRC <- ct.PRC(resultsDF, essential.genes, 'enrich')
320 320
 str(PRC)
321 321
 ```
322 322
 
323 323
 Alternatively, the significance of the enrichment within the target set may be assessed directly with `ct.targetSetEnrichment`.
324 324
 
325 325
 ```{r, fig.width=6, fig.height = 6, warning=FALSE}
326
+##' tar <-  sample(unique(resultsDF$geneSymbol), 20)
327
+##' res <- ct.targetSetEnrichment(resultsDF, tar)
328
+
326 329
 targetsTest <- ct.targetSetEnrichment(resultsDF, essential.genes, enrich = FALSE)
327 330
 str(targetsTest)
328 331
 ```