ropensci / BaseSet

Provides classes for working with sets
https://docs.ropensci.org/BaseSet
Other
10 stars 3 forks source link

Find which sets are mutually exclusive #68

Open llrs opened 8 months ago

llrs commented 8 months ago

If we want to select elements that have some mutually exclusive variables/set what would be the best way to do so?

For instance: These variables describe the positions of methylation. Some of them are exclusive (if one position is in a shelf it is not in an intron).

c("inter", "intergenic", "1to5kb", "intron", "shore", "exon", 
"exonintronboundary", "intronexonboundary", "shelf", "promoter", 
"3UTR", "island", "CDS", "enhancer", "5UTR")

If these are encoded in a matrix (like it would in BaseSet), how could one find those that are mutually exclusive?

structure(list(inter = c(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), 
    intergenic = c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE), 
    `1to5kb` = c(FALSE, TRUE, FALSE, FALSE, FALSE, FALSE), intron = c(FALSE, 
    TRUE, TRUE, TRUE, TRUE, TRUE), shore = c(FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE), exon = c(FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE), exonintronboundary = c(FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE), intronexonboundary = c(FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE), shelf = c(FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE), promoter = c(FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE), `3UTR` = c(FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE), island = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE
    ), CDS = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), enhancer = c(FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE), `5UTR` = c(FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE)), row.names = c(NA, 6L), class = "data.frame")

In this case the data doesn't show it up, but the shelf, promoter, island, shore and 1to5kb are mutually exclusive. Similarly the intron, exon, exonintronboundary, intronexonboundary.

Probably a combination of combn with a function making use of any(A & B).