Browse code

motif/TF mapping sources now case insensitive

paul-shannon authored on 26/09/2017 20:09:39
Showing3 changed files

... ...
@@ -1,8 +1,8 @@
1 1
 Package: MotifDb
2 2
 Type: Package
3 3
 Title: An Annotated Collection of Protein-DNA Binding Sequence Motifs
4
-Version: 1.19.8
5
-Date: 2017-09-18
4
+Version: 1.19.9
5
+Date: 2017-09-26
6 6
 Author: Paul Shannon, Matt Richards
7 7
 Maintainer: Paul Shannon <pshannon@systemsbiology.org>
8 8
 Depends: R (>= 2.15.0), methods, BiocGenerics, S4Vectors, IRanges, Biostrings
... ...
@@ -348,9 +348,10 @@ matrixToJasparText <- function (matrices)
348 348
 setMethod ('motifToGene', 'MotifList',
349 349
 
350 350
    function (object, motifs, source) {
351
-     stopifnot(source %in% c("MotifDb", "TFClass"))
351
+     source <- tolower(source)
352
+     stopifnot(source %in% c("motifdb", "tfclass"))
352 353
      tbl <- data.frame()
353
-     if(source %in% c("MotifDb")){
354
+     if(source %in% c("motifdb")){
354 355
         tbl <- as.data.frame(subset(mcols(object), providerId %in% motifs))
355 356
         tbl <- unique(tbl [, c("geneSymbol", "providerId", "dataSource", "organism", "pubmedID")])
356 357
         colnames(tbl) <- c("geneSymbol", "motif", "dataSource", "organism", "pubmedID")
... ...
@@ -358,7 +359,7 @@ setMethod ('motifToGene', 'MotifList',
358 359
         tbl <- tbl[, c("motif", "geneSymbol", "dataSource", "organism", "pubmedID")]
359 360
         tbl$from <- "MotifDb"
360 361
         }
361
-     if(source %in% c("TFClass")){
362
+     if(source %in% c("tfclass")){
362 363
         tbl <- subset(object@manuallyCuratedGeneMotifAssociationTable, motif %in% motifs)
363 364
         tbl <- unique(tbl[, c("motif", "tf.gene", "pubmedID")])
364 365
         tbl <- tbl[order(tbl$motif),]
... ...
@@ -374,7 +375,8 @@ setMethod ('motifToGene', 'MotifList',
374 375
 setMethod ('geneToMotif', 'MotifList',
375 376
 
376 377
    function (object, geneSymbols, source) {
377
-     stopifnot(source %in% c("MotifDb", "TFClass"))
378
+     source <- tolower(source)
379
+     stopifnot(source %in% c("motifdb", "tfclass"))
378 380
      #browser()
379 381
      extract.mdb <- function(gene){
380 382
         tbl <- as.data.frame(subset(mcols(object), geneSymbol == gene))
... ...
@@ -382,12 +384,12 @@ setMethod ('geneToMotif', 'MotifList',
382 384
         colnames(tbl) <- c("geneSymbol", "motif", "dataSource", "organism", "pubmedID")
383 385
         tbl
384 386
         }
385
-     if(source %in% c("MotifDb")){
387
+     if(source %in% c("motifdb")){
386 388
         tbls <- lapply(geneSymbols, extract.mdb)
387 389
         result <- do.call(rbind, tbls)
388 390
         result$from <- "MotifDb"
389 391
         }
390
-     if(source %in% c("TFClass")){
392
+     if(source %in% c("tfclass")){
391 393
         tbl <- subset(object@manuallyCuratedGeneMotifAssociationTable, tf.gene %in% geneSymbols)
392 394
         tbl <- unique(tbl[, c("motif", "tf.gene", "pubmedID")])
393 395
         tbl <- tbl[order(tbl$tf.gene),]
... ...
@@ -403,9 +405,10 @@ setMethod ('geneToMotif', 'MotifList',
403 405
 setMethod('associateTranscriptionFactors', 'MotifList',
404 406
 
405 407
    function(object, tbl.withMotifs, source, expand.rows){
406
-     stopifnot(source %in% c("MotifDb", "TFClass"))
408
+     source <- tolower(source)
409
+     stopifnot(source %in% c("motifdb", "tfclass"))
407 410
      tbl.out <- data.frame()
408
-     if(source %in% c("MotifDb")){
411
+     if(source %in% c("motifdb")){
409 412
            # lookup up in the object metadata, expect one TF geneSymbol per matrix name
410 413
         pfm.ids <- tbl.withMotifs[, "motifName"]
411 414
         matched.rows <- match(pfm.ids, names(as.list(object)))
... ...
@@ -415,7 +418,7 @@ setMethod('associateTranscriptionFactors', 'MotifList',
415 418
         tbl.new$pubmedID[nchar(tbl.new$pubmedID)==0] <- NA
416 419
         tbl.out <- as.data.frame(cbind(tbl.withMotifs, tbl.new))
417 420
         } # direct
418
-     if(source %in% c("TFClass")){
421
+     if(source %in% c("tfclass")){
419 422
         if(! "shortMotif" %in% colnames(tbl.withMotifs)){
420 423
            stop("MotifDb::assoicateTranscriptionFactors needs a 'shortMotif' column with the TFClass source")
421 424
            }
... ...
@@ -759,13 +759,13 @@ test.geneToMotif <- function()
759 759
    genes <- c("FOS", "ATF5", "bogus")
760 760
 
761 761
       # use  TFClass family classifcation
762
-   tbl.i <- geneToMotif(mdb, genes, source="TFClass")
762
+   tbl.i <- geneToMotif(mdb, genes, source="TfClaSS")   # intentional mis-capitalization
763 763
    checkEquals(tbl.i$gene,  c("ATF5", "FOS", "FOS"))
764 764
    checkEquals(tbl.i$motif,  c("MA0833.1", "MA0099.2", "MA0476.1"))
765 765
    checkEquals(tbl.i$from, rep("TFClass", 3))
766 766
 
767 767
       # MotifDb mode uses the MotifDb metadata, pulled from many sources
768
-   tbl.d <- geneToMotif(mdb, genes, source="MotifDb")
768
+   tbl.d <- geneToMotif(mdb, genes, source="mOtifdb")     # intentional mis-capitalization
769 769
    checkEquals(dim(tbl.d), c(12, 6))
770 770
    checkEquals(subset(tbl.d, dataSource=="jaspar2016" & geneSymbol== "FOS")$motif, "MA0476.1")
771 771
       # no recognizable (i.e., jaspar standard) motif name returned by MotifDb metadata